BxBaseFormView.php 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup TridentCore Trident Core
  7. * @{
  8. */
  9. class BxBaseFormView extends BxDolForm
  10. {
  11. protected static $_isToggleJsAdded = false;
  12. protected static $_isCssJsAdded = false;
  13. protected static $_isCssJsAddedViewMode = false;
  14. /**
  15. * Enable or disable error message displaying
  16. */
  17. protected $bEnableErrorIcon = true;
  18. /**
  19. * HTML Code of this form
  20. */
  21. protected $sCode;
  22. /**
  23. * Code which will be added to the beginning of the form.
  24. * For example, hidden inputs.
  25. * For internal use only
  26. */
  27. protected $_sCodeAdd = '';
  28. /**
  29. * for internal use only
  30. */
  31. protected $_isSectionOpened = false;
  32. /**
  33. * Default divider for several inputs
  34. */
  35. protected $_sDivider = '<span class="bx-def-margin-left"></span>';
  36. /**
  37. * Alternative divider for several inputs
  38. */
  39. protected $_sDividerAlt = '<br />';
  40. /**
  41. * Form is added dynamically.
  42. */
  43. protected $_bDynamicMode = false;
  44. /**
  45. * Function name for generation close form section HTML.
  46. */
  47. protected $_sSectionClose = 'getCloseSection';
  48. /**
  49. * Function name for generation open form section HTML.
  50. */
  51. protected $_sSectionOpen = 'getOpenSection';
  52. /**
  53. * Constructor
  54. *
  55. * @param array $aInfo Form contents
  56. *
  57. * $aInfo['params'] = array(
  58. * 'remove_form' => true|false,
  59. * );
  60. *
  61. * @return BxBaseFormView
  62. */
  63. function __construct($aInfo, $oTemplate)
  64. {
  65. parent::__construct($aInfo, $oTemplate);
  66. if (isset($this->aParams['view_mode']) && $this->aParams['view_mode']) {
  67. $this->_sSectionClose = 'getCloseSectionViewMode';
  68. $this->_sSectionOpen = 'getOpenSectionViewMode';
  69. }
  70. }
  71. /**
  72. * Return Form code
  73. * @param $bDynamicMode - set it to true if form is added via JS/AJAX call, for example form in AJAX popup.
  74. * @return string
  75. */
  76. function getCode($bDynamicMode = false)
  77. {
  78. $this->_bDynamicMode = $bDynamicMode;
  79. $this->addCssJs ();
  80. $this->aFormAttrs = $this->_replaceMarkers($this->aFormAttrs);
  81. return ($this->sCode = $this->genForm());
  82. }
  83. /**
  84. * Generate the whole form
  85. *
  86. * @return string
  87. */
  88. function genForm()
  89. {
  90. $this->_sCodeAdd = '';
  91. $sTable = $this->genRows();
  92. $sHtmlBefore = isset($this->aParams['html_before']) ? $this->aParams['html_before'] : '';
  93. $sHtmlAfter = isset($this->aParams['html_after']) ? $this->aParams['html_after'] : '';
  94. if (!empty($this->aParams['remove_form']) || (isset($this->aParams['view_mode']) && $this->aParams['view_mode'])) {
  95. $sForm = <<<BLAH
  96. $sHtmlBefore
  97. {$this->_sCodeAdd}
  98. <div class="bx-form-advanced-wrapper {$this->id}_wrapper">
  99. $sTable
  100. </div>
  101. $sHtmlAfter
  102. BLAH;
  103. } else {
  104. $sFormAttrs = bx_convert_array2attrs($this->aFormAttrs, 'bx-form-advanced');
  105. $sForm = <<<BLAH
  106. $sHtmlBefore
  107. <form $sFormAttrs>
  108. {$this->_sCodeAdd}
  109. <div class="bx-form-advanced-wrapper {$this->id}_wrapper">
  110. $sTable
  111. </div>
  112. </form>
  113. <script>
  114. $(document).ready(function() {
  115. $(this).addWebForms();
  116. });
  117. </script>
  118. $sHtmlAfter
  119. BLAH;
  120. }
  121. return $sForm;
  122. }
  123. /**
  124. * Generate Table HTML code
  125. *
  126. * @return string
  127. */
  128. function genRows()
  129. {
  130. // add CSRF token if it's needed.
  131. if (!(isset($this->aParams['view_mode']) && $this->aParams['view_mode']) && getParam('sys_security_form_token_enable') == 'on' && (!isset($this->aParams['csrf']['disable']) || (isset($this->aParams['csrf']['disable']) && $this->aParams['csrf']['disable'] !== true)) && ($mixedCsrfToken = BxDolForm::getCsrfToken()) !== false) {
  132. $this->aInputs['csrf_token'] = array(
  133. 'type' => 'hidden',
  134. 'name' => 'csrf_token',
  135. 'value' => $mixedCsrfToken,
  136. 'db' => array ('pass' => 'Xss'),
  137. 'visible_for_levels' => PHP_INT_MAX,
  138. );
  139. }
  140. // check if we need to generate open section clause
  141. $sOpenSection = '';
  142. foreach ($this->aInputs as $aInput) {
  143. if (isset($aInput['type']) && 'hidden' == $aInput['type'])
  144. continue;
  145. if (isset($aInput['type']) && 'block_header' != $aInput['type'])
  146. $sOpenSection = $this->{$this->_sSectionOpen}();
  147. break;
  148. }
  149. // generate rows contents
  150. $sCont = '';
  151. $sFuncGenRow = isset($this->aParams['view_mode']) && $this->aParams['view_mode'] ? 'genViewRow' : 'genRow';
  152. foreach ($this->aInputs as $aInput)
  153. if (!isset($aInput['visible_for_levels']) || self::isVisible($aInput))
  154. $sCont .= $this->$sFuncGenRow($aInput);
  155. $sCloseSection = $this->{$this->_sSectionClose}();
  156. return $sOpenSection . $sCont . $sCloseSection;
  157. }
  158. /**
  159. * Generate single Table Row
  160. *
  161. * @param array $aInput
  162. * @return string
  163. */
  164. function genRow(&$aInput)
  165. {
  166. if (!isset($aInput['type']))
  167. $aInput['type'] = false;
  168. if (!empty($aInput['name'])) {
  169. $sCustomMethod = 'genCustomRow' . $this->_genMethodName($aInput['name']);
  170. if (method_exists($this, $sCustomMethod))
  171. return $this->$sCustomMethod($aInput);
  172. }
  173. switch ($aInput['type']) {
  174. case 'block_header':
  175. $sRow = $this->genRowBlockHeader($aInput);
  176. break;
  177. case 'block_end':
  178. $sRow = $this->genBlockEnd($aInput);
  179. break;
  180. case 'hidden':
  181. // do not generate row for hidden inputs
  182. $sRow = '';
  183. $this->_sCodeAdd .= $this->genInput($aInput);
  184. break;
  185. case 'select_box':
  186. $sRow = $this->genRowCustom($aInput, 'genInputSelectBox');
  187. break;
  188. case 'files':
  189. $sRow = $this->genRowCustom($aInput, 'genInputFiles');
  190. break;
  191. case 'switcher':
  192. case 'checkbox':
  193. $sRow = $this->genRowStandard($aInput, true);
  194. break;
  195. default:
  196. $sRow = $this->genRowStandard($aInput);
  197. }
  198. return $sRow;
  199. }
  200. /**
  201. * Generate single Table Row for view mode
  202. *
  203. * @param array $aInput
  204. * @return string
  205. */
  206. function genViewRow(&$aInput)
  207. {
  208. if (!isset($aInput['type']))
  209. $aInput['type'] = false;
  210. if (!empty($aInput['name'])) {
  211. $sCustomMethod = 'genCustomRow' . $this->_genMethodName($aInput['name']);
  212. if (method_exists($this, $sCustomMethod))
  213. return $this->$sCustomMethod($aInput);
  214. }
  215. switch ($aInput['type']) {
  216. case 'block_header':
  217. $sRow = $this->genRowBlockHeader($aInput);
  218. break;
  219. case 'block_end':
  220. $sRow = $this->genBlockEnd($aInput);
  221. break;
  222. default:
  223. $sRow = $this->genViewRowWrapped($aInput);
  224. }
  225. return $sRow;
  226. }
  227. /**
  228. * Generate complete wrapped row for view mode form
  229. *
  230. * @param array $aInput
  231. * @return string
  232. */
  233. function genViewRowWrapped(&$aInput)
  234. {
  235. $sValue = $this->genViewRowValue($aInput);
  236. if (null === $sValue)
  237. return '';
  238. $sCaption = isset($aInput['caption']) ? bx_process_output($aInput['caption']) : '';
  239. return <<<EOS
  240. <div class="bx-form-row-view-wrapper bx-form-row-view-wrapper-{$aInput['type']} bx-def-padding-sec-top">
  241. <div class="bx-form-row-view-caption bx-def-margin-sec-right">{$sCaption}:</div>
  242. <div class="bx-form-row-view-value">{$sValue}</div>
  243. </div>
  244. EOS;
  245. }
  246. /**
  247. * Generate value for view mode row
  248. *
  249. * @param array $aInput
  250. * @return string
  251. */
  252. function genViewRowValue(&$aInput)
  253. {
  254. switch ($aInput['type']) {
  255. case 'hidden':
  256. $sValue = null;
  257. break;
  258. case 'select':
  259. case 'radio_set':
  260. $sValue = $this->genViewRowValueForSelect($aInput);
  261. break;
  262. case 'datepicker':
  263. $iTime = bx_process_input ($aInput['value'], BX_DATA_DATE_TS, false, false);
  264. $sValue = bx_time_js ($iTime, BX_FORMAT_DATE);
  265. break;
  266. case 'date_time':
  267. case 'datetime':
  268. $iTime = bx_process_input ($aInput['value'], BX_DATA_DATETIME_TS, false, false);
  269. $sValue = bx_time_js ($iTime, BX_FORMAT_DATE_TIME);
  270. break;
  271. case 'checkbox_set':
  272. case 'select_multiple':
  273. $sValue = null;
  274. if (!empty($aInput['value']) && is_array($aInput['value'])) {
  275. $sValue = '';
  276. foreach ($aInput['value'] as $sVal)
  277. $sValue .= $aInput['values'][$sVal] . ', ';
  278. $sValue = trim ($sValue, ', ');
  279. }
  280. break;
  281. case 'checkbox':
  282. case 'switcher':
  283. $sValue = isset($aInput['checked']) && $aInput['checked'] ? _t('_sys_form_checkbox_value_on') : _t('_sys_form_checkbox_value_off');
  284. break;
  285. case 'textarea':
  286. if (isset($aInput['value']) && '' !== $aInput['value'])
  287. $sValue = isset($aInput['html']) && $aInput['html'] ? $aInput['value'] : nl2br(bx_process_output($aInput['value']));
  288. else
  289. $sValue = null;
  290. break;
  291. default:
  292. $sValue = isset($aInput['value']) && '' !== $aInput['value'] ? bx_process_output($aInput['value']) : null;
  293. }
  294. return $sValue;
  295. }
  296. function genViewRowValueForSelect(&$aInput)
  297. {
  298. $s = isset($aInput['value']) && isset($aInput['values'][$aInput['value']]) ? $aInput['values'][$aInput['value']] : null;
  299. if (isset($aInput['values_list_name']) && ($oCategory = BxDolCategory::getObjectInstanceByFormAndList($this->aFormAttrs['name'], $aInput['values_list_name'])))
  300. return $oCategory->getCategoryLink($s, $aInput['value']);
  301. return $s;
  302. }
  303. /**
  304. * Generate standard row
  305. *
  306. * @param array $aInput
  307. * @return string
  308. */
  309. function genRowStandard(&$aInput, $isOneLine = false)
  310. {
  311. $sCaption = isset($aInput['caption']) ? bx_process_output($aInput['caption']) : '';
  312. $sRequired = !empty($aInput['required']) ? '<span class="bx-form-required">*</span> ' : '';
  313. $sClassAdd = !empty($aInput['error']) ? ' bx-form-error' : '';
  314. $sInfoIcon = !empty($aInput['info']) ? $this->genInfoIcon($aInput['info']) : '';
  315. $sErrorIcon = $this->genErrorIcon(empty($aInput['error']) ? '' : $aInput['error']);
  316. if (isset($aInput['name']))
  317. $aInput['tr_attrs']['id'] = "bx-form-element-" . $aInput['name'];
  318. $sTrAttrs = bx_convert_array2attrs(isset($aInput['tr_attrs']) && is_array($aInput['tr_attrs']) ? $aInput['tr_attrs'] : array(), "bx-form-element-wrapper bx-def-margin-top");
  319. $sClassOneLineCaption = '';
  320. $sClassOneLineValue = '';
  321. if ($isOneLine) {
  322. $sClassOneLineCaption = ' bx-form-caption-oneline bx-form-caption-oneline-' . $aInput['type'] . ' bx-def-margin-sec-left';
  323. $sClassOneLineValue = ' bx-form-value-oneline bx-form-value-oneline-' . $aInput['type'];
  324. $aInput['attrs']['id'] = $this->getInputId($aInput);
  325. if ($sCaption)
  326. $sCaption = '<label for="' . $aInput['attrs']['id'] . '">' . $sCaption . '</label>';
  327. }
  328. $sInput = $this->genInput($aInput);
  329. $sCaptionCode = '';
  330. if ($sCaption)
  331. $sCaptionCode = '<div class="bx-form-caption' . $sClassOneLineCaption . '">' . $sCaption . $sRequired . '</div>';
  332. else
  333. $sInput .= $sRequired;
  334. $sInputCode = $this->genWrapperInput($aInput, $sInput);
  335. if (empty($sInputCodeExtra)) $sInputCodeExtra = '';
  336. if (empty($sInfoIcon)) $sInfoIcon = '';
  337. if (empty($sInputCode)) $sInputCode = '';
  338. if (empty($sErrorIcon)) $sErrorIcon = '';
  339. $sValueCode = '
  340. <div class="bx-form-value bx-clearfix' . $sClassAdd . $sClassOneLineValue . '">
  341. ' . $sInputCode . '
  342. ' . ($isOneLine ? '' : $sInfoIcon . $sErrorIcon) . '
  343. ' . $sInputCodeExtra . '
  344. </div>';
  345. if ($isOneLine)
  346. $sCode = $sValueCode . $sCaptionCode . '<div class="bx-clear"></div>' . $sInfoIcon . $sErrorIcon;
  347. else
  348. $sCode = $sCaptionCode . $sValueCode;
  349. return "<div $sTrAttrs>" . $sCode . "</div>";
  350. }
  351. function genWrapperInput($aInput, $sContent)
  352. {
  353. $sAttr = isset($aInput['attrs_wrapper']) && is_array($aInput['attrs_wrapper']) ? bx_convert_array2attrs($aInput['attrs_wrapper']) : '';
  354. return "<div class=\"bx-form-input-wrapper bx-form-input-wrapper-{$aInput['type']}\" $sAttr>$sContent</div>";
  355. }
  356. /**
  357. * Generate custom row
  358. *
  359. * @param array $aInput
  360. * @param string $sCustomMethod custom method to generate code for input
  361. * @return string
  362. */
  363. function genRowCustom(&$aInput, $sCustomMethod)
  364. {
  365. $sCaption = isset($aInput['caption']) ? bx_process_output($aInput['caption']) : '';
  366. $sRequired = !empty($aInput['required']) ? '<span class="bx-form-required">*</span> ' : '';
  367. $sClassAdd = !empty($aInput['error']) ? ' bx-form-error' : '';
  368. $sInfoIcon = !empty($aInput['info']) ? $this->genInfoIcon($aInput['info']) : '';
  369. $sErrorIcon = $this->genErrorIcon(empty($aInput['error']) ? '' : $aInput['error']);
  370. $sInput = $this->$sCustomMethod($aInput, $sInfoIcon, $sErrorIcon);
  371. if (isset($aInput['name']))
  372. $aInput['tr_attrs']['id'] = "bx-form-element-" . $aInput['name'];
  373. $sTrAttrs = bx_convert_array2attrs(empty($aInput['tr_attrs']) ? array() : $aInput['tr_attrs'], "bx-form-element-wrapper bx-def-margin-top");
  374. $sCaptionCode = '';
  375. if ($sCaption)
  376. $sCaptionCode = '<div class="bx-form-caption">' . $sCaption . $sRequired . '</div>';
  377. $sCode = <<<BLAH
  378. <div $sTrAttrs>
  379. $sCaptionCode
  380. <div class="bx-form-value$sClassAdd">
  381. <div class="bx-clear"></div>
  382. $sInput
  383. <div class="bx-clear"></div>
  384. </div>
  385. </div>
  386. BLAH;
  387. return $sCode;
  388. }
  389. /**
  390. * Generate Block Headers row
  391. *
  392. * @param array $aInput
  393. * @return string
  394. */
  395. function genRowBlockHeader(&$aInput)
  396. {
  397. $aAttrs = empty($aInput['attrs']) ? '' : $aInput['attrs'];
  398. // if there is no caption - show divider only
  399. if (empty($aInput['caption'])) {
  400. $sCode = $this->{$this->_sSectionClose}();
  401. $sCode .= $this->{$this->_sSectionOpen}($aAttrs);
  402. return $sCode;
  403. }
  404. // if section is collapsed by default, add necessary code
  405. $sClassAddCollapsable = 'bx-form-collapsable';
  406. if (isset($aInput['collapsed']) and $aInput['collapsed'])
  407. $sClassAddCollapsable .= ' bx-form-collapsed bx-form-section-hidden';
  408. // display section with caption
  409. $sCode = $this->{$this->_sSectionClose}();
  410. if (empty($aAttrs))
  411. $aAttrs['class'] = 'bx-form-collapsable ' . $sClassAddCollapsable;
  412. else
  413. $aAttrs['class'] .= ' bx-form-collapsable ' . $sClassAddCollapsable;
  414. if (isset($this->aParams['view_mode']) && $this->aParams['view_mode'])
  415. $sLegend = '<legend class="bx-def-padding-sec-right bx-def-font-grayed bx-def-font-h3">' . bx_process_output($aInput['caption']) . '</legend>';
  416. else
  417. $sLegend = '<legend class="bx-def-padding-left bx-def-padding-sec-right bx-def-font-grayed bx-def-font-h3"><a href="javascript:void(0);">' . bx_process_output($aInput['caption']) . '</a></legend>';
  418. $sCode .= $this->{$this->_sSectionOpen}($aAttrs, $sLegend);
  419. return $sCode;
  420. }
  421. function genBlockEnd()
  422. {
  423. $aNextTbodyAdd = false; // need to have some default
  424. $sCode = '';
  425. $sCode .= $this->{$this->_sSectionClose}();
  426. $sCode .= $this->{$this->_sSectionOpen}($aNextTbodyAdd);
  427. return $sCode;
  428. }
  429. /**
  430. * Generate HTML Input Element
  431. *
  432. * @param array $aInput
  433. * @return string Output HTML Code
  434. */
  435. function genInput(&$aInput)
  436. {
  437. if (!empty($aInput['name'])) {
  438. $sCustomMethod = 'genCustomInput' . $this->_genMethodName($aInput['name']);
  439. if (method_exists($this, $sCustomMethod))
  440. return $this->$sCustomMethod($aInput);
  441. }
  442. switch ($aInput['type']) {
  443. // standard inputs (and non-standard, interpreted as standard)
  444. case 'text':
  445. case 'datepicker':
  446. case 'date_time':
  447. case 'datetime':
  448. case 'number':
  449. case 'checkbox':
  450. case 'radio':
  451. case 'file':
  452. case 'image':
  453. case 'password':
  454. case 'slider':
  455. case 'doublerange':
  456. case 'hidden':
  457. $sInput = $this->genInputStandard($aInput);
  458. break;
  459. case 'rgb':
  460. case 'rgba':
  461. $sClass = 'bx-form-input-' . $aInput['type'];
  462. $aInput['attrs']['class'] = !empty($aInput['attrs']['class']) ? $aInput['attrs']['class'] . ' ' . $sClass : $sClass;
  463. $aInput['type'] = 'text';
  464. $sInput = $this->genInputStandard($aInput);
  465. break;
  466. case 'switcher':
  467. $sInput = $this->genInputSwitcher($aInput);
  468. break;
  469. case 'button':
  470. case 'reset':
  471. case 'submit':
  472. $sInput = $this->genInputButton($aInput);
  473. break;
  474. case 'textarea':
  475. $sInput = $this->genInputTextarea($aInput);
  476. break;
  477. case 'select':
  478. $sInput = $this->genInputSelect($aInput);
  479. break;
  480. case 'select_multiple':
  481. $sInput = $this->genInputSelectMultiple($aInput);
  482. break;
  483. case 'checkbox_set':
  484. $sInput = $this->genInputCheckboxSet($aInput);
  485. break;
  486. case 'radio_set':
  487. $sInput = $this->genInputRadioSet($aInput);
  488. break;
  489. case 'input_set': // numeric array of inputs
  490. $sInput = '';
  491. $sDivider = isset($aInput['dv']) ? $aInput['dv'] : ' ';
  492. foreach ($aInput as $iKey => $aSubInput) {
  493. if (!is_int($iKey) or !$aSubInput)
  494. continue; // parse only integer keys and existing values
  495. $sInput .= $this->genInput($aSubInput); // recursive call
  496. $sInput .= $sDivider;
  497. }
  498. $sInput .= '<div class="bx-clear"></div>';
  499. break;
  500. case 'custom':
  501. $sInput = isset($aInput['content']) ? $aInput['content'] : '';
  502. break;
  503. case 'captcha':
  504. $sInput = $this->genInputCaptcha($aInput);
  505. break;
  506. case 'value':
  507. $sInput = $aInput['value'];
  508. break;
  509. default:
  510. //unknown control type
  511. $sInput = 'Unknown control type';
  512. }
  513. // create input label
  514. $sInput .= $this->genLabel($aInput);
  515. return $sInput;
  516. }
  517. /**
  518. * Generate new Input Element id
  519. *
  520. * @param array $aInput
  521. * @return string
  522. */
  523. function getInputId(&$aInput)
  524. {
  525. if (isset($aInput['id']))
  526. return $aInput['id'];
  527. $sName = md5($aInput['name']);
  528. $sID = $this->id . '_input_' . $sName;
  529. if ( // multiple elements cause identical id's
  530. (
  531. (
  532. $aInput['type'] == 'checkbox' and
  533. substr($aInput['name'], -2) == '[]' // it is multiple element
  534. ) or
  535. $aInput['type'] == 'radio' // it is always multiple (i think so... hm)
  536. ) and
  537. isset($aInput['value']) // if we can make difference
  538. ) {
  539. $sValue = md5($aInput['value']);
  540. // add value
  541. $sID .= '_' . $sValue;
  542. }
  543. $sID = trim($sID, '_');
  544. $aInput['id'] = $sID; // just for repeated calls
  545. return $sID;
  546. }
  547. /**
  548. * Generate standard Input Element
  549. *
  550. * @param array $aInput
  551. * @return string
  552. */
  553. function genInputStandard(&$aInput)
  554. {
  555. // clone attributes for system use ;)
  556. $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
  557. // add default className to attributes
  558. $aAttrs['type'] = $aInput['type'];
  559. if ('datetime' == $aAttrs['type'])
  560. $aAttrs['type'] = 'date_time';
  561. if (isset($aInput['name'])) $aAttrs['name'] = $aInput['name'];
  562. if (isset($aInput['value'])) $aAttrs['value'] = $aInput['value'];
  563. // for inputs with labels generate id
  564. if (isset($aInput['label']))
  565. $aAttrs['id'] = $this->getInputId($aInput);
  566. // for checkboxes
  567. if (isset($aInput['checked']) and $aInput['checked'])
  568. $aAttrs['checked'] = 'checked';
  569. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-def-font-inputs bx-form-input-{$aInput['type']}");
  570. return "<input $sAttrs />\n";
  571. }
  572. /**
  573. * Generate Switcher Input Element (based on checkbox)
  574. *
  575. * @param array $aInput
  576. * @return string
  577. */
  578. function genInputSwitcher(&$aInput)
  579. {
  580. $aInput['type'] = 'checkbox';
  581. $sCheckbox = $this->genInputStandard($aInput);
  582. $aInput['type'] = 'switcher';
  583. $sClass = 'off';
  584. if (isset($aInput['checked']) and $aInput['checked'])
  585. $sClass = 'on';
  586. return '
  587. <div class="bx-switcher-cont ' . $sClass . '">' . $sCheckbox . '
  588. <div class="bx-switcher-canvas">
  589. <div class="bx-switcher-on"><i class="sys-icon check"></i></div>
  590. <div class="bx-switcher-off"><i class="sys-icon times"></i></div>
  591. <div class="bx-switcher-handler">&nbsp;</div>
  592. </div>
  593. </div>';
  594. }
  595. /**
  596. * Generate Button Input Element
  597. *
  598. * @param array $aInput
  599. * @return string
  600. */
  601. function genInputButton(&$aInput)
  602. {
  603. // clone attributes for system use ;)
  604. $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
  605. // add default className to attributes
  606. $aAttrs['type'] = $aInput['type'];
  607. if (isset($aInput['value']))
  608. $aAttrs['value'] = $aInput['value'];
  609. if (isset($aInput['name'])) $aAttrs['name'] = $aInput['name'];
  610. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-def-font-inputs bx-form-input-{$aInput['type']} bx-btn" . ('submit' == $aInput['type'] ? ' bx-btn-primary' : ''));
  611. return "<button $sAttrs>" . $aInput['value'] . "</button>\n";
  612. }
  613. /**
  614. * Generate Textarea Element
  615. *
  616. * @param array $aInput
  617. * @return string
  618. */
  619. function genInputTextarea(&$aInput)
  620. {
  621. // clone attributes for system use ;)
  622. $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
  623. $aAttrs['name'] = $aInput['name'];
  624. // for inputs with labels generate id
  625. if (isset($aInput['label']))
  626. $aAttrs['id'] = $this->getInputId($aInput);
  627. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-def-font-inputs bx-form-input-{$aInput['type']}" . ((isset($aInput['html']) and $aInput['html'] and $this->addHtmlEditor($aInput['html'], $aInput)) ? ' bx-form-input-html' : ''));
  628. $sValue = isset($aInput['value']) ? bx_process_output($aInput['value']) : '';
  629. return "<textarea $sAttrs>$sValue</textarea>";
  630. }
  631. function addHtmlEditor($iViewMode, &$aInput)
  632. {
  633. $oEditor = BxDolEditor::getObjectInstance(false, $this->oTemplate);
  634. if (!$oEditor)
  635. return false;
  636. $this->_sCodeAdd .= $oEditor->attachEditor ('#' . $this->aFormAttrs['id'] . ' [name='.$aInput['name'].']', $iViewMode, $this->_bDynamicMode);
  637. return true;
  638. }
  639. /**
  640. * Generate Select Box Element
  641. *
  642. * @param array $aInput
  643. * @return string
  644. */
  645. function genInputSelectBox(&$aInput, $sInfo = '', $sError = '')
  646. {
  647. $aNewInput = $aInput;
  648. $aNewInput['type'] = 'select';
  649. $aNewInput['name'] .= '[]';
  650. $sInput = $this->genInput($aNewInput);
  651. return <<<BLAH
  652. <div class="bx-form-input-wrapper input-wrapper-{$aInput['type']}">
  653. $sInput
  654. </div>
  655. $sInfo
  656. $sError
  657. BLAH;
  658. }
  659. /**
  660. * Generate Select Box Element
  661. *
  662. * @param array $aInput
  663. * @return string
  664. */
  665. function genInputFiles(&$aInput, $sInfo = '', $sError = '')
  666. {
  667. $sUniqId = genRndPwd (8, false);
  668. $sUploaders = '';
  669. $oUploader = null;
  670. foreach ($aInput['uploaders'] as $sUploaderObject) {
  671. $oUploader = BxDolUploader::getObjectInstance($sUploaderObject, $aInput['storage_object'], $sUniqId, $this->oTemplate);
  672. if (!$oUploader)
  673. continue;
  674. $sGhostTemplate = false;
  675. if (isset($aInput['ghost_template']) && is_object($aInput['ghost_template'])) { // form is not submitted and ghost template is BxDolFormNested object
  676. $oFormNested = $aInput['ghost_template'];
  677. if ($oFormNested instanceof BxDolFormNested)
  678. $sGhostTemplate = $oFormNested->getCode();
  679. } elseif (isset($aInput['ghost_template']) && is_array($aInput['ghost_template']) && isset($aInput['ghost_template']['inputs'])) { // form is not submitted and ghost template is form array
  680. $oFormNested = new BxDolFormNested($aInput['name'], $aInput['ghost_template'], $this->aParams['db']['submit_name'], $this->oTemplate);
  681. $sGhostTemplate = $oFormNested->getCode();
  682. } elseif (isset($aInput['ghost_template']) && is_array($aInput['ghost_template']) && $aInput['ghost_template']) { // form is submitted and ghost template is array of BxDolFormNested objects
  683. $sGhostTemplate = array ();
  684. foreach ($aInput['ghost_template'] as $iFileId => $oFormNested)
  685. if (is_object($oFormNested) && $oFormNested instanceof BxDolFormNested)
  686. $sGhostTemplate[$iFileId] = $oFormNested->getCode();
  687. } elseif (isset($aInput['ghost_template']) && is_string($aInput['ghost_template'])) { // ghost template is just string template, without nested form
  688. $sGhostTemplate = $aInput['ghost_template'];
  689. }
  690. $aParams = array(
  691. 'button_title' => bx_js_string($oUploader->getUploaderButtonTitle(isset($aInput['upload_buttons_titles']) ? $aInput['upload_buttons_titles'] : false)),
  692. 'content_id' => isset($aInput['content_id']) ? $aInput['content_id'] : '',
  693. 'storage_private' => isset($aInput['storage_private']) ? $aInput['storage_private'] : '1',
  694. );
  695. if (isset($aInput['images_transcoder']) && $aInput['images_transcoder'])
  696. $aParams['images_transcoder'] = bx_js_string($aInput['images_transcoder']);
  697. $sUploaders .= $oUploader->getUploaderButton($sGhostTemplate, isset($aInput['multiple']) ? $aInput['multiple'] : true, $aParams);
  698. }
  699. return $this->oTemplate->parseHtmlByName('form_field_uploader.html', array(
  700. 'uploaders_buttons' => $sUploaders,
  701. 'info' => $sInfo,
  702. 'error' => $sError,
  703. 'id_container_errors' => $oUploader ? $oUploader->getIdContainerErrors() : '',
  704. 'id_container_result' => $oUploader ? $oUploader->getIdContainerResult() : '',
  705. 'uploader_instance_name' => $oUploader ? $oUploader->getNameJsInstanceUploader() : '',
  706. 'is_init_ghosts' => isset($aInput['init_ghosts']) && !$aInput['init_ghosts'] ? 0 : 1,
  707. ));
  708. }
  709. /**
  710. * Generate Select Element
  711. *
  712. * @param array $aInput
  713. * @return string
  714. */
  715. function genInputSelect(&$aInput)
  716. {
  717. $sCurValue = isset($aInput['value']) ? $aInput['value'] : '';
  718. return $this->_genInputSelect($aInput, false, $sCurValue, '_isSelected');
  719. }
  720. /**
  721. * Generate Multiple Select Element
  722. *
  723. * @param array $aInput
  724. * @return string
  725. */
  726. function genInputSelectMultiple(&$aInput)
  727. {
  728. $aCurValues = array();
  729. if (isset($aInput['value']) && $aInput['value'])
  730. $aCurValues = is_array($aInput['value']) ? $aInput['value'] : array();
  731. return $this->_genInputSelect($aInput, true, $aCurValues, '_isSelectedMultiple');
  732. }
  733. /**
  734. * Generate Checkbox Set Element
  735. *
  736. * @param array $aInput
  737. * @return string
  738. */
  739. function genInputCheckboxSet(&$aInput)
  740. {
  741. $aCurValues = array();
  742. if (isset($aInput['value']) && $aInput['value'])
  743. $aCurValues = is_array($aInput['value']) ? $aInput['value'] : array();
  744. return $this->_genInputsSet($aInput, 'checkbox', $aCurValues, '_isSelectedMultiple', '[]');
  745. }
  746. /**
  747. * Generate Radiobuttons Set Element
  748. *
  749. * @param array $aInput
  750. * @return string
  751. */
  752. function genInputRadioSet(&$aInput)
  753. {
  754. $sCurValue = isset($aInput['value']) ? $aInput['value'] : '';
  755. return $this->_genInputsSet($aInput, 'radio', $sCurValue, '_isSelected');
  756. }
  757. function _isSelected ($sValue, $sCurValue)
  758. {
  759. return ((string)$sValue === (string)$sCurValue);
  760. }
  761. function _isSelectedMultiple ($sValue, $aCurValues)
  762. {
  763. return in_array($sValue, $aCurValues);
  764. }
  765. function _genInputSelect(&$aInput, $isMultiple, $mixedCurrentVal, $sIsSelectedFunc)
  766. {
  767. $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
  768. $aAttrs['name'] = $aInput['name'];
  769. if ($isMultiple) {
  770. $aAttrs['name'] .= '[]';
  771. $aAttrs['multiple'] = 'multiple';
  772. }
  773. // for inputs with labels generate id
  774. if (isset($aInput['label']))
  775. $aAttrs['id'] = $this->getInputId($aInput);
  776. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-def-font-inputs bx-form-input-{$aInput['type']}");
  777. // generate options
  778. $sOptions = '';
  779. if (isset($aInput['values']) and is_array($aInput['values'])) {
  780. foreach ($aInput['values'] as $sValue => $sTitle) {
  781. $sClassC = $sStyleC = "";
  782. if(is_array($sTitle)) {
  783. if(isset($sTitle['type'])) {
  784. switch($sTitle['type']) {
  785. case 'group_header':
  786. $sTitle = bx_process_output($sTitle['value']);
  787. $sOptions .= <<<BLAH
  788. <optgroup label="$sTitle">
  789. BLAH;
  790. break;
  791. case 'group_end':
  792. $sOptions .= <<<BLAH
  793. </optgroup>
  794. BLAH;
  795. break;
  796. }
  797. continue;
  798. }
  799. $sClassC = isset($sTitle['class']) ? " class=\"" . $sTitle['class'] . "\"" : "";
  800. $sStyleC = isset($sTitle['style']) ? " style=\"" . $sTitle['style'] . "\"" : "";
  801. $sValue = $sTitle['key'];
  802. $sTitle = $sTitle['value'];
  803. }
  804. $sValueC = bx_html_attribute($sValue);
  805. $sTitleC = bx_process_output($sTitle);
  806. $sSelected = $this->$sIsSelectedFunc($sValue, $mixedCurrentVal) ? 'selected="selected"' : '';
  807. $sOptions .= <<<BLAH
  808. <option value="$sValueC"$sClassC$sStyleC $sSelected>$sTitleC</option>
  809. BLAH;
  810. }
  811. }
  812. // generate element
  813. $sCode = <<<BLAH
  814. <select $sAttrs>
  815. $sOptions
  816. </select>
  817. BLAH;
  818. return $sCode;
  819. }
  820. function _genInputsSet(&$aInput, $sType, $mixedCurrentVal, $sIsCheckedFunc, $sNameAppend = '')
  821. {
  822. $aAttrs = empty($aInput['attrs']) || 'radio_set' == $aInput['type'] || 'checkbox_set' == $aInput['type'] ? array() : $aInput['attrs'];
  823. $aAttrs['name'] = $aInput['name'];
  824. // for inputs with labels generate id
  825. if (isset($aInput['label']))
  826. $aAttrs['id'] = $this->getInputId($aInput);
  827. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-form-input-{$aInput['type']}");
  828. // generate options
  829. $sDivider = isset($aInput['dv']) ? $aInput['dv'] : $this->_sDivider;
  830. $sOptions = '';
  831. if (isset($aInput['values']) and is_array($aInput['values'])) {
  832. if (count($aInput['values']) > 3 && $sDivider == $this->_sDivider)
  833. $sDivider = $this->_sDividerAlt;
  834. // generate complex input using simple standard inputs
  835. foreach ($aInput['values'] as $sValue => $sLabel) {
  836. // create new simple input
  837. $aNewInput = array(
  838. 'type' => $sType,
  839. 'name' => $aInput['name'] . $sNameAppend,
  840. 'value' => $sValue,
  841. 'checked' => $this->$sIsCheckedFunc($sValue, $mixedCurrentVal),
  842. 'label' => $sLabel,
  843. 'attrs' => !empty($aInput['attrs']) && ('radio_set' == $aInput['type'] || 'checkbox_set' == $aInput['type']) ? $aInput['attrs'] : false,
  844. );
  845. $sNewInput = $this->genInput($aNewInput);
  846. // attach new input to complex
  847. $sOptions .= ($sNewInput . $sDivider);
  848. }
  849. }
  850. // generate element
  851. $sCode = <<<BLAH
  852. <div $sAttrs>
  853. $sOptions
  854. </div>
  855. BLAH;
  856. return $sCode;
  857. }
  858. function genInputCaptcha(&$aInput)
  859. {
  860. $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
  861. // for inputs with labels generate id
  862. if (isset($aInput['label']))
  863. $aAttrs['id'] = $this->getInputId($aInput);
  864. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-form-input-{$aInput['type']}");
  865. $oCaptcha = BxDolCaptcha::getObjectInstance();
  866. return "<div $sAttrs>" . ($oCaptcha ? $oCaptcha->display($this->_bDynamicMode) : _t('_sys_txt_captcha_not_available')) . "</div>";
  867. }
  868. /**
  869. * Generate Label Element
  870. *
  871. * @param string $sLabel Text of the Label
  872. * @param string $sInputID Dependant Input Element ID
  873. * @return string HTML code
  874. */
  875. function genLabel(&$aInput)
  876. {
  877. if (!isset($aInput['label']) or empty($aInput['label']))
  878. return '';
  879. $sLabel = $aInput['label'];
  880. $sInputID = $this->getInputId($aInput);
  881. $sRet = '<label for="' . $sInputID . '">' . bx_process_output($sLabel) . '</label>';
  882. return $sRet;
  883. }
  884. function genInfoIcon($sInfo)
  885. {
  886. return '<div class="bx-form-info bx-def-font-grayed bx-def-font-small">' . bx_process_output($sInfo) . '</div>';
  887. }
  888. function genErrorIcon( $sError = '' )
  889. {
  890. if ($this->bEnableErrorIcon) {
  891. $sStyle = '';
  892. if (!$sError)
  893. $sStyle = 'style="display:none;"';
  894. return '<div class="bx-form-warn" ' . $sStyle . '>' . $sError . '</div>';
  895. }
  896. }
  897. function getOpenSection($aAttrs = array(), $sLegend = '')
  898. {
  899. if (!$this->_isSectionOpened) {
  900. if (!$aAttrs || !is_array($aAttrs))
  901. $aAttrs = array();
  902. if ($sLegend)
  903. $sClassesAdd = "bx-form-section-header";
  904. else
  905. $sClassesAdd = "bx-form-section-divider";
  906. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-form-section bx-def-padding-sec-top bx-def-border-top " . $sClassesAdd);
  907. $this->_isSectionOpened = true;
  908. return "<!-- form header content begins -->\n <div class=\"bx-form-section-wrapper bx-def-margin-top\"> <fieldset $sAttrs> $sLegend <div class=\"bx-form-section-content bx-def-padding-top bx-def-padding-bottom" . ($sLegend ? ' bx-def-padding-left bx-def-padding-right' : '') . "\">\n";
  909. } else {
  910. return '';
  911. }
  912. }
  913. function getCloseSection()
  914. {
  915. if ($this->_isSectionOpened) {
  916. $this->_isSectionOpened = false;
  917. return "</div> </fieldset> </div> \n<!-- form header content ends -->\n";
  918. } else {
  919. return '';
  920. }
  921. }
  922. function getOpenSectionViewMode($aAttrs = array(), $sLegend = '')
  923. {
  924. if (!$this->_isSectionOpened) {
  925. if (!$aAttrs || !is_array($aAttrs))
  926. $aAttrs = array();
  927. if ($sLegend)
  928. $sClassesAdd = "bx-form-section-header";
  929. else
  930. $sClassesAdd = "bx-form-section-divider";
  931. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-form-section bx-form-view-section bx-def-padding-sec-top bx-def-border-top " . $sClassesAdd);
  932. $this->_isSectionOpened = true;
  933. return "<!-- form header content begins -->\n <div class=\"bx-form-section-wrapper bx-def-margin-top\"> <fieldset $sAttrs> $sLegend <div class=\"bx-form-section-content bx-def-padding-top\">\n";
  934. } else {
  935. return '';
  936. }
  937. }
  938. function getCloseSectionViewMode()
  939. {
  940. if ($this->_isSectionOpened) {
  941. $this->_isSectionOpened = false;
  942. return "</div> </fieldset> </div> \n<!-- form header content ends -->\n";
  943. } else {
  944. return '';
  945. }
  946. }
  947. function addCssJs ()
  948. {
  949. if (isset($this->aParams['view_mode']) && $this->aParams['view_mode']) {
  950. if (self::$_isCssJsAddedViewMode)
  951. return;
  952. $this->oTemplate->addCss('forms.css');
  953. self::$_isCssJsAddedViewMode = true;
  954. } else {
  955. if (self::$_isCssJsAdded)
  956. return;
  957. $aCss = array(
  958. 'forms.css',
  959. 'jquery-ui/jquery-ui.css',
  960. 'timepicker-addon/jquery-ui-timepicker-addon.css',
  961. BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'jquery-minicolors/|jquery.minicolors.css',
  962. );
  963. $aUiLangs = array ('af' => 1, 'ar-DZ' => 1, 'ar' => 1, 'az' => 1, 'be' => 1, 'bg' => 1, 'bs' => 1, 'ca' => 1, 'cs' => 1, 'cy-GB' => 1, 'da' => 1, 'de' => 1, 'el' => 1, 'en-AU' => 1, 'en-GB' => 1, 'en-NZ' => 1, 'en' => 1, 'eo' => 1, 'es' => 1, 'et' => 1, 'eu' => 1, 'fa' => 1, 'fi' => 1, 'fo' => 1, 'fr-CA' => 1, 'fr-CH' => 1, 'fr' => 1, 'gl' => 1, 'he' => 1, 'hi' => 1, 'hr' => 1, 'hu' => 1, 'hy' => 1, 'id' => 1, 'is' => 1, 'it' => 1, 'ja' => 1, 'ka' => 1, 'kk' => 1, 'km' => 1, 'ko' => 1, 'ky' => 1, 'lb' => 1, 'lt' => 1, 'lv' => 1, 'mk' => 1, 'ml' => 1, 'ms' => 1, 'nb' => 1, 'nl-BE' => 1, 'nl' => 1, 'nn' => 1, 'no' => 1, 'pl' => 1, 'pt-BR' => 1, 'pt' => 1, 'rm' => 1, 'ro' => 1, 'ru' => 1, 'sk' => 1, 'sl' => 1, 'sq' => 1, 'sr-SR' => 1, 'sr' => 1, 'sv' => 1, 'ta' => 1, 'th' => 1, 'tj' => 1, 'tr' => 1, 'uk' => 1, 'vi' => 1, 'zh-CN' => 1, 'zh-HK' => 1, 'zh-TW' => 1);
  964. $aCalendarLangs = array ('af' => 1, 'am' => 1, 'bg' => 1, 'ca' => 1, 'cs' => 1, 'da' => 1, 'de' => 1, 'el' => 1, 'es' => 1, 'et' => 1, 'eu' => 1, 'fa' => 1, 'fi' => 1, 'fr' => 1, 'gl' => 1, 'he' => 1, 'hr' => 1, 'hu' => 1, 'id' => 1, 'it' => 1, 'ja' => 1, 'ko' => 1, 'lt' => 1, 'lv' => 1, 'mk' => 1, 'nl' => 1, 'no' => 1, 'pl' => 1, 'pt-BR' => 1, 'pt' => 1, 'ro' => 1, 'ru' => 1, 'sk' => 1, 'sl' => 1, 'sr-RS' => 1, 'sr-YU' => 1, 'sv' => 1, 'th' => 1, 'tr' => 1, 'uk' => 1, 'vi' => 1, 'zh-CN' => 1, 'zh-TW' => 1);
  965. $sCalendarLang = BxDolLanguages::getInstance()->detectLanguageFromArray ($aCalendarLangs);
  966. $sUiLang = BxDolLanguages::getInstance()->detectLanguageFromArray ($aUiLangs);
  967. $aJs = array(
  968. 'jquery.webForms.js',
  969. 'jquery-ui/jquery.ui.core.min.js',
  970. 'jquery-ui/jquery.ui.widget.min.js',
  971. 'jquery-ui/jquery.ui.mouse.min.js',
  972. 'jquery-ui/jquery.ui.position.min.js',
  973. 'jquery-ui/jquery.ui.slider.min.js',
  974. 'jquery-ui/jquery.ui.datepicker.min.js',
  975. 'jquery-ui/i18n/jquery.ui.datepicker-' . $sUiLang . '.js',
  976. 'jquery-minicolors/jquery.minicolors.min.js',
  977. 'timepicker-addon/jquery-ui-timepicker-addon.min.js',
  978. 'timepicker-addon/jquery-ui-sliderAccess.js',
  979. 'timepicker-addon/i18n/jquery-ui-timepicker-' . $sCalendarLang . '.js',
  980. );
  981. foreach ($this->aInputs as $aInput) {
  982. if (!isset($aInput['type']) || 'files' != $aInput['type'] || !isset($aInput['uploaders']))
  983. continue;
  984. foreach ($aInput['uploaders'] as $sUploaderObject) {
  985. $oUploader = BxDolUploader::getObjectInstance($sUploaderObject, $aInput['storage_object'], '', $this->oTemplate);
  986. if ($oUploader)
  987. $oUploader->addCssJs();
  988. }
  989. }
  990. $this->oTemplate->addJs($aJs);
  991. $this->oTemplate->addCss($aCss);
  992. self::$_isCssJsAdded = true;
  993. }
  994. }
  995. }
  996. /** @} */