/functions/Inputs.php
PHP | 264 lines | 222 code | 37 blank | 5 comment | 61 complexity | 8a2f7d77efd8f37e9f304a4553e156cb MD5 | raw file
- <?php
- function DateInput($value,$name,$title='',$div=true,$allow_na=true)
- {
- if(Preferences('HIDDEN')!='Y')
- $div = false;
- if(AllowEdit() && !$_REQUEST['_CENTRE_PDF'])
- {
- if($value=='' || $div==false)
- return PrepareDate($value,"_$name",$allow_na).($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- else
- return "<DIV id='div$name'><div onclick='javascript:addHTML(\"".str_replace('"','\"',PrepareDate($value,"_$name",true,array('Y'=>1,'M'=>1,'D'=>1))).($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'')."\",\"div$name\",true)'>".(($value!='')?ProperDate($value):'-').($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'').'</div></DIV>';
- }
- else
- return (($value!='')?ProperDate($value):'-').($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- }
- function TextInput($value,$name,$title='',$options='',$div=true)
- {
- if(Preferences('HIDDEN')!='Y')
- $div = false;
- // mab - support array style $option values
- if(AllowEdit() && !$_REQUEST['_CENTRE_PDF'])
- {
- $value = str_replace("'",''',str_replace('"','”',$value));
- $value1 = is_array($value) ? $value[1] : $value;
- $value = is_array($value) ? $value[0] : $value;
- if(strpos($options,'size')===false && $value!='')
- $options .= ' size='.strlen($value);
- elseif(strpos($options,'size')===false)
- $options .= ' size=10';
- if((trim($value)=='' || $div==false))
- return "<INPUT type=text name=$name ".(($value || $value==='0')?"value=\"$value\"":'')." $options>".($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- else
- return "<DIV id='div$name'><div onclick='javascript:addHTML(\"<INPUT type=text id=input$name name=$name ".(($value || $value==='0')?"value=\\\"".str_replace('"','”',$value)."\\\"":'')." $options>".($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'')."\",\"div$name\",true); document.getElementById(\"input$name\").focus();'>".(($value!='')?str_replace('"','”',$value1):'-').($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').'</small>':'').'</div></DIV>';
- }
- else
- return (((is_array($value)?$value[1]:$value)!='')?(is_array($value)?$value[1]:$value):'-').($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- }
- function TextAreaInput($value,$name,$title='',$options='',$div=true)
- {
- if(Preferences('HIDDEN')!='Y')
- $div = false;
- if(AllowEdit() && !$_REQUEST['_CENTRE_PDF'])
- {
- $value = str_replace("'",''',str_replace('"','”',$value));
- if(strpos($options,'cols')===false)
- $options .= ' cols=30';
- if(strpos($options,'rows')===false)
- $options .= ' rows=4';
- $rows = substr($options,strpos($options,'rows')+5,2)*1;
- $cols = substr($options,strpos($options,'cols')+5,2)*1;
- if($value=='' || $div==false)
- return "<TEXTAREA name=$name $options>$value</TEXTAREA>".($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- else
- return "<DIV id='div$name'><div onclick='javascript:addHTML(\"<TEXTAREA id=textarea$name name=$name $options>".ereg_replace("[\n\r]",'\u000D\u000A',str_replace("\r\n",'\u000D\u000A',str_replace("'","'",$value)))."</TEXTAREA>".($title!=''?"<BR><small>".str_replace("'",''',(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':''))."</small>":'')."\",\"div$name\",true); document.getElementById(\"textarea$name\").value=unescape(document.getElementById(\"textarea$name\").value);'><TABLE class=LO_field ><TR><TD>".((substr_count($value,"\r\n")>$rows)?'<DIV style="overflow:auto; height:'.(15*$rows).'px; width:'.($cols*10).'; padding-right: 16px;">'.nl2br($value).'</DIV>':'<DIV style="overflow:auto; width:300; padding-right: 16px;">'.nl2br($value).'</DIV>').'</TD></TR></TABLE>'.($title!=''?'<BR><small>'.str_replace("'",''',(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'')).'</small>':'').'</div></DIV>';
- }
- else
- return (($value!='')?nl2br($value):'-').($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- }
- function CheckboxInput($value,$name,$title='',$checked='',$new=false,$yes='Yes',$no='No',$div=true,$extra='')
- {
- // $checked has been deprecated -- it remains only as a placeholder
- if(Preferences('HIDDEN')!='Y')
- $div = false;
- if($div==false || $new==true)
- {
- if($value && $value!='N')
- $checked = 'CHECKED';
- else
- $checked = '';
- }
- if(AllowEdit() && !$_REQUEST['_CENTRE_PDF'])
- {
- if($new || $div==false)
- return "<INPUT type=checkbox name=$name value=Y $checked $extra>".($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- else
- return "<DIV id='div$name'><div onclick='javascript:addHTML(\"<INPUT type=hidden name=$name value=\\\"\\\"><INPUT type=checkbox name=$name ".(($value)?'checked':'')." value=Y ".str_replace('"','\"',$extra).">".($title!=''?'<BR><small>'.str_replace("'",''',(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'')).'</small>':'')."\",\"div$name\",true)'>".($value?$yes:$no).($title!=''?"<BR><small>".str_replace("'",''',(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':''))."</small>":'')."</div></DIV>";
- }
- else
- return ($value?$yes:$no).($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- }
- function SelectInput($value,$name,$title='',$options,$allow_na='N/A',$extra='',$div=true)
- {
- if(Preferences('HIDDEN')!='Y')
- $div = false;
- // mab - support array style $option values
- // mab - append current val to select list if not in list
- if ($value!='' && !$options[$value])
- $options[$value] = array($value,'<FONT color=red>'.$value.'</FONT>');
- if(AllowEdit() && !$_REQUEST['_CENTRE_PDF'])
- {
- if($value!='' && $div)
- {
- $return = "<DIV id='div$name'><div onclick='javascript:addHTML(\"";
- $extra = str_replace('"','\"',$extra);
- }
- $return .= "<SELECT name=$name $extra>";
- if($allow_na!==false)
- {
- if($value!='' && $div)
- $return .= '<OPTION value=\"\">'.$allow_na;
- else
- $return .= '<OPTION value="">'.$allow_na;
- }
- if(count($options))
- {
- foreach($options as $key=>$val)
- {
- settype($key,'string');
- if($value!='' && $div)
- $return .= "<OPTION value=\\\"".str_replace("'",''',$key)."\\\" ".(($value==$key && (!($value==false && ($value!==$key)) || ($value==='0' && $key===0)))?'SELECTED':'').">".str_replace("'",''',(is_array($val)?$val[0]:$val));
- else
- $return .= "<OPTION value=\"$key\" ".(($value==$key && !($value==false && $value!==$key))?'SELECTED':'').">".(is_array($val)?$val[0]:$val);
- }
- }
- $return .= "</SELECT>";
- if($title!='')
- $return .= '<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'<FONT>':'').'</small>';
- if($value!='' && $div)
- $return .="\",\"div$name\",true)'>".(is_array($options[$value])?$options[$value][1]:$options[$value]).($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'').'</div></DIV>';
- }
- else
- $return = (((is_array($options[$value])?$options[$value][1]:$options[$value])!='')?(is_array($options[$value])?$options[$value][1]:$options[$value]):($allow_na!==false?($allow_na?$allow_na:'-'):'-')).($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- return $return;
- }
- function NoInput($value,$title='')
- {
- return ($value!=''?$value:'-').($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- }
- function TextInputSchool($value,$name,$title='',$options='',$div=true)
- {
- if(Preferences('HIDDEN')!='Y')
- $div = false;
- // mab - support array style $option values
- if(AllowEdit() && !$_REQUEST['_CENTRE_PDF'])
- {
- $value = str_replace("'",''',str_replace('"','”',$value));
- $value1 = is_array($value) ? $value[1] : $value;
- $value = is_array($value) ? $value[0] : $value;
- if(strpos($options,'size')===false && $value!='')
- $options .= ' size='.strlen($value);
- elseif(strpos($options,'size')===false)
- $options .= 'type=\'text\' class=\"cell_wide\"';
- if((trim($value)=='' || $div==false))
- return "<INPUT type=text name=$name ".(($value || $value==='0')?"value=\"$value\"":'')." $options>".($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- else
- return "<DIV id='div$name'><div onclick='javascript:addHTML(\"<INPUT type=text id=input$name name=$name ".(($value || $value==='0')?"value=\\\"".str_replace('"','”',$value)."\\\"":'')." $options>".($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'')."\",\"div$name\",true); document.getElementById(\"input$name\").focus();'>".(($value!='')?str_replace('"','”',$value1):'-').($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').'</small>':'').'</div></DIV>';
- }
- else
- return (((is_array($value)?$value[1]:$value)!='')?(is_array($value)?$value[1]:$value):'-').($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- }
- function ModTextInput($value,$name,$title='',$options='',$div=true)
- {
-
- // mab - support array style $option values
- if(AllowEdit() && !$_REQUEST['_CENTRE_PDF'])
- {
- $value = str_replace("'",''',str_replace('"','”',$value));
- $value1 = is_array($value) ? $value[1] : $value;
- $value = is_array($value) ? $value[0] : $value;
- if(strpos($options,'size')===false && $value!='')
- $options .= ' size='.strlen($value);
- elseif(strpos($options,'size')===false)
- $options .= ' size=10';
- if((trim($value)=='' || $div==false))
- return "<INPUT type=text name=$name ".(($value || $value==='0')?"value=\"$value\"":'')." $options>".($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- else
- return "<INPUT type=text name=$name ".(($value || $value==='0')?"value=\"$value\"":'')." $options>".($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- }
- else
- return (((is_array($value)?$value[1]:$value)!='')?(is_array($value)?$value[1]:$value):'-').($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- }
- function TextInputWrap($value,$name,$title='',$options='',$div=true, $wrap='')
- {
- if(Preferences('HIDDEN')!='Y')
- $div = false;
- // mab - support array style $option values
- if(AllowEdit() && !$_REQUEST['_CENTRE_PDF'])
- {
- $value = str_replace("'",''',str_replace('"','”',$value));
- $value1 = is_array($value) ? $value[1] : $value;
- $value = is_array($value) ? $value[0] : $value;
- if(strpos($options,'size')===false && $value!='')
- $options .= ' size='.strlen($value);
- elseif(strpos($options,'size')===false)
- $options .= ' size=10';
- else
- $options .= ' size=10 class=cell_floating';
-
-
- if((trim($value)=='' || $div==false))
- return "<INPUT type=text name=$name ".(($value || $value==='0')?"value=\"$value\"":'')." $options>".($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- else
- return "<DIV id='div$name' STYLE='word-wrap:break-word; width:".$wrap."px; overflow:auto'><div onclick='javascript:addHTML(\"<INPUT type=text id=input$name name=$name ".(($value || $value==='0')?"value=\\\"".str_replace('"','”',$value)."\\\"":'')." $options>".($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'')."\",\"div$name\",true); document.getElementById(\"input$name\").focus();'>".(($value!='')?str_replace('"','”',$value1):'-').($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').'</small>':'').'</div></DIV>';
- }
- else
- return (((is_array($value)?$value[1]:$value)!='')?(is_array($value)?$value[1]:$value):'-').($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- }
- function TextAreaInputWrap($value,$name,$title='',$options='',$div=true, $wrap='')
- {
- if(Preferences('HIDDEN')!='Y')
- $div = false;
-
-
- if(AllowEdit() && !$_REQUEST['_CENTRE_PDF'])
- {
- $value = str_replace("'",''',str_replace('"','”',$value));
- if(strpos($options,'cols')===false)
- $options .= ' cols=70';
- if(strpos($options,'rows')===false)
- $options .= ' rows=8';
- $rows = substr($options,strpos($options,'rows')+5,2)*1;
- $cols = substr($options,strpos($options,'cols')+5,2)*1;
- if($value=='' || $div==false)
- return "<TEXTAREA name=$name $options >$value</TEXTAREA>".($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- else
- return "<DIV id='div$name' STYLE='word-wrap:break-word; '><div onclick='javascript:addHTML(\"<TEXTAREA id=textarea$name name=$name $options >".ereg_replace("[\n\r]",'\u000D\u000A',str_replace("\r\n",'\u000D\u000A',str_replace("'","'",$value)))."</TEXTAREA>".($title!=''?"<BR><small>".str_replace("'",''',(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':''))."</small>":'')."\",\"div$name\",true); document.getElementById(\"textarea$name\").value=unescape(document.getElementById(\"textarea$name\").value);'><TABLE class=LO_field ><TR><TD>".((substr_count($value,"\r\n")>$rows)?'<DIV style="overflow:auto; height:'.(15*$rows).'px; width:'.($cols*10).'; padding-right: 16px;">'.nl2br($value).'</DIV>':'<DIV style="overflow:auto; width:300; padding-right: 16px;">'.nl2br($value).'</DIV>').'</TD></TR></TABLE>'.($title!=''?'<BR><small>'.str_replace("'",''',(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'')).'</small>':'').'</div></DIV>';
- }
- else
- return (($value!='')?nl2br($value):'-').($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
- }
- ?>