PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/includes/config.inc.php

https://github.com/reshadf/Library
PHP | 411 lines | 224 code | 51 blank | 136 comment | 6 complexity | c72a4a364e11fb29f995bc21c0fe7d88 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /**
  3. * config.inc.php
  4. *
  5. *
  6. * The file contains the configuration options used by the FormHandler.
  7. * You can change the values below. It's also possible to define your own
  8. * values before you create a new FormHandler object:
  9. *
  10. * define('FH_TIMEFIELD_SET_CUR_TIME', false);
  11. *
  12. * $form = new FormHandler();
  13. *
  14. * ....
  15. *
  16. * At this way you dont have to change the config.inc.php to change a
  17. * specific configuration value once.
  18. *
  19. * @author Teye Heimans
  20. * @package FormHandler
  21. */
  22. // Get the location where formhandler is located
  23. if( !empty($_SERVER['DOCUMENT_ROOT']) )
  24. {
  25. $__fh_root = str_replace( $_SERVER['DOCUMENT_ROOT'], '', str_replace('\\', '/', realpath( dirname(__FILE__).'/../' ))).'/';
  26. }
  27. // could not fetch the location of the FH3 directory!
  28. else
  29. {
  30. // Please set here the location to the FH3 directory
  31. // like: /engineering/FH3/
  32. $__fh_root = '';
  33. if( empty( $__fh_root ) )
  34. {
  35. trigger_error(
  36. "Please set the location to the FH3 directory in the config file!!",
  37. E_USER_WARNING
  38. );
  39. }
  40. }
  41. // The default name of the form
  42. // when no name is given in the constructor
  43. fh_conf('FH_DEFAULT_FORM_NAME', 'FormHandler');
  44. // The default mask used to parse the fields
  45. // The mask can be changed with the function setMask()
  46. fh_conf('FH_DEFAULT_ROW_MASK'," <tr>\n".
  47. " <td valign='top' align='right'>%title%</td>\n".
  48. " <td valign='top'>%seperator%</td>\n".
  49. " <td valign='top'>%field% %help% <span id='%error_id%' class='error'>%error%</span></td>\n".
  50. " </tr>\n"
  51. );
  52. // When addLine() is used, this line is used to set the data in
  53. // (%s is going to be replaced with the value!)
  54. fh_conf('FH_LINE_MASK',
  55. " <tr><td>&nbsp;</td><td>&nbsp;</td><td>%s</td></tr>\n"
  56. );
  57. // Default for use table, can be overwritten by useTable
  58. //since 08-10-2009 JW
  59. fh_conf( 'FH_USE_TABLE', true );
  60. // Default for Set focus, can be overwritten by setFocus
  61. //since 14-01-2010 JW
  62. fh_conf( 'FH_SET_FOCUS', true );
  63. // When borderStart() and borderEnd() are used, this fieldset is inserted
  64. fh_conf('FH_FIELDSET_MASK',
  65. " <tr>\n".
  66. " <td valign='top' colspan='3'>\n".
  67. " <br />\n".
  68. " <fieldset id='%name%' %extra%>\n".
  69. " <legend>%caption%</legend>\n".
  70. " <!-- content of fieldset %name% -->\n".
  71. " <table cellspacing='0' cellpadding='3' id='%name%'>\n".
  72. " %content%\n".
  73. " </table>\n".
  74. " <!-- end of fieldset %name% -->\n".
  75. " </fieldset>\n".
  76. " </td>\n".
  77. " </tr>\n"
  78. );
  79. // The error mask used to surround the error messages
  80. fh_conf('FH_ERROR_MASK',
  81. '<span id="error_%s" class="error">%s</span>'
  82. );
  83. // The mask used for the horizontal listfield
  84. fh_conf('FH_LISTFIELD_HORIZONTAL_MASK',
  85. " <table border='0' cellspacing='0' cellpadding='0'>\n".
  86. " <tr>\n".
  87. " <td align='center'><strong>%onlabel%</strong></td>\n".
  88. " <td align='center'></td>\n".
  89. " <td align='center'><strong>%offlabel%</strong></td>\n".
  90. " </tr>\n".
  91. " <tr>\n".
  92. " <td rowspan='2' align='right'>\n".
  93. " %onfield%\n".
  94. " </td>\n".
  95. " <td width='30' align='center' valign='bottom'>\n".
  96. " <input type='button' value=' &gt; ' onclick=\"changeValue('%name%', false)\" ondblclick=\"moveAll('%name%', false)\" title='%ontitle%' />\n".
  97. " </td>\n".
  98. " <td rowspan='2'>\n".
  99. " %offfield%\n".
  100. " </td>\n".
  101. " </tr>\n".
  102. " <tr>\n".
  103. " <td align='center' valign='top'>\n".
  104. " <input type='button' value=' &lt; ' onclick=\"changeValue('%name%', true)\" ondblclick=\"moveAll('%name%', true)\" title='%offtitle%' />\n".
  105. " </td>\n".
  106. " </tr>\n".
  107. " </table>"
  108. );
  109. // The mask used for the vertical listfield
  110. fh_conf('FH_LISTFIELD_VERTICAL_MASK',
  111. " <table border='0' cellspacing='0' cellpadding='0'>\n".
  112. " <tr>\n".
  113. " <td align='right' valign='middle'><strong>%offlabel%</strong></td>\n".
  114. " <td valign='top' align='left'>\n".
  115. " %offfield%\n".
  116. " </td>\n".
  117. " </tr>\n".
  118. " <tr>\n".
  119. " <td colspan='2' height='30' align='center' valign='middle'>\n".
  120. " <input type='button' value=' &darr; ' onclick=\"changeValue('%name%', true)\" ondblclick=\"moveAll('%name%', true)\" title='%offtitle%' />&nbsp;\n".
  121. " &nbsp;<input type='button' value=' &uarr; ' onclick=\"changeValue('%name%', false)\" ondblclick=\"moveAll('%name%', false)\" title='%ontitle%' />\n".
  122. " </td>\n".
  123. " </tr>\n".
  124. " <tr>\n".
  125. " <td align='right' valign='middle'><strong>%onlabel%</strong></td>\n".
  126. " <td valign='top' align='left'>\n".
  127. " %onfield%\n".
  128. " </td>\n".
  129. " </tr>\n".
  130. " </table>"
  131. );
  132. // Should Overlib javascript be included for help messages?
  133. fh_conf('FH_USE_OVERLIB', true);
  134. // The help mask used to surround the help messages
  135. fh_conf('FH_HELP_MASK',
  136. '<img src="%helpicon%" border="0" onmouseover="return overlib(\'%helptext%\', DELAY, \'400\', FGCOLOR, \'#CCCCCC\', BGCOLOR, \'#666666\', TEXTCOLOR, \'#666666\', TEXTFONT, \'Verdana\', TEXTSIZE, \'12px\', CELLPAD, 8, BORDER, 1, CAPTION, \'&nbsp;%helptitle%\', CAPTIONSIZE, \'12px\');" onmouseout="return nd();" style="color:333333;cursor:help;" />'
  137. );
  138. // Default table width. When "false", no width will be set
  139. fh_conf('FH_DEFAULT_TABLE_WIDTH', false);
  140. // The default border size of the table where the form will be located in
  141. fh_conf('FH_DEFAULT_TABLE_BORDER', 0);
  142. // The default cellspacing of the table where the form will be located in
  143. fh_conf('FH_DEFAULT_TABLE_CELLSPACING', 0);
  144. // The default cellpadding of the table where the form will be located in
  145. fh_conf('FH_DEFAULT_TABLE_CELLPADDING', 3);
  146. // The default number of caracters used in the captcha
  147. fh_conf( 'FH_CAPTCHA_LENGTH',6 );
  148. // The width of a captcha image
  149. fh_conf( 'FH_CAPTCHA_WIDTH',200 );
  150. // Does formhandler has to detect the language atomatically?
  151. fh_conf('FH_AUTO_DETECT_LANGUAGE', true);
  152. // If no correct language could be found or auto detect language is disabled,
  153. // what should be the default language ?
  154. fh_conf('FH_DEFAULT_LANGUAGE', 'en');
  155. // When an unknown record is tried to edit, should FormHandler insert
  156. // the record instead ?
  157. fh_conf('FH_AUTO_INSERT', false);
  158. // The URL to web root where the FHTML dir is located (So not the path!). The URL can also be relative to the web root.
  159. // Example: fh_conf('FH_FHTML_DIR', 'http://www.mysite.com/dir/to/FHTML/');
  160. // Or: fh_conf('FH_FHTML_DIR', '/dir/to/FHTML/');
  161. // here we try to get the dir automatically
  162. fh_conf('FH_FHTML_DIR', $__fh_root . 'FHTML/' );
  163. // This config var has to point to the FCKeditor directory.
  164. // Default this dir is located in the FH3 directory. If you put it
  165. // somewhere else you have to change this config var.
  166. // added 21-11-2008 By Johan Wiegel in order to make it posible to place FH3 outside webroot and FHMTL directory inside webroot
  167. fh_conf('FH_FHTML_INCLUDE_DIR', FH_INCLUDE_DIR . 'FHTML/');
  168. // mask for a TextSelectField
  169. fh_conf( 'FH_TEXTSELECT_MASK',
  170. '<input type="text" name="%s" id="%1$s" value="%s" size="%d" %s onblur="FH_CLOSE_TEXTSELECT(\'FHSpan_%1$s\');" onkeyup="FH_CLOSE_TEXTSELECT(\'FHSpan_%1$s\');" onclick="document.getElementById(\'FHSpan_%1$s\').style.display=\'block\';" style="background: #FFF url('.$__fh_root . 'FHTML/images/arrow_down.gif) no-repeat right;" />%s<br /><div style="position:absolute;height:70px;overflow-y:scroll; width:150px; display:none; background-color:#FFF;" id="FHSpan_%1$s">%s</div>'."\n"
  171. );
  172. // mask for the TextSelectField options
  173. fh_conf( 'FH_TEXTSELECT_OPTION_MASK',
  174. '<a style="display:block;padding-left:5px;margin:0px;width:auto;color:black;text-decoration:none;" href="#" onmouseover="this.style.background=\'#C0C0C0\';" onmouseout="this.style.background=\'#FFFFFF\';" onblur="FH_CLOSE_TEXTSELECT(\'FHSpan_%s\')" onfocus="FH_SET_TEXTSELECT( \'%1$s\', this.innerHTML );" onclick="FH_SET_TEXTSELECT( \'%1$s\',this.innerHTML );" >%s</a>'."\n"
  175. );
  176. // This config var has to point to the YADAL directory.
  177. // Yadal is the database abstraction class which FormHandler uses
  178. // to interact with the databases.
  179. // Default this dir is located in the FH3 directory. If you put it
  180. // somewhere else you have to change this config var.
  181. fh_conf('FH_YADAL_DIR', FH_INCLUDE_DIR . 'yadal/');
  182. // The default database type which is used when no one is given.
  183. fh_conf('FH_DEFAULT_DB_TYPE', 'mysql');
  184. // The default host which is used when no one is given
  185. fh_conf('FH_DEFAULT_DB_HOST', 'localhost');
  186. // The id which we are watching in the URL of the form is an edit form.
  187. // like: index.php?id=1
  188. // ^
  189. // |
  190. // or when multiple primary key's are used:
  191. // like: index.php?id[]=1&id[]=en
  192. // ^ ^
  193. // | |
  194. fh_conf('FH_EDIT_NAME', 'id');
  195. // In the fields CheckBox, SelectBox and RadioButton it is possible
  196. // to give a array as value. The index (key) of this array can be used
  197. // as value for the field.
  198. // This can be changed in the call of the function:
  199. // $form->CheckBox('title', 'name', array(...), true);
  200. // ^
  201. // You can change the default value of this option...
  202. // Should by default the array key be used as value ??
  203. fh_conf('FH_DEFAULT_USEARRAYKEY', true);
  204. // The default upload config. It contains this config values:
  205. // - where to upload the file,
  206. // - what kind of files are allowed,
  207. // - what the maximum allowed size is of the uploaded file,
  208. // - then new name of the uploaded file,
  209. // - if the field is required (so that visitors must upload a file),
  210. // - what to do if the uploaded file already exists.
  211. // - the allowed dimensions of the uploaded image
  212. fh_conf('FH_DEFAULT_UPLOAD_CONFIG',
  213. serialize(array (
  214. 'path' => realpath( '.' ).'/uploads', // <-- dir where the requested script is located
  215. 'type' => 'jpg jpeg png gif doc txt bmp tif tiff pdf',
  216. 'mime' => '', // <-- use the mime types which are known by FH for these extensions
  217. 'size' => '', // <-- max upload size
  218. 'name' => '', // <-- keep the original name
  219. 'width' => '', // <-- all widths are permitted! (only used for images)
  220. 'height' => '', // <-- all heights are permitted! (only used for images)
  221. 'required' => false,
  222. 'exists' => 'alert' // possible values: alert, overwrite, rename
  223. ))
  224. );
  225. // Do we have to check the upload file with JS?
  226. // (recomended!)
  227. fh_conf('FH_UPLOAD_JS_CHECK', true);
  228. // The default resize width of the thumbnail
  229. // created by the function resizeImage()
  230. fh_conf('FH_DEFAULT_RESIZE_WIDTH', 180);
  231. // The quality of the thumbnail created by the function resizeImage()
  232. fh_conf('FH_DEFAULT_RESIZE_QUALITY', 80);
  233. // The minimum password length used by the checkPassword() function
  234. fh_conf('FH_MIN_PASSWORD_LENGTH', 5);
  235. // The default hour format used for the time field
  236. fh_conf('FH_TIMEFIELD_DEFAULT_HOUR_FORMAT', 24);
  237. // The steps between the minutes in the timeField
  238. // - Set to 1 for these minutes options: 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, etc...
  239. // - Set to 5 for these minutes options: 00, 05, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55
  240. // - Set to 10 for these minutes options: 00, 10, 20, 30, 40, 50
  241. // - Set to 15 for these minutes options: 00, 15, 30, 45
  242. // etc...
  243. fh_conf('FH_TIMEFIELD_MINUTE_STEPS', 10);
  244. // When the timeField's value is empty (eg. not posted and insert mode),
  245. // should we display the current time ?
  246. fh_conf('FH_TIMEFIELD_SET_CUR_TIME', true);
  247. // The default option if the timeField is required or not
  248. // (Overwrites the current time option! It makes the fields empty)
  249. fh_conf('FH_TIMEFIELD_DEFAULT_REQUIRED', true);
  250. // The default display of the date fields useage:
  251. // d = selectfield day
  252. // m = selectfield month
  253. // y = selectfield year
  254. // D = textfield day
  255. // M = textfield month
  256. // Y = textfield year
  257. fh_conf('FH_DATEFIELD_DEFAULT_DISPLAY', 'd-m-y');
  258. // When the dateField's value is empty (eg. not posted and insert mode),
  259. // should we display the current date ?
  260. fh_conf('FH_DATEFIELD_SET_CUR_DATE', true);
  261. // The default date interval (the years which are displayed)
  262. // which are displayed in the year section of the dateField
  263. fh_conf('FH_DATEFIELD_DEFAULT_DATE_INTERVAL', '90:0');
  264. // The default option if the dateField is required or not
  265. fh_conf('FH_DATEFIELD_DEFAULT_REQUIRED', true);
  266. // The default display of the date fields useage:
  267. // d = day (2 digits with leading zeros)
  268. // D = day
  269. // m = month (2 digits with leading zeros)
  270. // M = month
  271. // y = year (two digits)
  272. // Y = year (four digits)
  273. fh_conf('FH_DATETEXTFIELD_DEFAULT_DISPLAY', 'd-m-Y');
  274. // Use dropdown in jsCalendarPopup
  275. fh_conf('FH_JSCALENDARPOPUP_USE_DROPDOWN', false);
  276. // start day in jsCalendarPopup
  277. // 0 = sunday ... 6 = saturday
  278. fh_conf('FH_JSCALENDARPOPUP_STARTDAY', 1);
  279. // The default size of the listfield field's
  280. fh_conf('FH_DEFAULT_LISTFIELD_SIZE', 4);
  281. // The default glue which should be used to merge multiple
  282. // checkboxes or radiobuttons
  283. fh_conf('FH_DEFAULT_GLUE_MASK', "%field%<br />\n");
  284. // The chmod which is used when a dir is created
  285. fh_conf('FH_DEFAULT_CHMOD', 0777);
  286. // Display errors of FormHandler (PHP errors, NOT field validation errors!)
  287. fh_conf('FH_DISPLAY_ERRORS', true);
  288. // If this variabele is set to true, FH will
  289. // expose itsself by adding a extra line on the bottom of the form
  290. fh_conf('FH_EXPOSE', false);
  291. // Disable the submit button after submitting the form ?
  292. fh_conf('FH_DEFAULT_DISABLE_SUBMIT_BTN', true);
  293. // use / for valid XHTML, '' for valid HTML
  294. fh_conf('FH_XHTML_CLOSE', '/');
  295. /***********************************/
  296. /*** Don't change anything below ***/
  297. /***********************************/
  298. /**
  299. * Document::fh_conf()
  300. *
  301. * Set the configuration defines if they are
  302. * not defined by the user yet.
  303. *
  304. */
  305. function fh_conf()
  306. {
  307. static $define = array();
  308. // is a value set?
  309. if (func_num_args()==2)
  310. {
  311. $define[func_get_arg(0)] = func_get_arg(1);
  312. }
  313. // no value is set, we have to define the values!
  314. else
  315. {
  316. // walk all values and define them if they dont exists yet
  317. foreach ($define as $name => $value)
  318. {
  319. if(!defined($name))
  320. {
  321. define($name, $value);
  322. }
  323. }
  324. unset( $define );
  325. }
  326. }
  327. // make sure that array_key_exists exists! :D
  328. if( !function_exists('array_key_exists') )
  329. {
  330. function array_key_exists($sKey, $aArray)
  331. {
  332. return in_array($sKey, array_keys($aArray));
  333. }
  334. }
  335. // For PHP version < 4.2.0 missing the array_fill function..
  336. if(!function_exists('array_fill'))
  337. {
  338. function array_fill($iStart, $iLen, $vValue)
  339. {
  340. $aResult = array();
  341. for ($iCount = $iStart; $iCount < $iLen + $iStart; $iCount++)
  342. {
  343. $aResult[$iCount] = $vValue;
  344. }
  345. return $aResult;
  346. }
  347. }
  348. ?>