BxBaseFormView.php 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. class BxBaseFormView extends BxDolForm
  10. {
  11. protected static $_isToggleJsAdded = false;
  12. protected static $_isCssJsAdded = false;
  13. protected static $_isCssJsUiAdded = false;
  14. protected static $_isCssJsMinicolorsAdded = false;
  15. protected static $_isCssJsTimepickerAdded = false;
  16. protected static $_isCssJsAddedViewMode = false;
  17. /**
  18. * Enable or disable error message displaying
  19. */
  20. protected $bEnableErrorIcon = true;
  21. /**
  22. * HTML Code of this form
  23. */
  24. protected $sCode;
  25. /**
  26. * Code which will be added to the beginning of the form.
  27. * For example, hidden inputs.
  28. * For internal use only
  29. */
  30. protected $_sCodeAdd = '';
  31. /**
  32. * for internal use only
  33. */
  34. protected $_isSectionOpened = false;
  35. /**
  36. * Default divider for several inputs
  37. */
  38. protected $_sDivider = '<span class="bx-def-margin-left"></span>';
  39. /**
  40. * Alternative divider for several inputs
  41. */
  42. protected $_sDividerAlt = '<br />';
  43. /**
  44. * Form is added dynamically.
  45. */
  46. protected $_bDynamicMode = false;
  47. /**
  48. * Form is submitted dynamically (using Ajax Submit).
  49. */
  50. protected $_bAjaxMode = false;
  51. /**
  52. * Use absolute Action URL which is needed in Ajax Mode.
  53. */
  54. protected $_bAbsoluteActionUrl = false;
  55. /**
  56. * Form is displayed in view mode.
  57. */
  58. protected $_bViewMode = false;
  59. /**
  60. * Function name for generation close form section HTML.
  61. */
  62. protected $_sSectionClose = 'getCloseSection';
  63. /**
  64. * Function name for generation open form section HTML.
  65. */
  66. protected $_sSectionOpen = 'getOpenSection';
  67. /**
  68. * JS files list for form
  69. */
  70. protected $_aJs = array();
  71. /**
  72. * CSS files list for form
  73. */
  74. protected $_aCss = array();
  75. /**
  76. * Constructor
  77. *
  78. * @param array $aInfo Form contents
  79. *
  80. * $aInfo['params'] = array(
  81. * 'remove_form' => true|false,
  82. * );
  83. *
  84. * @return BxBaseFormView
  85. */
  86. function __construct($aInfo, $oTemplate)
  87. {
  88. parent::__construct($aInfo, $oTemplate);
  89. $this->_bAjaxMode = isset($this->aParams['ajax_mode']) && $this->aParams['ajax_mode'];
  90. $this->_bViewMode = isset($this->aParams['view_mode']) && $this->aParams['view_mode'];
  91. if($this->_bViewMode) {
  92. $this->_sSectionClose = 'getCloseSectionViewMode';
  93. $this->_sSectionOpen = 'getOpenSectionViewMode';
  94. }
  95. }
  96. function setAjaxMode($bAjaxMode)
  97. {
  98. $this->_bAjaxMode = (bool)$bAjaxMode;
  99. }
  100. function isAjaxMode()
  101. {
  102. return $this->_bAjaxMode;
  103. }
  104. function setAbsoluteActionUrl($sUrl)
  105. {
  106. if(empty($sUrl))
  107. return;
  108. $this->aFormAttrs['action'] = $sUrl;
  109. $this->_bAbsoluteActionUrl = true;
  110. }
  111. /**
  112. * Return Form code
  113. * @param $bDynamicMode - set it to true if form is added via JS/AJAX call, for example form in AJAX popup.
  114. * @return string
  115. */
  116. function getCode($bDynamicMode = false)
  117. {
  118. if (!$bDynamicMode && bx_is_dynamic_request())
  119. $bDynamicMode = true;
  120. $this->_bDynamicMode = $bDynamicMode;
  121. $this->aFormAttrs = $this->_replaceMarkers($this->aFormAttrs);
  122. $this->sCode = $this->genForm();
  123. $this->addCssJs ();
  124. $sDynamicCssJs = $this->_processCssJs();
  125. return $sDynamicCssJs . $this->sCode;
  126. }
  127. /**
  128. * Generate the whole form
  129. *
  130. * @return string
  131. */
  132. function genForm()
  133. {
  134. $this->_sCodeAdd = '';
  135. $sTable = $this->genRows();
  136. $sHtmlBefore = isset($this->aParams['html_before']) ? $this->aParams['html_before'] : '';
  137. $sHtmlAfter = isset($this->aParams['html_after']) ? $this->aParams['html_after'] : '';
  138. if (!empty($this->aParams['remove_form']) || (isset($this->aParams['view_mode']) && $this->aParams['view_mode'])) {
  139. $sForm = <<<BLAH
  140. $sHtmlBefore
  141. {$this->_sCodeAdd}
  142. <div class="bx-form-advanced-wrapper {$this->id}_wrapper">
  143. $sTable
  144. </div>
  145. $sHtmlAfter
  146. BLAH;
  147. } else {
  148. $sFormAttrs = bx_convert_array2attrs($this->aFormAttrs, 'bx-form-advanced');
  149. $sAjaxFormJs = '';
  150. if($this->_bAjaxMode)
  151. $sAjaxFormJs = <<<BLAH
  152. $("form#{$this->id}").ajaxForm({
  153. dataType: "json",
  154. beforeSubmit: function (formData, jqForm, options) {
  155. bx_loading($("form#{$this->id}"), true);
  156. },
  157. success: function (oData) {
  158. bx_loading($("form#{$this->id}"), false);
  159. processJsonData(oData);
  160. }
  161. });
  162. BLAH;
  163. $sForm = <<<BLAH
  164. $sHtmlBefore
  165. <form $sFormAttrs>
  166. {$this->_sCodeAdd}
  167. <div class="bx-form-advanced-wrapper {$this->id}_wrapper">
  168. $sTable
  169. </div>
  170. </form>
  171. <script>
  172. $(document).ready(function() {
  173. $(this).addWebForms();
  174. });
  175. $sAjaxFormJs
  176. </script>
  177. $sHtmlAfter
  178. BLAH;
  179. }
  180. return $sForm;
  181. }
  182. /**
  183. * Generate Table HTML code
  184. *
  185. * @return string
  186. */
  187. function genRows()
  188. {
  189. // add CSRF token if it's needed.
  190. 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) {
  191. $this->aInputs['csrf_token'] = array(
  192. 'type' => 'hidden',
  193. 'name' => 'csrf_token',
  194. 'value' => $mixedCsrfToken,
  195. 'db' => array ('pass' => 'Xss'),
  196. 'visible_for_levels' => PHP_INT_MAX,
  197. );
  198. }
  199. // add 'Ajax Mode' flag
  200. if($this->_bAjaxMode)
  201. $this->aInputs['ajax_mode'] = array(
  202. 'type' => 'hidden',
  203. 'name' => 'ajax_mode',
  204. 'value' => 1,
  205. 'db' => array ('pass' => 'Int'),
  206. 'visible_for_levels' => PHP_INT_MAX,
  207. );
  208. // add 'Absolute Action Url' flag
  209. if($this->_bAbsoluteActionUrl)
  210. $this->aInputs['absolute_action_url'] = array(
  211. 'type' => 'hidden',
  212. 'name' => 'absolute_action_url',
  213. 'value' => 1,
  214. 'db' => array ('pass' => 'Int'),
  215. 'visible_for_levels' => PHP_INT_MAX,
  216. );
  217. // check if we need to generate open section clause
  218. $sOpenSection = '';
  219. foreach ($this->aInputs as $aInput) {
  220. if (isset($aInput['type']) && 'hidden' == $aInput['type'])
  221. continue;
  222. if (isset($aInput['type']) && 'block_header' != $aInput['type'])
  223. $sOpenSection = $this->{$this->_sSectionOpen}();
  224. break;
  225. }
  226. // generate rows contents
  227. $sCont = '';
  228. $sContHeader = '';
  229. $sContFields = '';
  230. $sFuncGenRow = isset($this->aParams['view_mode']) && $this->aParams['view_mode'] ? 'genViewRow' : 'genRow';
  231. foreach ($this->aInputs as $aInput) {
  232. if (!isset($aInput['visible_for_levels']) || self::isVisible($aInput)) {
  233. if ('block_header' == $aInput['type']) {
  234. // don't show section with no fields or with empty fields
  235. if ($sContHeader) {
  236. if ($sContFields)
  237. $sCont .= $sContHeader . $sContFields;
  238. else
  239. $sContHeader = '';
  240. $sContFields = '';
  241. }
  242. else {
  243. $sCont .= $sContFields;
  244. $sContFields = '';
  245. }
  246. $sContHeader = $this->$sFuncGenRow($aInput);
  247. } else {
  248. $sContFields .= $this->$sFuncGenRow($aInput);
  249. }
  250. }
  251. }
  252. $sCont .= $sContHeader . $sContFields;
  253. $sCloseSection = $this->{$this->_sSectionClose}();
  254. return $sOpenSection . $sCont . $sCloseSection;
  255. }
  256. /**
  257. * Generate single Table Row
  258. *
  259. * @param array $aInput
  260. * @return string
  261. */
  262. function genRow(&$aInput)
  263. {
  264. if (!isset($aInput['type']))
  265. $aInput['type'] = false;
  266. if (!empty($aInput['name'])) {
  267. $sCustomMethod = 'genCustomRow' . $this->_genMethodName($aInput['name']);
  268. if (method_exists($this, $sCustomMethod))
  269. return $this->$sCustomMethod($aInput);
  270. }
  271. switch ($aInput['type']) {
  272. case 'block_header':
  273. $sRow = $this->genRowBlockHeader($aInput);
  274. break;
  275. case 'block_end':
  276. $sRow = $this->genBlockEnd($aInput);
  277. break;
  278. case 'hidden':
  279. // do not generate row for hidden inputs
  280. $sRow = '';
  281. $this->_sCodeAdd .= $this->genInput($aInput);
  282. break;
  283. case 'select_box':
  284. $sRow = $this->genRowCustom($aInput, 'genInputSelectBox');
  285. break;
  286. case 'files':
  287. $sRow = $this->genRowCustom($aInput, 'genInputFiles');
  288. break;
  289. case 'switcher':
  290. case 'checkbox':
  291. $sRow = $this->genRowStandard($aInput, true);
  292. break;
  293. default:
  294. $sRow = $this->genRowStandard($aInput);
  295. }
  296. return $sRow;
  297. }
  298. /**
  299. * Generate single Table Row for view mode
  300. *
  301. * @param array $aInput
  302. * @return string
  303. */
  304. function genViewRow(&$aInput)
  305. {
  306. if (!isset($aInput['type']))
  307. $aInput['type'] = false;
  308. if (!empty($aInput['name'])) {
  309. $sCustomMethod = 'genCustomRow' . $this->_genMethodName($aInput['name']);
  310. if (method_exists($this, $sCustomMethod))
  311. return $this->$sCustomMethod($aInput);
  312. }
  313. switch ($aInput['type']) {
  314. case 'block_header':
  315. $sRow = $this->genRowBlockHeader($aInput);
  316. break;
  317. case 'block_end':
  318. $sRow = $this->genBlockEnd($aInput);
  319. break;
  320. default:
  321. $sRow = $this->genViewRowWrapped($aInput);
  322. }
  323. return $sRow;
  324. }
  325. /**
  326. * Generate complete wrapped row for view mode form
  327. *
  328. * @param array $aInput
  329. * @return string
  330. */
  331. function genViewRowWrapped(&$aInput)
  332. {
  333. $sValue = $this->genViewRowValue($aInput);
  334. if (null === $sValue)
  335. return '';
  336. $sCaption = isset($aInput['caption']) ? bx_process_output($aInput['caption']) : '';
  337. return <<<EOS
  338. <div class="bx-form-row-view-wrapper bx-form-row-view-wrapper-{$aInput['type']} bx-def-padding-sec-top">
  339. <div class="bx-form-row-view-caption">{$sCaption}:</div>
  340. <div class="bx-form-row-view-value">{$sValue}</div>
  341. </div>
  342. EOS;
  343. }
  344. /**
  345. * Generate value for view mode row
  346. *
  347. * @param array $aInput
  348. * @return string
  349. */
  350. function genViewRowValue(&$aInput)
  351. {
  352. if (!empty($aInput['name'])) {
  353. $sCustomMethod = 'genCustomViewRowValue' . $this->_genMethodName($aInput['name']);
  354. if (method_exists($this, $sCustomMethod))
  355. return $this->$sCustomMethod($aInput);
  356. }
  357. switch ($aInput['type']) {
  358. case 'hidden':
  359. $sValue = null;
  360. break;
  361. case 'select':
  362. case 'radio_set':
  363. $sValue = $this->genViewRowValueForSelect($aInput);
  364. break;
  365. case 'datepicker':
  366. $sValue = null;
  367. if (empty($aInput['value']) || !$aInput['value'] || '0000-00-00' == $aInput['value'])
  368. break;
  369. $sValue = BxTemplFunctions::getInstance()->{is_numeric($aInput['value']) ? 'timeForJs' : 'timeForJsFullDate'}($aInput['value'], isset($aInput['date_format']) ? $aInput['date_format'] : BX_FORMAT_DATE, true);
  370. break;
  371. case 'date_time':
  372. case 'datetime':
  373. $sValue = null;
  374. if(empty($aInput['value']) || !$aInput['value'] || '0000-00-00 00:00:00' == $aInput['value'] || '0000-00-00 00:00' == $aInput['value'])
  375. break;
  376. $sValue = BxTemplFunctions::getInstance()->{is_numeric($aInput['value']) ? 'timeForJs' : 'timeForJsFullDate'}($aInput['value'], isset($aInput['date_format']) ? $aInput['date_format'] : BX_FORMAT_DATE_TIME, true);
  377. break;
  378. case 'checkbox_set':
  379. case 'select_multiple':
  380. $sValue = null;
  381. if (!empty($aInput['value']) && is_array($aInput['value'])) {
  382. $sValue = '';
  383. foreach ($aInput['value'] as $sVal)
  384. $sValue .= $aInput['values'][$sVal] . ', ';
  385. $sValue = trim ($sValue, ', ');
  386. }
  387. break;
  388. case 'checkbox':
  389. case 'switcher':
  390. $sValue = isset($aInput['checked']) && $aInput['checked'] ? _t('_sys_form_checkbox_value_on') : _t('_sys_form_checkbox_value_off');
  391. break;
  392. case 'textarea':
  393. if (isset($aInput['value']) && '' !== $aInput['value'])
  394. $sValue = (isset($aInput['html']) && $aInput['html']) || (isset($aInput['code']) && $aInput['code']) ? $aInput['value'] : bx_process_output($aInput['value'], BX_DATA_TEXT_MULTILINE);
  395. else
  396. $sValue = null;
  397. break;
  398. case 'text':
  399. if(isset($aInput['value']) && '' !== $aInput['value'])
  400. $sValue = bx_linkify(bx_process_output($aInput['value']));
  401. else
  402. $sValue = null;
  403. break;
  404. default:
  405. $sValue = isset($aInput['value']) && '' !== $aInput['value'] ? bx_process_output($aInput['value']) : null;
  406. }
  407. return $sValue;
  408. }
  409. function genViewRowValueForSelect(&$aInput)
  410. {
  411. if (!isset($aInput['value']) || !$aInput['value'])
  412. return null;
  413. $s = isset($aInput['value']) && isset($aInput['values'][$aInput['value']]) ? $aInput['values'][$aInput['value']] : null;
  414. if (isset($aInput['values_list_name']) && ($oCategory = BxDolCategory::getObjectInstanceByFormAndList($this->aFormAttrs['name'], $aInput['values_list_name'])))
  415. return $oCategory->getCategoryLink($s, $aInput['value']);
  416. return $s;
  417. }
  418. protected function genCustomRowBirthday(&$aInput)
  419. {
  420. if(!$this->_bViewMode)
  421. return $this->genRowStandard($aInput);
  422. $aInput['caption_src'] = '_sys_form_input_age';
  423. $aInput['caption'] = _t($aInput['caption_src']);
  424. return $this->genViewRowWrapped($aInput);
  425. }
  426. protected function genCustomViewRowValueBirthday(&$aInput)
  427. {
  428. if(!isset($aInput['value']) || !$aInput['value'] || in_array($aInput['value'], array('0000-00-00', '0000-00-00 00:00:00')))
  429. return null;
  430. $sValue = $aInput['value'];
  431. $iPosSpace = strpos($sValue, ' ');
  432. if($iPosSpace !== false)
  433. $sValue = trim(substr($sValue, 0, $iPosSpace));
  434. $aDate = explode('-', $sValue);
  435. $iCdYear = (int)date('Y');
  436. $iCdMonth = (int)date('n');
  437. $iCdDay = (int)date('j');
  438. $iResult = $iCdYear - (int)$aDate[0];
  439. if($iCdMonth < (int)$aDate[1] || ($iCdMonth == (int)$aDate[1] && $iCdDay < (int)$aDate[2]))
  440. $iResult -= 1;
  441. return $iResult;
  442. }
  443. /**
  444. * Generate standard row
  445. *
  446. * @param array $aInput
  447. * @return string
  448. */
  449. function genRowStandard(&$aInput, $isOneLine = false)
  450. {
  451. $sCaption = isset($aInput['caption']) ? bx_process_output($aInput['caption'], BX_DATA_HTML) : '';
  452. $sRequired = !empty($aInput['required']) ? '<span class="bx-form-required">*</span> ' : '';
  453. $sClassAdd = !empty($aInput['error']) ? ' bx-form-error' : '';
  454. $sInfoIcon = !empty($aInput['info']) ? $this->genInfoIcon($aInput['info']) : '';
  455. $sErrorIcon = $this->genErrorIcon(empty($aInput['error']) ? '' : $aInput['error']);
  456. $sClassWrapper = 'bx-form-element-wrapper';
  457. if($isOneLine)
  458. $sClassWrapper .= ' ' . $sClassWrapper . '-oneline';
  459. $sClassWrapper .= ' bx-def-margin-top';
  460. if (isset($aInput['name']))
  461. $aInput['tr_attrs']['id'] = "bx-form-element-" . $aInput['name'];
  462. $sTrAttrs = bx_convert_array2attrs(isset($aInput['tr_attrs']) && is_array($aInput['tr_attrs']) ? $aInput['tr_attrs'] : array(), $sClassWrapper);
  463. $sClassOneLineCaption = '';
  464. $sClassOneLineValue = '';
  465. if ($isOneLine) {
  466. $sClassOneLineCaption = ' bx-form-caption-oneline bx-form-caption-oneline-' . $aInput['type'] . ' bx-def-margin-sec-left';
  467. $sClassOneLineValue = ' bx-form-value-oneline bx-form-value-oneline-' . $aInput['type'];
  468. $aInput['attrs']['id'] = $this->getInputId($aInput);
  469. if ($sCaption)
  470. $sCaption = '<label for="' . $aInput['attrs']['id'] . '">' . $sCaption . '</label>';
  471. }
  472. $sInput = $this->genInput($aInput);
  473. if(isset($aInput['error_updated']) && $aInput['error_updated'] === true)
  474. $sErrorIcon = $this->genErrorIcon(empty($aInput['error']) ? '' : $aInput['error']);
  475. $sCaptionCode = '';
  476. if ($sCaption)
  477. $sCaptionCode = '<div class="bx-form-caption' . $sClassOneLineCaption . '">' . $sCaption . $sRequired . '</div>';
  478. else
  479. $sInput .= $sRequired;
  480. $sInputCode = $this->genWrapperInput($aInput, $sInput);
  481. if (empty($sInfoIcon)) $sInfoIcon = '';
  482. if (empty($sInputCode)) $sInputCode = '';
  483. if (empty($sErrorIcon)) $sErrorIcon = '';
  484. $sValueCode = '<div class="bx-form-value bx-clearfix' . $sClassAdd . $sClassOneLineValue . '">' . $sInputCode . '</div>';
  485. if ($isOneLine)
  486. $sCode = $sValueCode . $sCaptionCode;
  487. else
  488. $sCode = $sCaptionCode . $sValueCode;
  489. return '<div ' . $sTrAttrs . '><div class="bx-form-element">' . $sCode . '</div>' . $sInfoIcon . $sErrorIcon . '</div>';
  490. }
  491. function genWrapperInput($aInput, $sContent)
  492. {
  493. $sAttr = isset($aInput['attrs_wrapper']) && is_array($aInput['attrs_wrapper']) ? bx_convert_array2attrs($aInput['attrs_wrapper']) : '';
  494. return "<div class=\"bx-form-input-wrapper bx-form-input-wrapper-{$aInput['type']}" . ((isset($aInput['html']) && $aInput['html'] && $this->isHtmlEditor($aInput['html'], $aInput)) ? ' bx-form-input-wrapper-html' : '') . "\" $sAttr>$sContent</div>";
  495. }
  496. /**
  497. * Generate custom row
  498. *
  499. * @param array $aInput
  500. * @param string $sCustomMethod custom method to generate code for input
  501. * @return string
  502. */
  503. function genRowCustom(&$aInput, $sCustomMethod)
  504. {
  505. $sCaption = isset($aInput['caption']) ? bx_process_output($aInput['caption']) : '';
  506. $sRequired = !empty($aInput['required']) ? '<span class="bx-form-required">*</span> ' : '';
  507. $sClassAdd = !empty($aInput['error']) ? ' bx-form-error' : '';
  508. $sInfoIcon = !empty($aInput['info']) ? $this->genInfoIcon($aInput['info']) : '';
  509. $sErrorIcon = $this->genErrorIcon(empty($aInput['error']) ? '' : $aInput['error']);
  510. $sInput = $this->$sCustomMethod($aInput, $sInfoIcon, $sErrorIcon);
  511. if (isset($aInput['name']))
  512. $aInput['tr_attrs']['id'] = "bx-form-element-" . $aInput['name'];
  513. $sTrAttrs = bx_convert_array2attrs(empty($aInput['tr_attrs']) ? array() : $aInput['tr_attrs'], "bx-form-element-wrapper bx-def-margin-top");
  514. $sCaptionCode = '';
  515. if ($sCaption)
  516. $sCaptionCode = '<div class="bx-form-caption">' . $sCaption . $sRequired . '</div>';
  517. $sCode = <<<BLAH
  518. <div $sTrAttrs>
  519. $sCaptionCode
  520. <div class="bx-form-value$sClassAdd">
  521. <div class="bx-clear"></div>
  522. $sInput
  523. <div class="bx-clear"></div>
  524. </div>
  525. </div>
  526. BLAH;
  527. return $sCode;
  528. }
  529. /**
  530. * Generate Block Headers row
  531. *
  532. * @param array $aInput
  533. * @return string
  534. */
  535. function genRowBlockHeader(&$aInput)
  536. {
  537. $aAttrs = empty($aInput['attrs']) ? '' : $aInput['attrs'];
  538. // if there is no caption - show divider only
  539. if (empty($aInput['caption'])) {
  540. $sCode = $this->{$this->_sSectionClose}();
  541. $sCode .= $this->{$this->_sSectionOpen}($aAttrs);
  542. return $sCode;
  543. }
  544. // if section is collapsed by default, add necessary code
  545. $sClassAddCollapsable = 'bx-form-collapsable';
  546. if (isset($aInput['collapsed']) and $aInput['collapsed'])
  547. $sClassAddCollapsable .= ' bx-form-collapsed bx-form-section-hidden';
  548. // display section with caption
  549. $sCode = $this->{$this->_sSectionClose}();
  550. if (empty($aAttrs))
  551. $aAttrs = array('class' => 'bx-form-collapsable ' . $sClassAddCollapsable);
  552. else
  553. $aAttrs['class'] .= ' bx-form-collapsable ' . $sClassAddCollapsable;
  554. if (isset($this->aParams['view_mode']) && $this->aParams['view_mode'])
  555. $sLegend = '<legend class="bx-def-padding-left bx-def-padding-sec-right bx-def-font-grayed bx-def-font-h3">' . bx_process_output($aInput['caption']) . (!empty($aInput['info']) ? '<br /><span>' . bx_process_output($aInput['info']) . '</span>' : '') . '</legend>';
  556. else
  557. $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>' . (!empty($aInput['info']) ? '<br /><span>' . bx_process_output($aInput['info']) . '</span>' : '') . '</legend>';
  558. $sCode .= $this->{$this->_sSectionOpen}($aAttrs, $sLegend);
  559. return $sCode;
  560. }
  561. function genBlockEnd()
  562. {
  563. $aNextTbodyAdd = false; // need to have some default
  564. $sCode = '';
  565. $sCode .= $this->{$this->_sSectionClose}();
  566. $sCode .= $this->{$this->_sSectionOpen}($aNextTbodyAdd);
  567. return $sCode;
  568. }
  569. /**
  570. * Generate HTML Input Element
  571. *
  572. * @param array $aInput
  573. * @return string Output HTML Code
  574. */
  575. function genInput(&$aInput)
  576. {
  577. if (!empty($aInput['name'])) {
  578. $sCustomMethod = 'genCustomInput' . $this->_genMethodName($aInput['name']);
  579. if (method_exists($this, $sCustomMethod))
  580. return $this->$sCustomMethod($aInput);
  581. }
  582. switch ($aInput['type']) {
  583. // standard inputs (and non-standard, interpreted as standard)
  584. case 'text':
  585. case 'datepicker':
  586. case 'date_time':
  587. case 'datetime':
  588. case 'number':
  589. case 'checkbox':
  590. case 'radio':
  591. case 'image':
  592. case 'password':
  593. case 'slider':
  594. case 'doublerange':
  595. case 'hidden':
  596. $sInput = $this->genInputStandard($aInput);
  597. break;
  598. case 'file':
  599. $sInput = $this->genInputFile($aInput);
  600. break;
  601. case 'rgb':
  602. case 'rgba':
  603. $sClass = 'bx-form-input-' . $aInput['type'];
  604. $aInput['attrs']['class'] = !empty($aInput['attrs']['class']) ? $aInput['attrs']['class'] . ' ' . $sClass : $sClass;
  605. $aInput['type'] = 'text';
  606. $sInput = $this->genInputStandard($aInput);
  607. break;
  608. case 'switcher':
  609. $sInput = $this->genInputSwitcher($aInput);
  610. break;
  611. case 'button':
  612. case 'reset':
  613. case 'submit':
  614. $sInput = $this->genInputButton($aInput);
  615. break;
  616. case 'textarea':
  617. $sInput = $this->genInputTextarea($aInput);
  618. break;
  619. case 'select':
  620. $sInput = $this->genInputSelect($aInput);
  621. break;
  622. case 'select_multiple':
  623. $sInput = $this->genInputSelectMultiple($aInput);
  624. break;
  625. case 'checkbox_set':
  626. $sInput = $this->genInputCheckboxSet($aInput);
  627. break;
  628. case 'radio_set':
  629. $sInput = $this->genInputRadioSet($aInput);
  630. break;
  631. case 'input_set': // numeric array of inputs
  632. $sInput = '';
  633. $sDivider = isset($aInput['dv']) ? $aInput['dv'] : ' ';
  634. foreach ($aInput as $iKey => $aSubInput) {
  635. if (!is_int($iKey) or !$aSubInput)
  636. continue; // parse only integer keys and existing values
  637. $sInput .= $this->genInput($aSubInput); // recursive call
  638. $sInput .= $sDivider;
  639. }
  640. $sInput .= '<div class="bx-clear"></div>';
  641. break;
  642. case 'custom':
  643. $sInput = isset($aInput['content']) ? $aInput['content'] : '';
  644. break;
  645. case 'captcha':
  646. $sInput = $this->genInputCaptcha($aInput);
  647. break;
  648. case 'location':
  649. $sInput = $this->genInputLocation($aInput);
  650. break;
  651. case 'value':
  652. $sInput = isset($aInput['value']) ? $aInput['value'] : '';
  653. break;
  654. default:
  655. //unknown control type
  656. $sInput = 'Unknown control type';
  657. }
  658. // create input label
  659. $sInput .= $this->genLabel($aInput);
  660. return $sInput;
  661. }
  662. /**
  663. * Generate new Input Element id
  664. *
  665. * @param array $aInput
  666. * @return string
  667. */
  668. function getInputId(&$aInput)
  669. {
  670. if (isset($aInput['id']))
  671. return $aInput['id'];
  672. $sName = md5($aInput['name']);
  673. $sID = $this->id . '_input_' . $sName;
  674. if ( // multiple elements cause identical id's
  675. (
  676. (
  677. $aInput['type'] == 'checkbox' and
  678. substr($aInput['name'], -2) == '[]' // it is multiple element
  679. ) or
  680. $aInput['type'] == 'radio' // it is always multiple (i think so... hm)
  681. ) and
  682. isset($aInput['value']) // if we can make difference
  683. ) {
  684. $sValue = md5($aInput['value']);
  685. // add value
  686. $sID .= '_' . $sValue;
  687. }
  688. $sID = trim($sID, '_');
  689. $aInput['id'] = $sID; // just for repeated calls
  690. return $sID;
  691. }
  692. /**
  693. * Generate standard Input Element
  694. *
  695. * @param array $aInput
  696. * @return string
  697. */
  698. function genInputStandard(&$aInput)
  699. {
  700. // clone attributes for system use ;)
  701. $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
  702. // add default className to attributes
  703. $aAttrs['type'] = $aInput['type'];
  704. if ('datetime' == $aAttrs['type'])
  705. $aAttrs['type'] = 'date_time';
  706. switch($aAttrs['type']) {
  707. case 'date_time':
  708. $this->addCssJsUi ();
  709. $this->addCssJsTimepicker ();
  710. break;
  711. case 'slider':
  712. case 'doublerange':
  713. case 'datepicker':
  714. $this->addCssJsUi ();
  715. break;
  716. case 'text':
  717. if (isset($aAttrs['class']) && false !== strpos($aAttrs['class'], 'bx-form-input-rgb'))
  718. $this->addCssJsMinicolors ();
  719. break;
  720. }
  721. if ('doublerange' == $aAttrs['type'] && (!isset($aInput['value']) || !$aInput['value']) && !empty($aAttrs['min']) && !empty($aAttrs['max'])) {
  722. $aInput['value'] = $aAttrs['min'] . '-' . $aAttrs['max'];
  723. }
  724. if (isset($aInput['name'])) $aAttrs['name'] = $aInput['name'];
  725. if (isset($aInput['value'])) $aAttrs['value'] = $aInput['value'];
  726. if (isset($aInput['db']['pass']) && ('DateUtc' == $aInput['db']['pass'] || 'DateTimeUtc' == $aInput['db']['pass'])) $aAttrs['data-utc'] = 1;
  727. // for inputs with labels generate id
  728. if (isset($aInput['label']))
  729. $aAttrs['id'] = $this->getInputId($aInput);
  730. // for checkboxes
  731. if (isset($aInput['checked']) and $aInput['checked'])
  732. $aAttrs['checked'] = 'checked';
  733. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-def-font-inputs bx-form-input-{$aInput['type']}");
  734. return "<input $sAttrs />\n";
  735. }
  736. /**
  737. * Generate Switcher Input Element (based on checkbox)
  738. *
  739. * @param array $aInput
  740. * @return string
  741. */
  742. function genInputSwitcher(&$aInput)
  743. {
  744. $aInput['type'] = 'checkbox';
  745. $sCheckbox = $this->genInputStandard($aInput);
  746. $aInput['type'] = 'switcher';
  747. $sClass = 'off';
  748. if (isset($aInput['checked']) and $aInput['checked'])
  749. $sClass = 'on';
  750. return '
  751. <div class="bx-switcher-cont ' . $sClass . '">' . $sCheckbox . '
  752. <div class="bx-switcher-canvas">
  753. <div class="bx-switcher-on"><i class="sys-icon check"></i></div>
  754. <div class="bx-switcher-off"><i class="sys-icon times"></i></div>
  755. <div class="bx-switcher-handler">&nbsp;</div>
  756. </div>
  757. </div>';
  758. }
  759. /**
  760. * Generate Button Input Element
  761. *
  762. * @param array $aInput
  763. * @return string
  764. */
  765. function genInputButton(&$aInput)
  766. {
  767. // clone attributes for system use ;)
  768. $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
  769. // add default className to attributes
  770. $aAttrs['type'] = $aInput['type'];
  771. if (isset($aInput['value']))
  772. $aAttrs['value'] = $aInput['value'];
  773. if (isset($aInput['name'])) $aAttrs['name'] = $aInput['name'];
  774. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-def-font-inputs bx-form-input-{$aInput['type']} bx-btn" . ('submit' == $aInput['type'] ? ' bx-btn-primary' : ''));
  775. return "<button $sAttrs>" . $aInput['value'] . "</button>\n";
  776. }
  777. /**
  778. * Generate Textarea Element
  779. *
  780. * @param array $aInput
  781. * @return string
  782. */
  783. function genInputTextarea(&$aInput)
  784. {
  785. // clone attributes for system use ;)
  786. $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
  787. $aAttrs['name'] = $aInput['name'];
  788. // for inputs with labels generate id
  789. if (isset($aInput['label']))
  790. $aAttrs['id'] = $this->getInputId($aInput);
  791. $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' : ''));
  792. $sValue = isset($aInput['value']) ? bx_process_output((isset($aInput['html']) && $aInput['html']) || (isset($aInput['code']) && $aInput['code']) ? $aInput['value'] : strip_tags($aInput['value'])) : '';
  793. return "<textarea $sAttrs>$sValue</textarea>";
  794. }
  795. function isHtmlEditor($iViewMode, &$aInput)
  796. {
  797. return BxDolEditor::getObjectInstance(false, $this->oTemplate) !== false;
  798. }
  799. function addHtmlEditor($iViewMode, &$aInput)
  800. {
  801. $oEditor = BxDolEditor::getObjectInstance(false, $this->oTemplate);
  802. if (!$oEditor)
  803. return false;
  804. $this->_sCodeAdd .= $oEditor->attachEditor ('#' . $this->aFormAttrs['id'] . ' [name='.$aInput['name'].']', $iViewMode, $this->_bDynamicMode);
  805. return true;
  806. }
  807. /**
  808. * Generate Select Box Element
  809. *
  810. * @param array $aInput
  811. * @return string
  812. */
  813. function genInputSelectBox(&$aInput, $sInfo = '', $sError = '')
  814. {
  815. $aNewInput = $aInput;
  816. $aNewInput['type'] = 'select';
  817. $aNewInput['name'] .= '[]';
  818. $sInput = $this->genInput($aNewInput);
  819. return <<<BLAH
  820. <div class="bx-form-input-wrapper input-wrapper-{$aInput['type']}">
  821. $sInput
  822. </div>
  823. $sInfo
  824. $sError
  825. BLAH;
  826. }
  827. /**
  828. * Generate Browse File Element
  829. *
  830. * @param array $aInput
  831. * @return string
  832. */
  833. function genInputFile(&$aInput)
  834. {
  835. $sOnChange = "$(this).parents('.bx-form-input-wrapper-file:first').find('.bx-fif-value').html($(this).val());";
  836. if(!empty($aInput['attrs']['onchange']))
  837. $aInput['attrs']['onchange'] = $sOnChange . $aInput['attrs']['onchange'];
  838. else
  839. $aInput['attrs']['onchange'] = $sOnChange;
  840. $sInput = $this->genInputStandard($aInput);
  841. return '<label class="bx-btn">' . $sInput . '<span class="bx-fif-label">' . _t('_sys_form_txt_select_file') . '</span></label><span class="bx-fif-value bx-def-margin-thd-left"></span>';
  842. }
  843. /**
  844. * Generate Select Box Element
  845. *
  846. * @param array $aInput
  847. * @return string
  848. */
  849. function genInputFiles(&$aInput, $sInfo = '', $sError = '')
  850. {
  851. $sUniqId = genRndPwd (8, false);
  852. $sUploaders = '';
  853. $oUploader = null;
  854. foreach ($aInput['uploaders'] as $sUploaderObject) {
  855. $oUploader = BxDolUploader::getObjectInstance($sUploaderObject, $aInput['storage_object'], $sUniqId, $this->oTemplate);
  856. if (!$oUploader)
  857. continue;
  858. $sGhostTemplate = $this->genGhostTemplate($aInput);
  859. $aAttrs = !empty($aInput['attrs']) ? $aInput['attrs'] : array();
  860. if (empty($aInput['attrs']['disabled']))
  861. $aAttrs = array_merge($aAttrs, array('onclick' => $oUploader->getNameJsInstanceUploader() . '.showUploaderForm();'));
  862. $aParams = array(
  863. 'button_title' => bx_js_string($oUploader->getUploaderButtonTitle(isset($aInput['upload_buttons_titles']) ? $aInput['upload_buttons_titles'] : false)),
  864. 'content_id' => isset($aInput['content_id']) ? $aInput['content_id'] : '',
  865. 'storage_private' => isset($aInput['storage_private']) ? $aInput['storage_private'] : '1',
  866. 'attrs' => bx_convert_array2attrs($aAttrs),
  867. 'btn_class' => !empty($aInput['attrs']['disabled']) ? 'bx-btn-disabled' : '',
  868. );
  869. if (isset($aInput['images_transcoder']) && $aInput['images_transcoder'])
  870. $aParams['images_transcoder'] = bx_js_string($aInput['images_transcoder']);
  871. $sUploaders .= $oUploader->getUploaderButton($sGhostTemplate, isset($aInput['multiple']) ? $aInput['multiple'] : true, $aParams, $this->_bDynamicMode);
  872. }
  873. return $this->oTemplate->parseHtmlByName('form_field_uploader.html', array(
  874. 'uploaders_buttons' => $sUploaders,
  875. 'info' => $sInfo,
  876. 'error' => $sError,
  877. 'id_container_errors' => $oUploader ? $oUploader->getIdContainerErrors() : '',
  878. 'id_container_result' => $oUploader ? $oUploader->getIdContainerResult() : '',
  879. 'uploader_instance_name' => $oUploader ? $oUploader->getNameJsInstanceUploader() : '',
  880. 'is_init_ghosts' => isset($aInput['init_ghosts']) && !$aInput['init_ghosts'] ? 0 : 1,
  881. ));
  882. }
  883. protected function genGhostTemplate(&$aInput)
  884. {
  885. $sGhostTemplate = false;
  886. if (isset($aInput['ghost_template']) && is_object($aInput['ghost_template'])) { // form is not submitted and ghost template is BxDolFormNested object
  887. $oFormNested = $aInput['ghost_template'];
  888. if ($oFormNested instanceof BxDolFormNested)
  889. $sGhostTemplate = $oFormNested->genForm();
  890. } 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
  891. $oFormNested = new BxDolFormNested($aInput['name'], $aInput['ghost_template'], $this->aParams['db']['submit_name'], $this->oTemplate);
  892. $sGhostTemplate = $oFormNested->getCode();
  893. } elseif (isset($aInput['ghost_template']) && is_array($aInput['ghost_template']) && $aInput['ghost_template']) { // form is submitted and ghost template is array of BxDolFormNested objects
  894. $sGhostTemplate = array ();
  895. foreach ($aInput['ghost_template'] as $iFileId => $oFormNested)
  896. if (is_object($oFormNested) && $oFormNested instanceof BxDolFormNested)
  897. $sGhostTemplate[$iFileId] = $oFormNested->genForm();
  898. } elseif (isset($aInput['ghost_template']) && is_string($aInput['ghost_template'])) { // ghost template is just string template, without nested form
  899. $sGhostTemplate = $aInput['ghost_template'];
  900. }
  901. return $sGhostTemplate;
  902. }
  903. protected function genCustomInputUsernamesSuggestions ($aInput)
  904. {
  905. $this->addCssJsUi();
  906. $sVals = '';
  907. if (!empty($aInput['value']) && is_array($aInput['value'])) {
  908. foreach ($aInput['value'] as $sVal) {
  909. if (!$sVal || !($oProfile = BxDolProfile::getInstance($sVal)))
  910. continue;
  911. $sVals .= '<b class="val bx-def-color-bg-hl bx-def-round-corners">' . $oProfile->getUnit(0, array('template' => 'unit_wo_info')) . $oProfile->getDisplayName() . '<input type="hidden" name="' . $aInput['name'] . '[]" value="' . $sVal . '" /></b>';
  912. }
  913. $sVals = trim($sVals, ',');
  914. }
  915. return $this->oTemplate->parseHtmlByName('form_field_custom_suggestions.html', array(
  916. 'id' => $aInput['name'] . time() . mt_rand(0, 100),
  917. 'url_get_recipients' => $aInput['ajax_get_suggestions'],
  918. 'name' => $aInput['name'],
  919. 'b_img' => isset($aInput['custom']['b_img']) ? (int)$aInput['custom']['b_img'] : 1,
  920. 'only_once' => isset($aInput['custom']['only_once']) ? 1 : 0,
  921. 'on_select' => isset($aInput['custom']['on_select']) ? $aInput['custom']['on_select']: 'null',
  922. 'placeholder' => bx_html_attribute(isset($aInput['placeholder']) ? $aInput['placeholder'] : _t('_sys_form_paceholder_profiles_suggestions'), BX_ESCAPE_STR_QUOTE),
  923. 'vals' => $sVals,
  924. ));
  925. }
  926. protected function genCustomViewRowValueLabels ($aInput)
  927. {
  928. if (empty($aInput['value']) || !is_array($aInput['value']) || !($oMetatags = BxDolMetatags::getObjectInstance($aInput['meta_object'])) || !$oMetatags->keywordsIsEnabled())
  929. return null;
  930. $s = '';
  931. foreach ($aInput['value'] as $sLabel)
  932. $s .= '<a href="' . $oMetatags->keywordsGetHashTagUrl($sLabel, $aInput['content_id']) . '"><b class="val bx-def-color-bg-hl bx-def-round-corners">' . trim($sLabel) . '</b></a>';
  933. return $this->oTemplate->parseHtmlByName('form_field_labels_view.html', array(
  934. 'values' => $s,
  935. ));
  936. }
  937. protected function genCustomInputLabels ($aInput)
  938. {
  939. $aValues = array();
  940. $oLabel = BxDolLabel::getInstance();
  941. $this->_getLabelOptions(0, $oLabel, $aValues);
  942. $aInput['type'] = 'select_multiple';
  943. $aInput['values'] = $aValues;
  944. return $this->genInputSelectMultiple($aInput);
  945. }
  946. protected function _getLabelOptions($iParent, &$oLabel, &$aValues)
  947. {
  948. $aLabels = $oLabel->getLabels(array('type' => 'parent', 'parent' => $iParent));
  949. foreach($aLabels as $aLabel) {
  950. $aValues[] = array('key' => $aLabel['value'], 'value' => str_repeat('&nbsp;&nbsp;&nbsp;', (int)$aLabel['level']) . ' ' . $aLabel['value']);
  951. $this->_getLabelOptions($aLabel['id'], $oLabel, $aValues);
  952. }
  953. }
  954. /*
  955. protected function genCustomInputLabels ($aInput)
  956. {
  957. // generate currently selected labels
  958. $sValue = '';
  959. if (!empty($aInput['value']) && is_array($aInput['value'])) {
  960. sort($aInput['value'], SORT_LOCALE_STRING);
  961. foreach ($aInput['value'] as $sVal) {
  962. $sValue .= '<b class="val bx-def-color-bg-hl bx-def-round-corners">' . trim($sVal) . '<input type="hidden" name="' . $aInput['name'] . '[]" value="' . trim($sVal) . '" /></b>';
  963. }
  964. $sValue = trim($sValue, ',');
  965. }
  966. // generate "following" labels
  967. $aFollowingLabels = bx_srv('bx_channels', 'get_following_channels_names', array(bx_get_logged_profile_id()));
  968. if (!is_array($aFollowingLabels))
  969. $aFollowingLabels = array();
  970. $aFollowingLabels = array_intersect($aFollowingLabels, $aInput['values']);
  971. $aFollowingLabels = array_diff($aFollowingLabels, !empty($aInput['value']) && is_array($aInput['value']) ? $aInput['value'] : array());
  972. $aValues = array_diff($aInput['values'],
  973. !empty($aInput['value']) && is_array($aInput['value']) ? $aInput['value'] : array(),
  974. !empty($aFollowingLabels) && is_array($aFollowingLabels) ? $aFollowingLabels : array());
  975. $sValues = '';
  976. if (!empty($aFollowingLabels)) {
  977. sort($aFollowingLabels, SORT_LOCALE_STRING);
  978. foreach ($aFollowingLabels as $sVal) {
  979. $sValues .= '<b class="val bx-def-color-bg-hl bx-def-round-corners">' . trim($sVal) . '</b>';
  980. }
  981. if (!empty($aValues))
  982. $sValues .= '<a href="#" class="bx-form-input-autotoken-labels-show-more">' . _t('_sys_show_more') . '</a><i class="bx-form-input-autotoken-labels-more">';
  983. }
  984. // generate all possible labels
  985. if (!empty($aValues)) {
  986. sort($aValues, SORT_LOCALE_STRING);
  987. foreach ($aValues as $sVal) {
  988. $sValues .= '<b class="val bx-def-color-bg-hl bx-def-round-corners">' . trim($sVal) . '</b>';
  989. }
  990. $sValues = trim($sValues, ',');
  991. }
  992. if (!empty($aFollowingLabels) && !empty($aValues))
  993. $sValues .= '</i>';
  994. return $this->oTemplate->parseHtmlByName('form_field_labels.html', array(
  995. 'id' => $aInput['name'] . time() . mt_rand(0, 100),
  996. 'name' => $aInput['name'],
  997. 'value' => $sValue,
  998. 'values' => $sValues,
  999. ));
  1000. }
  1001. */
  1002. /**
  1003. * Generate Select Element
  1004. *
  1005. * @param array $aInput
  1006. * @return string
  1007. */
  1008. function genInputSelect(&$aInput)
  1009. {
  1010. $sCurValue = isset($aInput['value']) ? $aInput['value'] : '';
  1011. return $this->_genInputSelect($aInput, false, $sCurValue, '_isSelected');
  1012. }
  1013. /**
  1014. * Generate Multiple Select Element
  1015. *
  1016. * @param array $aInput
  1017. * @return string
  1018. */
  1019. function genInputSelectMultiple(&$aInput)
  1020. {
  1021. $aCurValues = array();
  1022. if (isset($aInput['value']) && $aInput['value'])
  1023. $aCurValues = is_array($aInput['value']) ? $aInput['value'] : array();
  1024. return $this->_genInputSelect($aInput, true, $aCurValues, '_isSelectedMultiple');
  1025. }
  1026. /**
  1027. * Generate Checkbox Set Element
  1028. *
  1029. * @param array $aInput
  1030. * @return string
  1031. */
  1032. function genInputCheckboxSet(&$aInput)
  1033. {
  1034. $aCurValues = array();
  1035. if (isset($aInput['value']) && $aInput['value'])
  1036. $aCurValues = is_array($aInput['value']) ? $aInput['value'] : array();
  1037. return $this->_genInputsSet($aInput, 'checkbox', $aCurValues, '_isSelectedMultiple', '[]');
  1038. }
  1039. /**
  1040. * Generate Radiobuttons Set Element
  1041. *
  1042. * @param array $aInput
  1043. * @return string
  1044. */
  1045. function genInputRadioSet(&$aInput)
  1046. {
  1047. $sCurValue = isset($aInput['value']) ? $aInput['value'] : '';
  1048. return $this->_genInputsSet($aInput, 'radio', $sCurValue, '_isSelected');
  1049. }
  1050. function _isSelected ($sValue, $sCurValue)
  1051. {
  1052. return ((string)$sValue === (string)$sCurValue);
  1053. }
  1054. function _isSelectedMultiple ($sValue, $aCurValues)
  1055. {
  1056. return in_array($sValue, $aCurValues);
  1057. }
  1058. function _genInputSelect(&$aInput, $isMultiple, $mixedCurrentVal, $sIsSelectedFunc)
  1059. {
  1060. $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
  1061. $aAttrs['name'] = $aInput['name'];
  1062. if ($isMultiple) {
  1063. $aAttrs['name'] .= '[]';
  1064. $aAttrs['multiple'] = 'multiple';
  1065. }
  1066. // for inputs with labels generate id
  1067. if (isset($aInput['label']))
  1068. $aAttrs['id'] = $this->getInputId($aInput);
  1069. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-def-font-inputs bx-form-input-{$aInput['type']}");
  1070. // generate options
  1071. $sOptions = '';
  1072. if (isset($aInput['values']) and is_array($aInput['values'])) {
  1073. foreach ($aInput['values'] as $sValue => $sTitle) {
  1074. $sAttrsOpt = "";
  1075. if(is_array($sTitle)) {
  1076. if(isset($sTitle['type'])) {
  1077. switch($sTitle['type']) {
  1078. case 'group_header':
  1079. $sTitle = bx_process_output($sTitle['value']);
  1080. $sOptions .= <<<BLAH
  1081. <optgroup label="$sTitle">
  1082. BLAH;
  1083. break;
  1084. case 'group_end':
  1085. $sOptions .= <<<BLAH
  1086. </optgroup>
  1087. BLAH;
  1088. break;
  1089. }
  1090. continue;
  1091. }
  1092. $aAttrsOpt = array();
  1093. if(!empty($sTitle['attrs']) && is_array($sTitle['attrs']))
  1094. $aAttrsOpt = $sTitle['attrs'];
  1095. if(isset($sTitle['class']))
  1096. $aAttrsOpt['class'] = !empty($aAttrsOpt['class']) ? $aAttrsOpt['class'] . ' ' . $sTitle['class'] : $sTitle['class'];
  1097. if(isset($sTitle['style']))
  1098. $aAttrsOpt['style'] = !empty($aAttrsOpt['style']) ? $aAttrsOpt['style'] . ' ' . $sTitle['style'] : $sTitle['style'];
  1099. $sAttrsOpt = !empty($aAttrsOpt) ? bx_convert_array2attrs($aAttrsOpt) : '';
  1100. $sValue = $sTitle['key'];
  1101. $sTitle = $sTitle['value'];
  1102. }
  1103. $sValueC = bx_html_attribute($sValue);
  1104. $sTitleC = bx_process_output($sTitle);
  1105. $sSelected = $this->$sIsSelectedFunc($sValue, $mixedCurrentVal) ? 'selected="selected"' : '';
  1106. $sOptions .= <<<BLAH
  1107. <option value="$sValueC" $sAttrsOpt $sSelected>$sTitleC</option>
  1108. BLAH;
  1109. }
  1110. }
  1111. // generate element
  1112. $sCode = <<<BLAH
  1113. <select $sAttrs>
  1114. $sOptions
  1115. </select>
  1116. BLAH;
  1117. return $sCode;
  1118. }
  1119. function _genInputsSet(&$aInput, $sType, $mixedCurrentVal, $sIsCheckedFunc, $sNameAppend = '')
  1120. {
  1121. $aAttrs = empty($aInput['attrs']) || 'radio_set' == $aInput['type'] || 'checkbox_set' == $aInput['type'] ? array() : $aInput['attrs'];
  1122. $aAttrs['name'] = $aInput['name'];
  1123. // for inputs with labels generate id
  1124. if (isset($aInput['label']))
  1125. $aAttrs['id'] = $this->getInputId($aInput);
  1126. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-form-input-{$aInput['type']}");
  1127. // generate options
  1128. $sDivider = isset($aInput['dv']) ? $aInput['dv'] : $this->_sDivider;
  1129. $sOptions = '';
  1130. if (isset($aInput['values']) && is_array($aInput['values'])) {
  1131. if (count($aInput['values']) > 3 && $sDivider == $this->_sDivider)
  1132. $sDivider = $this->_sDividerAlt;
  1133. // generate complex input using simple standard inputs
  1134. foreach ($aInput['values'] as $sValue => $sLabel) {
  1135. if(is_array($sLabel)) {
  1136. $sValue = $sLabel['key'];
  1137. $sLabel = $sLabel['value'];
  1138. }
  1139. // create new simple input
  1140. $aNewInput = array(
  1141. 'type' => $sType,
  1142. 'name' => $aInput['name'] . $sNameAppend,
  1143. 'value' => $sValue,
  1144. 'checked' => $this->$sIsCheckedFunc($sValue, $mixedCurrentVal),
  1145. 'label' => $sLabel,
  1146. 'attrs' => !empty($aInput['attrs']) && ('radio_set' == $aInput['type'] || 'checkbox_set' == $aInput['type']) ? $aInput['attrs'] : false,
  1147. );
  1148. $sNewInput = $this->genInput($aNewInput);
  1149. // attach new input to complex
  1150. $sOptions .= ($sNewInput . $sDivider);
  1151. }
  1152. }
  1153. // generate element
  1154. $sCode = <<<BLAH
  1155. <div $sAttrs>
  1156. $sOptions
  1157. </div>
  1158. BLAH;
  1159. return $sCode;
  1160. }
  1161. function genInputLocation(&$aInput)
  1162. {
  1163. $isManualInput = (int)(isset($aInput['manual_input']) && $aInput['manual_input']);
  1164. $sIdStatus = $this->getInputId($aInput) . '_status';
  1165. $sIdInput = $this->getInputId($aInput) . '_location';
  1166. $sProto = (0 === strncmp('https', BX_DOL_URL_ROOT, 5)) ? 'https' : 'http';
  1167. $aVars = array (
  1168. 'key' => trim(getParam('sys_maps_api_key')),
  1169. 'lang' => bx_lang_name(),
  1170. 'name' => $aInput['name'],
  1171. 'id_status' => $sIdStatus,
  1172. 'id_input' => $sIdInput,
  1173. 'manual_input' => $isManualInput,
  1174. 'bx_if:manual_input' => array(
  1175. 'condition' => $isManualInput,
  1176. 'content' => array(),
  1177. ),
  1178. 'bx_if:auto_input' => array(
  1179. 'condition' => !$isManualInput,
  1180. 'content' => array(
  1181. 'id_status' => $sIdStatus,
  1182. 'location_string' => _t('_sys_location_undefined'),
  1183. ),
  1184. ),
  1185. );
  1186. $aLocationIndexes = array ('lat', 'lng', 'country', 'state', 'city', 'zip', 'street', 'street_number');
  1187. foreach ($aLocationIndexes as $sKey)
  1188. $aVars[$sKey] = $this->getLocationVal($aInput, $sKey);
  1189. if ($aVars['country']) {
  1190. $aCountries = BxDolFormQuery::getDataItems('Country');
  1191. $s = ($aVars['street_number'] ? $aVars['street_number'] . ', ' : '') . ($aVars['street'] ? $aVars['street'] . ', ' : '') . ($aVars['city'] ? $aVars['city'] . ', ' : '') . ($aVars['state'] ? $aVars['state'] . ', ' : '') . $aCountries[$aVars['country']];
  1192. $aVars['bx_if:auto_input']['content']['location_string'] = $s;
  1193. }
  1194. if ($isManualInput) {
  1195. $aInput['type'] = 'text';
  1196. $aInput['attrs']['id'] = $sIdInput;
  1197. $aVars['input'] = $this->genInputStandard($aInput);
  1198. }
  1199. else {
  1200. if ($this->getLocationVal($aInput, 'lat') && $this->getLocationVal($aInput, 'lng'))
  1201. $aInput['checked'] = true;
  1202. else
  1203. $aInput['checked'] = $this->getCleanValue($aInput['name'] . '_lat') && $this->getCleanValue($aInput['name'] . '_lng') ? 1 : 0;
  1204. $aVars['input'] = $this->genInputSwitcher($aInput);
  1205. }
  1206. return $this->oTemplate->parseHtmlByName('form_field_location.html', $aVars);
  1207. }
  1208. public function setLocationVal ($aInput, $sIndex, $sVal)
  1209. {
  1210. $s = $aInput['name'] . '_' . $sIndex;
  1211. $this->_aSpecificValues[$s] = $sVal;
  1212. }
  1213. protected function getLocationVal ($aInput, $sIndex)
  1214. {
  1215. $s = $aInput['name'] . '_' . $sIndex;
  1216. if (isset($this->_aSpecificValues[$s]))
  1217. return $this->_aSpecificValues[$s];
  1218. return $this->getCleanValue($s);
  1219. }
  1220. function genInputCaptcha(&$aInput)
  1221. {
  1222. $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
  1223. // for inputs with labels generate id
  1224. if (isset($aInput['label']))
  1225. $aAttrs['id'] = $this->getInputId($aInput);
  1226. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-form-input-{$aInput['type']}");
  1227. $oCaptcha = BxDolCaptcha::getObjectInstance();
  1228. return "<div $sAttrs>" . ($oCaptcha ? $oCaptcha->display($this->_bDynamicMode) : _t('_sys_txt_captcha_not_available')) . "</div>";
  1229. }
  1230. /**
  1231. * Generate Label Element
  1232. *
  1233. * @param string $sLabel Text of the Label
  1234. * @param string $sInputID Dependant Input Element ID
  1235. * @return string HTML code
  1236. */
  1237. function genLabel(&$aInput)
  1238. {
  1239. if (!isset($aInput['label']) or empty($aInput['label']))
  1240. return '';
  1241. $sLabel = $aInput['label'];
  1242. $sInputID = $this->getInputId($aInput);
  1243. $sRet = '<label for="' . $sInputID . '">' . bx_process_output($sLabel) . '</label>';
  1244. return $sRet;
  1245. }
  1246. function genInfoIcon($sInfo)
  1247. {
  1248. return '<div class="bx-form-info bx-def-font-grayed bx-def-font-small">' . bx_process_output($sInfo, BX_DATA_HTML) . '</div>';
  1249. }
  1250. function genErrorIcon( $sError = '' )
  1251. {
  1252. if ($this->bEnableErrorIcon) {
  1253. $sStyle = '';
  1254. if (!$sError)
  1255. $sStyle = 'style="display:none;"';
  1256. return '<div class="bx-form-warn" ' . $sStyle . '>' . $sError . '</div>';
  1257. }
  1258. }
  1259. function getOpenSection($aAttrs = array(), $sLegend = '')
  1260. {
  1261. if (!$this->_isSectionOpened) {
  1262. if (!$aAttrs || !is_array($aAttrs))
  1263. $aAttrs = array();
  1264. if ($sLegend)
  1265. $sClassesAdd = "bx-form-section-header";
  1266. else
  1267. $sClassesAdd = "bx-form-section-divider";
  1268. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-form-section bx-def-padding-sec-top bx-def-border-top " . $sClassesAdd);
  1269. $this->_isSectionOpened = true;
  1270. return "<!-- form header content begins -->\n <div class=\"bx-form-section-wrapper bx-def-margin-top\"> <div $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";
  1271. } else {
  1272. return '';
  1273. }
  1274. }
  1275. function getCloseSection()
  1276. {
  1277. if ($this->_isSectionOpened) {
  1278. $this->_isSectionOpened = false;
  1279. return "</div> </div> </div> \n<!-- form header content ends -->\n";
  1280. } else {
  1281. return '';
  1282. }
  1283. }
  1284. function getOpenSectionViewMode($aAttrs = array(), $sLegend = '')
  1285. {
  1286. if (!$this->_isSectionOpened) {
  1287. if (!$aAttrs || !is_array($aAttrs))
  1288. $aAttrs = array();
  1289. if ($sLegend)
  1290. $sClassesAdd = "bx-form-section-header";
  1291. else
  1292. $sClassesAdd = "bx-form-section-divider";
  1293. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-form-section bx-form-view-section bx-def-padding-sec-top bx-def-border-top " . $sClassesAdd);
  1294. $this->_isSectionOpened = true;
  1295. return "<!-- form header content begins -->\n <div class=\"bx-form-section-wrapper bx-def-margin-top\"> <div $sAttrs> $sLegend <div class=\"bx-form-section-content bx-def-padding-top\">\n";
  1296. } else {
  1297. return '';
  1298. }
  1299. }
  1300. function getCloseSectionViewMode()
  1301. {
  1302. if ($this->_isSectionOpened) {
  1303. $this->_isSectionOpened = false;
  1304. return "</div> </div> </div> \n<!-- form header content ends -->\n";
  1305. } else {
  1306. return '';
  1307. }
  1308. }
  1309. static function getJsUiLangs ()
  1310. {
  1311. return 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);
  1312. }
  1313. function addCssJsUi ()
  1314. {
  1315. if (self::$_isCssJsUiAdded)
  1316. return;
  1317. $aUiLangs = $this->getJsUiLangs ();
  1318. $sUiLang = BxDolLanguages::getInstance()->detectLanguageFromArray ($aUiLangs);
  1319. $this->_addJs(array(
  1320. 'jquery-ui/jquery-ui.custom.min.js',
  1321. 'jquery-ui/i18n/jquery.ui.datepicker-' . $sUiLang . '.min.js',
  1322. ), "'undefined' === typeof($.datepicker)");
  1323. $this->_addCss('jquery-ui/jquery-ui.css');
  1324. self::$_isCssJsUiAdded = true;
  1325. }
  1326. function addCssJsTimepicker ()
  1327. {
  1328. if (self::$_isCssJsTimepickerAdded)
  1329. return;
  1330. $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);
  1331. $sCalendarLang = BxDolLanguages::getInstance()->detectLanguageFromArray ($aCalendarLangs);
  1332. $this->_addCss('timepicker-addon/jquery-ui-timepicker-addon.css');
  1333. $this->_addJs(array(
  1334. 'timepicker-addon/jquery-ui-timepicker-addon.min.js',
  1335. 'timepicker-addon/jquery-ui-sliderAccess.js',
  1336. 'timepicker-addon/i18n/jquery-ui-timepicker-' . $sCalendarLang . '.js',
  1337. 'jquery.ui.touch-punch.min.js',
  1338. ), "'undefined' === typeof($.fn.datetimepicker)");
  1339. self::$_isCssJsTimepickerAdded = true;
  1340. }
  1341. function addCssJsMinicolors ()
  1342. {
  1343. if (self::$_isCssJsMinicolorsAdded)
  1344. return;
  1345. $this->_addCss(BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'jquery-minicolors/|jquery.minicolors.css');
  1346. $this->_addJs('jquery-minicolors/jquery.minicolors.min.js', "'undefined' === typeof($.minicolors)");
  1347. self::$_isCssJsMinicolorsAdded = true;
  1348. }
  1349. function addCssJsViewMode ()
  1350. {
  1351. if (self::$_isCssJsAddedViewMode)
  1352. return;
  1353. $this->_addCss('forms.css');
  1354. self::$_isCssJsAddedViewMode = true;
  1355. }
  1356. function addCssJsCore ()
  1357. {
  1358. if (self::$_isCssJsAdded)
  1359. return;
  1360. $this->_addCss('forms.css');
  1361. $this->_addJs('jquery.webForms.js', "'undefined' === typeof($.fn.addWebForms)");
  1362. self::$_isCssJsAdded = true;
  1363. }
  1364. function addCssJs ()
  1365. {
  1366. if (isset($this->aParams['view_mode']) && $this->aParams['view_mode']) {
  1367. $this->addCssJsViewMode ();
  1368. } else {
  1369. $this->addCssJsCore();
  1370. }
  1371. }
  1372. protected function _processCssJs()
  1373. {
  1374. $sRet = '';
  1375. if ($this->_bDynamicMode) {
  1376. $sRet .= $this->oTemplate->addCss($this->_aCss, true);
  1377. $sRet .= "\n<script>\n";
  1378. $sRet .= "\nglJsLoadOnaddWebForms = [];\n";
  1379. foreach ($this->_aJs as $sCondition => $aJs) {
  1380. $sJs = $this->oTemplate->addJs($aJs, true);
  1381. if (!$sJs)
  1382. continue;
  1383. $sRet .= "if ($sCondition)\n";
  1384. if (preg_match_all("/src=\"(.*?)\"/", $sJs, $aMatches))
  1385. $sRet .= "\tglJsLoadOnaddWebForms = glJsLoadOnaddWebForms.concat(" . json_encode($aMatches[1]) . ");\n";
  1386. }
  1387. $sRet .= "\n</script>\n";
  1388. }
  1389. else {
  1390. $this->oTemplate->addCss($this->_aCss);
  1391. $aJs = array();
  1392. foreach ($this->_aJs as $sCondition => $a)
  1393. $aJs = array_merge($aJs, $a);
  1394. $this->oTemplate->addJs($aJs);
  1395. }
  1396. return $sRet;
  1397. }
  1398. protected function _addJs($mixed, $sJsCondition)
  1399. {
  1400. if (!is_array($mixed))
  1401. $mixed = array($mixed);
  1402. $this->_aJs[$sJsCondition] = $mixed;
  1403. }
  1404. protected function _addCss($mixed)
  1405. {
  1406. if (!is_array($mixed))
  1407. $mixed = array($mixed);
  1408. foreach ($mixed as $s)
  1409. $this->_aCss[$s] = $s;
  1410. }
  1411. }
  1412. /** @} */