PageRenderTime 50ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/functions/Inputs.php

https://bitbucket.org/Mab879/johtaja-schools
PHP | 453 lines | 391 code | 30 blank | 32 comment | 65 complexity | 3cd935cc32fd15225a6ae42ccee69cf3 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. #**************************************************************************
  3. # openSIS is a free student information system for public and non-public
  4. # schools from Open Solutions for Education, Inc. web: www.os4ed.com
  5. #
  6. # openSIS is web-based, open source, and comes packed with features that
  7. # include student demographic info, scheduling, grade book, attendance,
  8. # report cards, eligibility, transcripts, parent portal,
  9. # student portal and more.
  10. #
  11. # Visit the openSIS web site at http://www.opensis.com to learn more.
  12. # If you have question regarding this system or the license, please send
  13. # an email to info@os4ed.com.
  14. #
  15. # This program is released under the terms of the GNU General Public License as
  16. # published by the Free Software Foundation, version 2 of the License.
  17. # See license.txt.
  18. #
  19. # This program is distributed in the hope that it will be useful,
  20. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. # GNU General Public License for more details.
  23. #
  24. # You should have received a copy of the GNU General Public License
  25. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  26. #
  27. #***************************************************************************************
  28. function DateInput($value,$name,$title='',$div=true,$allow_na=true)
  29. {
  30. if(Preferences('HIDDEN')!='Y')
  31. $div = false;
  32. if(AllowEdit() && !$_REQUEST['_openSIS_PDF'])
  33. {
  34. if($value=='' || $div==false)
  35. 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>':'');
  36. else
  37. 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>';
  38. }
  39. else
  40. return (($value!='')?ProperDate($value):'-').($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
  41. }
  42. function SearchDateInput($day,$month,$year,$allow_day,$allow_month,$allow_year)
  43. {
  44. $dt='';
  45. if($allow_day == 'Y')
  46. {
  47. $dt.='<select name="'.$day.'" id="'.$day.'">';
  48. $dt.='<option value="">Day</option>';
  49. for($i=1; $i<=31; $i++)
  50. {
  51. if($i < 10)
  52. $i='0'.$i;
  53. $dt.='<option value="'.$i.'">'.$i.'</option>';
  54. }
  55. $dt.='</select>';
  56. }
  57. if($allow_month == 'Y')
  58. {
  59. $dt.='<select name="'.$month.'" id="'.$month.'">';
  60. $dt.='<option value="">Month</option><option value="01">January</option><option value="02">February</option><option value="03">March</option><option value="04">April</option><option value="05">May</option><option value="06">June</option><option value="07">July</option><option value="08">August</option><option value="09">September</option><option value="10">October</option><option value="11">November</option><option value="12">December</option>';
  61. $dt.='</select>';
  62. }
  63. if($allow_year == 'Y')
  64. {
  65. $dt.='<select name="'.$year.'" id="'.$year.'">';
  66. $dt.='<option value="">Year</option>';
  67. for($i=1930; $i<=2030; $i++)
  68. {
  69. $dt.='<option value="'.$i.'">'.$i.'</option>';
  70. }
  71. $dt.='</select>';
  72. }
  73. return $dt;
  74. }
  75. function DateInput_for_EndInput($value,$name,$title='',$div=true,$allow_na=true)
  76. {
  77. if(Preferences('HIDDEN')!='Y')
  78. $div = false;
  79. if(AllowEdit() && !$_REQUEST['_openSIS_PDF'])
  80. {
  81. if($value=='' || $div==false)
  82. return PrepareDate_for_EndInput($value,"_$name",$allow_na).($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
  83. else
  84. return "<DIV id='div$name'><div onclick='javascript:addHTML(\"".str_replace('"','\"',PrepareDate_for_EndInput($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>';
  85. }
  86. else
  87. return (($value!='')?ProperDate($value):'-').($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
  88. }
  89. function TextInput($value,$name,$title='',$options='',$div=true)
  90. {
  91. if(Preferences('HIDDEN')!='Y')
  92. $div = false;
  93. // mab - support array style $option values
  94. if(AllowEdit() && !$_REQUEST['_openSIS_PDF'])
  95. {
  96. $value = str_replace("'",'&#39;',str_replace('"','&rdquo;',$value));
  97. $value1 = is_array($value) ? $value[1] : $value;
  98. $value = is_array($value) ? $value[0] : $value;
  99. if(strpos($options,'size')===false && $value!='')
  100. $options .= ' size='.strlen($value);
  101. elseif(strpos($options,'size')===false)
  102. $options .= ' size=10';
  103. if((trim($value)=='' || $div==false))
  104. 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>':'');
  105. else
  106. return "<DIV id='div$name'><div onclick='javascript:addHTML(\"<INPUT type=text id=input$name name=$name ".(($value || $value==='0')?"value=\\\"".str_replace('"','&rdquo;',$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('"','&rdquo;',$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>';
  107. }
  108. else
  109. 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>':'');
  110. }
  111. function TextInput_mod_a($value,$name,$title='',$options='',$div=true)
  112. {
  113. if(Preferences('HIDDEN')!='Y')
  114. $div = false;
  115. // mab - support array style $option values
  116. if(AllowEdit() && !$_REQUEST['_openSIS_PDF'])
  117. {
  118. $value = str_replace("'",'&#39;',str_replace('"','&rdquo;',$value));
  119. $value1 = is_array($value) ? $value[1] : $value;
  120. $value = is_array($value) ? $value[0] : $value;
  121. if(strpos($options,'size')===false && $value!='')
  122. $options .= ' size='.strlen($value);
  123. elseif(strpos($options,'size')===false)
  124. $options .= ' size=10';
  125. if((trim($value)=='' || $div==false))
  126. return "<INPUT type=text name=$name ".(($value || $value==='0')?"value=\"$value\"":'')." id=$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>':'');
  127. else
  128. return "<DIV id='div$name'><div onclick='javascript:addHTML(\"<INPUT type=text id=input$name name=$name ".(($value || $value==='0')?"value=\\\"".str_replace('"','&rdquo;',$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('"','&rdquo;',$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>';
  129. }
  130. else
  131. 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>':'');
  132. }
  133. function TextAreaInput($value,$name,$title='',$options='',$div=true)
  134. {
  135. if(Preferences('HIDDEN')!='Y')
  136. $div = false;
  137. if(AllowEdit() && !$_REQUEST['_openSIS_PDF'])
  138. {
  139. $value = str_replace("'",'&#39;',str_replace('"','&rdquo;',$value));
  140. if(strpos($options,'cols')===false)
  141. $options .= ' cols=30';
  142. if(strpos($options,'rows')===false)
  143. $options .= ' rows=4';
  144. $rows = substr($options,strpos($options,'rows')+5,2)*1;
  145. $cols = substr($options,strpos($options,'cols')+5,2)*1;
  146. if($value=='' || $div==false)
  147. 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>':'');
  148. else
  149. 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("'","&#39;",$value)))."</TEXTAREA>".($title!=''?"<BR><small>".str_replace("'",'&#39;',(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("'",'&#39;',(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'')).'</small>':'').'</div></DIV>';
  150. }
  151. else
  152. return (($value!='')?nl2br($value):'-').($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
  153. }
  154. function CheckboxInput($value,$name,$title='',$checked='',$new=false,$yes='Yes',$no='No',$div=true,$extra='')
  155. {
  156. // $checked has been deprecated -- it remains only as a placeholder
  157. if(Preferences('HIDDEN')!='Y')
  158. $div = false;
  159. if($div==false || $new==true)
  160. {
  161. if($value && $value!='N')
  162. $checked = 'CHECKED';
  163. else
  164. $checked = '';
  165. }
  166. if(AllowEdit() && !$_REQUEST['_openSIS_PDF'])
  167. {
  168. if($new || $div==false)
  169. 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>':'');
  170. else
  171. 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("'",'&#39;',(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("'",'&#39;',(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':''))."</small>":'')."</div></DIV>";
  172. }
  173. else
  174. return ($value?$yes:$no).($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
  175. }
  176. function CheckboxInputWithID($value,$name,$id,$title='',$checked='',$new=false,$yes='Yes',$no='No',$div=true,$extra='')
  177. {
  178. // $checked has been deprecated -- it remains only as a placeholder
  179. if(Preferences('HIDDEN')!='Y')
  180. $div = false;
  181. if($div==false || $new==true)
  182. {
  183. if($value && $value!='N')
  184. $checked = 'CHECKED';
  185. else
  186. $checked = '';
  187. }
  188. if(AllowEdit() && !$_REQUEST['_openSIS_PDF'])
  189. {
  190. if($new || $div==false)
  191. return "<INPUT type=checkbox name=$name id=$id value=Y $checked $extra>".($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
  192. else
  193. 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("'",'&#39;',(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("'",'&#39;',(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':''))."</small>":'')."</div></DIV>";
  194. }
  195. else
  196. return ($value?$yes:$no).($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
  197. }
  198. function SelectInput($value,$name,$title='',$options,$allow_na='N/A',$extra='',$div=true)
  199. {
  200. if(Preferences('HIDDEN')!='Y')
  201. $div = false;
  202. // mab - support array style $option values
  203. // mab - append current val to select list if not in list
  204. if ($value!='' && !$options[$value])
  205. $options[$value] = array($value,'<FONT color=red>'.$value.'</FONT>');
  206. if(AllowEdit() && !$_REQUEST['_openSIS_PDF'])
  207. {
  208. if($value!='' && $div)
  209. {
  210. $return = "<DIV id='div$name'><div onclick='javascript:addHTML(\"";
  211. $extra = str_replace('"','\"',$extra);
  212. }
  213. $return .= "<SELECT name=$name $extra>";
  214. if($allow_na!==false)
  215. {
  216. if($value!='' && $div)
  217. $return .= '<OPTION value=\"\">'.$allow_na;
  218. else
  219. $return .= '<OPTION value="">'.$allow_na;
  220. }
  221. if(count($options))
  222. {
  223. foreach($options as $key=>$val)
  224. {
  225. settype($key,'string');
  226. if($value!='' && $div)
  227. $return .= "<OPTION value=\\\"".str_replace("'",'&#39;',$key)."\\\" ".(($value==$key && (!($value==false && ($value!==$key)) || ($value==='0' && $key===0)))?'SELECTED':'').">".str_replace("'",'&#39;',(is_array($val)?$val[0]:$val));
  228. else
  229. $return .= "<OPTION value=\"$key\" ".(($value==$key && !($value==false && $value!==$key))?'SELECTED':'').">".(is_array($val)?$val[0]:$val);
  230. }
  231. }
  232. $return .= "</SELECT>";
  233. if($title!='')
  234. $return .= '<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'<FONT>':'').'</small>';
  235. if($value!='' && $div)
  236. $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>';
  237. }
  238. else
  239. $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>':'');
  240. return $return;
  241. }
  242. function SelectInput_for_EndInput($value,$name,$title='',$options,$allow_na='N/A',$extra='',$div=true)
  243. {
  244. if(Preferences('HIDDEN')!='Y')
  245. $div = false;
  246. // mab - support array style $option values
  247. // mab - append current val to select list if not in list
  248. if ($value!='' && !$options[$value])
  249. $options[$value] = array($value,'<FONT color=red>'.$value.'</FONT>');
  250. if(AllowEdit() && !$_REQUEST['_openSIS_PDF'])
  251. {
  252. if($value!='' && $div)
  253. {
  254. $return = "<DIV id='div$name'><div onclick='javascript:addHTML(\"";
  255. $extra = str_replace('"','\"',$extra);
  256. }
  257. $return .= "<SELECT name=$name $extra onchange=javascript:if(this.value==\"5\")window.open(\"for_window.php?modname=$_REQUEST[modname]&modfunc=detail&student_id=".UserStudentID()."\",\"blank\",\"width=500,height=300\");>";
  258. if($allow_na!==false)
  259. {
  260. if($value!='' && $div)
  261. $return .= '<OPTION value=\"\">'.$allow_na;
  262. else
  263. $return .= '<OPTION value="">'.$allow_na;
  264. }
  265. if(count($options))
  266. {
  267. foreach($options as $key=>$val)
  268. {
  269. settype($key,'string');
  270. if($value!='' && $div)
  271. $return .= "<OPTION value=\\\"".str_replace("'",'&#39;',$key)."\\\" ".(($value==$key && (!($value==false && ($value!==$key)) || ($value==='0' && $key===0)))?'SELECTED':'').">".str_replace("'",'&#39;',(is_array($val)?$val[0]:$val));
  272. else{
  273. $return .= "<OPTION value=\"$key\" ".(($value==$key && !($value==false && $value!==$key))?'SELECTED':'')." >".(is_array($val)?$val[0]:$val);
  274. }
  275. }
  276. }
  277. $return .= "</SELECT>";
  278. if($title!='')
  279. $return .= '<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'<FONT>':'').'</small>';
  280. if($value!='' && $div)
  281. $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>';
  282. }
  283. else
  284. $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>':'');
  285. return $return;
  286. }
  287. function NoInput($value,$title='')
  288. {
  289. return ($value!=''?$value:'-').($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
  290. }
  291. function TextInputSchool($value,$name,$title='',$options='',$div=true)
  292. {
  293. if(Preferences('HIDDEN')!='Y')
  294. $div = false;
  295. // mab - support array style $option values
  296. if(AllowEdit() && !$_REQUEST['_openSIS_PDF'])
  297. {
  298. $value = str_replace("'",'&#39;',str_replace('"','&rdquo;',$value));
  299. $value1 = is_array($value) ? $value[1] : $value;
  300. $value = is_array($value) ? $value[0] : $value;
  301. if(strpos($options,'size')===false && $value!='')
  302. $options .= ' size='.strlen($value);
  303. elseif(strpos($options,'size')===false)
  304. $options .= 'type=\'text\' class=\"cell_wide\"';
  305. if((trim($value)=='' || $div==false))
  306. 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>':'');
  307. else
  308. return "<DIV id='div$name'><div onclick='javascript:addHTML(\"<INPUT type=text id=input$name name=$name ".(($value || $value==='0')?"value=\\\"".str_replace('"','&rdquo;',$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('"','&rdquo;',$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>';
  309. }
  310. else
  311. 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>':'');
  312. }
  313. function ModTextInput($value,$name,$title='',$options='',$div=true)
  314. {
  315. // mab - support array style $option values
  316. if(AllowEdit() && !$_REQUEST['_openSIS_PDF'])
  317. {
  318. $value = str_replace("'",'&#39;',str_replace('"','&rdquo;',$value));
  319. $value1 = is_array($value) ? $value[1] : $value;
  320. $value = is_array($value) ? $value[0] : $value;
  321. if(strpos($options,'size')===false && $value!='')
  322. $options .= ' size='.strlen($value);
  323. elseif(strpos($options,'size')===false)
  324. $options .= ' size=10';
  325. if((trim($value)=='' || $div==false))
  326. 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>':'');
  327. else
  328. 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>':'');
  329. }
  330. else
  331. 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>':'');
  332. }
  333. function TextInputWrap($value,$name,$title='',$options='',$div=true, $wrap='')
  334. {
  335. if(Preferences('HIDDEN')!='Y')
  336. $div = false;
  337. // mab - support array style $option values
  338. if(AllowEdit() && !$_REQUEST['_openSIS_PDF'])
  339. {
  340. $value = str_replace("'",'&#39;',str_replace('"','&rdquo;',$value));
  341. $value1 = is_array($value) ? $value[1] : $value;
  342. $value = is_array($value) ? $value[0] : $value;
  343. if(strpos($options,'size')===false && $value!='')
  344. $options .= ' size='.strlen($value);
  345. elseif(strpos($options,'size')===false)
  346. $options .= ' size=10';
  347. else
  348. $options .= ' size=10 class=cell_floating';
  349. if((trim($value)=='' || $div==false))
  350. 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>':'');
  351. else
  352. 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('"','&rdquo;',$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('"','&rdquo;',$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>';
  353. }
  354. else
  355. 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>':'');
  356. }
  357. function TextAreaInputWrap($value,$name,$title='',$options='',$div=true, $wrap='')
  358. {
  359. if(Preferences('HIDDEN')!='Y')
  360. $div = false;
  361. if(AllowEdit() && !$_REQUEST['_openSIS_PDF'])
  362. {
  363. $value = str_replace("'",'&#39;',str_replace('"','&rdquo;',$value));
  364. if(strpos($options,'cols')===false)
  365. $options .= ' cols=70';
  366. if(strpos($options,'rows')===false)
  367. $options .= ' rows=8';
  368. $rows = substr($options,strpos($options,'rows')+5,2)*1;
  369. $cols = substr($options,strpos($options,'cols')+5,2)*1;
  370. if($value=='' || $div==false)
  371. 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>':'');
  372. else
  373. 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("'","&#39;",$value)))."</TEXTAREA>".($title!=''?"<BR><small>".str_replace("'",'&#39;',(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("'",'&#39;',(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'')).'</small>':'').'</div></DIV>';
  374. }
  375. else
  376. return (($value!='')?nl2br($value):'-').($title!=''?'<BR><small>'.(strpos(strtolower($title),'<font ')===false?'<FONT color='.Preferences('TITLES').'>':'').$title.(strpos(strtolower($title),'<font ')===false?'</FONT>':'').'</small>':'');
  377. }
  378. ?>