1
0

BxBaseFormView.php 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742
  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 'time':
  590. case 'checkbox':
  591. case 'radio':
  592. case 'image':
  593. case 'password':
  594. case 'slider':
  595. case 'doublerange':
  596. case 'hidden':
  597. $sInput = $this->genInputStandard($aInput);
  598. break;
  599. case 'file':
  600. $sInput = $this->genInputFile($aInput);
  601. break;
  602. case 'rgb':
  603. case 'rgba':
  604. $sClass = 'bx-form-input-' . $aInput['type'];
  605. $aInput['attrs']['class'] = !empty($aInput['attrs']['class']) ? $aInput['attrs']['class'] . ' ' . $sClass : $sClass;
  606. $aInput['type'] = 'text';
  607. $sInput = $this->genInputStandard($aInput);
  608. break;
  609. case 'switcher':
  610. $sInput = $this->genInputSwitcher($aInput);
  611. break;
  612. case 'button':
  613. case 'reset':
  614. case 'submit':
  615. $sInput = $this->genInputButton($aInput);
  616. break;
  617. case 'textarea':
  618. $sInput = $this->genInputTextarea($aInput);
  619. break;
  620. case 'select':
  621. $sInput = $this->genInputSelect($aInput);
  622. break;
  623. case 'select_multiple':
  624. $sInput = $this->genInputSelectMultiple($aInput);
  625. break;
  626. case 'checkbox_set':
  627. $sInput = $this->genInputCheckboxSet($aInput);
  628. break;
  629. case 'radio_set':
  630. $sInput = $this->genInputRadioSet($aInput);
  631. break;
  632. case 'input_set': // numeric array of inputs
  633. $sInput = '';
  634. $sDivider = isset($aInput['dv']) ? $aInput['dv'] : ' ';
  635. foreach ($aInput as $iKey => $aSubInput) {
  636. if (!is_int($iKey) or !$aSubInput)
  637. continue; // parse only integer keys and existing values
  638. $sInput .= $this->genInput($aSubInput); // recursive call
  639. $sInput .= $sDivider;
  640. }
  641. $sInput .= '<div class="bx-clear"></div>';
  642. break;
  643. case 'custom':
  644. $sInput = isset($aInput['content']) ? $aInput['content'] : '';
  645. break;
  646. case 'captcha':
  647. $sInput = $this->genInputCaptcha($aInput);
  648. break;
  649. case 'location':
  650. $sInput = $this->genInputLocation($aInput);
  651. break;
  652. case 'value':
  653. $sInput = isset($aInput['value']) ? $aInput['value'] : '';
  654. break;
  655. default:
  656. //unknown control type
  657. $sInput = 'Unknown control type';
  658. }
  659. // create input label
  660. $sInput .= $this->genLabel($aInput);
  661. return $sInput;
  662. }
  663. /**
  664. * Generate new Input Element id
  665. *
  666. * @param array $aInput
  667. * @return string
  668. */
  669. function getInputId(&$aInput)
  670. {
  671. if (isset($aInput['id']))
  672. return $aInput['id'];
  673. $sName = md5($aInput['name']);
  674. $sID = $this->id . '_input_' . $sName;
  675. if ( // multiple elements cause identical id's
  676. (
  677. (
  678. $aInput['type'] == 'checkbox' and
  679. substr($aInput['name'], -2) == '[]' // it is multiple element
  680. ) or
  681. $aInput['type'] == 'radio' // it is always multiple (i think so... hm)
  682. ) and
  683. isset($aInput['value']) // if we can make difference
  684. ) {
  685. $sValue = md5($aInput['value']);
  686. // add value
  687. $sID .= '_' . $sValue;
  688. }
  689. $sID = trim($sID, '_');
  690. $aInput['id'] = $sID; // just for repeated calls
  691. return $sID;
  692. }
  693. /**
  694. * Generate standard Input Element
  695. *
  696. * @param array $aInput
  697. * @return string
  698. */
  699. function genInputStandard(&$aInput)
  700. {
  701. // clone attributes for system use ;)
  702. $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
  703. // add default className to attributes
  704. $aAttrs['type'] = $aInput['type'];
  705. if ('datetime' == $aAttrs['type'])
  706. $aAttrs['type'] = 'date_time';
  707. switch($aAttrs['type']) {
  708. case 'date_time':
  709. $this->addCssJsUi ();
  710. $this->addCssJsTimepicker ();
  711. break;
  712. case 'slider':
  713. case 'doublerange':
  714. case 'datepicker':
  715. $this->addCssJsUi ();
  716. break;
  717. case 'text':
  718. if (isset($aAttrs['class']) && false !== strpos($aAttrs['class'], 'bx-form-input-rgb'))
  719. $this->addCssJsMinicolors ();
  720. break;
  721. }
  722. if ('doublerange' == $aAttrs['type'] && (!isset($aInput['value']) || !$aInput['value']) && !empty($aAttrs['min']) && !empty($aAttrs['max'])) {
  723. $aInput['value'] = $aAttrs['min'] . '-' . $aAttrs['max'];
  724. }
  725. if (isset($aInput['name'])) $aAttrs['name'] = $aInput['name'];
  726. if (isset($aInput['value'])) $aAttrs['value'] = $aInput['value'];
  727. if (isset($aInput['db']['pass']) && ('DateUtc' == $aInput['db']['pass'] || 'DateTimeUtc' == $aInput['db']['pass'])) $aAttrs['data-utc'] = 1;
  728. // for inputs with labels generate id
  729. if (isset($aInput['label']))
  730. $aAttrs['id'] = $this->getInputId($aInput);
  731. // for checkboxes
  732. if (isset($aInput['checked']) and $aInput['checked'])
  733. $aAttrs['checked'] = 'checked';
  734. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-def-font-inputs bx-form-input-{$aInput['type']}");
  735. return "<input $sAttrs />\n";
  736. }
  737. /**
  738. * Generate Switcher Input Element (based on checkbox)
  739. *
  740. * @param array $aInput
  741. * @return string
  742. */
  743. function genInputSwitcher(&$aInput)
  744. {
  745. $aInput['type'] = 'checkbox';
  746. $sCheckbox = $this->genInputStandard($aInput);
  747. $aInput['type'] = 'switcher';
  748. $sClass = 'off';
  749. if (isset($aInput['checked']) and $aInput['checked'])
  750. $sClass = 'on';
  751. return '
  752. <div class="bx-switcher-cont ' . $sClass . '">' . $sCheckbox . '
  753. <div class="bx-switcher-canvas">
  754. <div class="bx-switcher-on"><i class="sys-icon check"></i></div>
  755. <div class="bx-switcher-off"><i class="sys-icon times"></i></div>
  756. <div class="bx-switcher-handler">&nbsp;</div>
  757. </div>
  758. </div>';
  759. }
  760. /**
  761. * Generate Button Input Element
  762. *
  763. * @param array $aInput
  764. * @return string
  765. */
  766. function genInputButton(&$aInput)
  767. {
  768. // clone attributes for system use ;)
  769. $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
  770. // add default className to attributes
  771. $aAttrs['type'] = $aInput['type'];
  772. if (isset($aInput['value']))
  773. $aAttrs['value'] = $aInput['value'];
  774. if (isset($aInput['name'])) $aAttrs['name'] = $aInput['name'];
  775. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-def-font-inputs bx-form-input-{$aInput['type']} bx-btn" . ('submit' == $aInput['type'] ? ' bx-btn-primary' : ''));
  776. return "<button $sAttrs>" . $aInput['value'] . "</button>\n";
  777. }
  778. /**
  779. * Generate Textarea Element
  780. *
  781. * @param array $aInput
  782. * @return string
  783. */
  784. function genInputTextarea(&$aInput)
  785. {
  786. // clone attributes for system use ;)
  787. $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
  788. $aAttrs['name'] = $aInput['name'];
  789. // for inputs with labels generate id
  790. if (isset($aInput['label']))
  791. $aAttrs['id'] = $this->getInputId($aInput);
  792. $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' : ''));
  793. $sValue = isset($aInput['value']) ? bx_process_output((isset($aInput['html']) && $aInput['html']) || (isset($aInput['code']) && $aInput['code']) ? $aInput['value'] : strip_tags($aInput['value'])) : '';
  794. return "<textarea $sAttrs>$sValue</textarea>";
  795. }
  796. function isHtmlEditor($iViewMode, &$aInput)
  797. {
  798. return BxDolEditor::getObjectInstance(false, $this->oTemplate) !== false;
  799. }
  800. function addHtmlEditor($iViewMode, &$aInput)
  801. {
  802. $oEditor = BxDolEditor::getObjectInstance(false, $this->oTemplate);
  803. if (!$oEditor)
  804. return false;
  805. $this->_sCodeAdd .= $oEditor->attachEditor ('#' . $this->aFormAttrs['id'] . ' [name='.$aInput['name'].']', $iViewMode, $this->_bDynamicMode);
  806. return true;
  807. }
  808. /**
  809. * Generate Select Box Element
  810. *
  811. * @param array $aInput
  812. * @return string
  813. */
  814. function genInputSelectBox(&$aInput, $sInfo = '', $sError = '')
  815. {
  816. $aNewInput = $aInput;
  817. $aNewInput['type'] = 'select';
  818. $aNewInput['name'] .= '[]';
  819. $sInput = $this->genInput($aNewInput);
  820. return <<<BLAH
  821. <div class="bx-form-input-wrapper input-wrapper-{$aInput['type']}">
  822. $sInput
  823. </div>
  824. $sInfo
  825. $sError
  826. BLAH;
  827. }
  828. /**
  829. * Generate Browse File Element
  830. *
  831. * @param array $aInput
  832. * @return string
  833. */
  834. function genInputFile(&$aInput)
  835. {
  836. $sOnChange = "$(this).parents('.bx-form-input-wrapper-file:first').find('.bx-fif-value').html($(this).val());";
  837. if(!empty($aInput['attrs']['onchange']))
  838. $aInput['attrs']['onchange'] = $sOnChange . $aInput['attrs']['onchange'];
  839. else
  840. $aInput['attrs']['onchange'] = $sOnChange;
  841. $sInput = $this->genInputStandard($aInput);
  842. 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>';
  843. }
  844. /**
  845. * Generate Select Box Element
  846. *
  847. * @param array $aInput
  848. * @return string
  849. */
  850. function genInputFiles(&$aInput, $sInfo = '', $sError = '')
  851. {
  852. $sUniqId = genRndPwd (8, false);
  853. $sUploaders = '';
  854. $oUploader = null;
  855. foreach ($aInput['uploaders'] as $sUploaderObject) {
  856. $oUploader = BxDolUploader::getObjectInstance($sUploaderObject, $aInput['storage_object'], $sUniqId, $this->oTemplate);
  857. if (!$oUploader)
  858. continue;
  859. $sGhostTemplate = $this->genGhostTemplate($aInput);
  860. $aAttrs = !empty($aInput['attrs']) ? $aInput['attrs'] : array();
  861. if (empty($aInput['attrs']['disabled']))
  862. $aAttrs = array_merge($aAttrs, array('onclick' => $oUploader->getNameJsInstanceUploader() . '.showUploaderForm();'));
  863. $aParams = array(
  864. 'button_title' => bx_js_string($oUploader->getUploaderButtonTitle(isset($aInput['upload_buttons_titles']) ? $aInput['upload_buttons_titles'] : false)),
  865. 'content_id' => isset($aInput['content_id']) ? $aInput['content_id'] : '',
  866. 'storage_private' => isset($aInput['storage_private']) ? $aInput['storage_private'] : '1',
  867. 'attrs' => bx_convert_array2attrs($aAttrs),
  868. 'btn_class' => !empty($aInput['attrs']['disabled']) ? 'bx-btn-disabled' : '',
  869. );
  870. if (isset($aInput['images_transcoder']) && $aInput['images_transcoder'])
  871. $aParams['images_transcoder'] = bx_js_string($aInput['images_transcoder']);
  872. $sUploaders .= $oUploader->getUploaderButton($sGhostTemplate, isset($aInput['multiple']) ? $aInput['multiple'] : true, $aParams, $this->_bDynamicMode);
  873. }
  874. return $this->oTemplate->parseHtmlByName('form_field_uploader.html', array(
  875. 'uploaders_buttons' => $sUploaders,
  876. 'info' => $sInfo,
  877. 'error' => $sError,
  878. 'id_container_errors' => $oUploader ? $oUploader->getIdContainerErrors() : '',
  879. 'id_container_result' => $oUploader ? $oUploader->getIdContainerResult() : '',
  880. 'uploader_instance_name' => $oUploader ? $oUploader->getNameJsInstanceUploader() : '',
  881. 'is_init_ghosts' => isset($aInput['init_ghosts']) && !$aInput['init_ghosts'] ? 0 : 1,
  882. ));
  883. }
  884. protected function genGhostTemplate(&$aInput)
  885. {
  886. $sGhostTemplate = false;
  887. if (isset($aInput['ghost_template']) && is_object($aInput['ghost_template'])) { // form is not submitted and ghost template is BxDolFormNested object
  888. $oFormNested = $aInput['ghost_template'];
  889. if ($oFormNested instanceof BxDolFormNested)
  890. $sGhostTemplate = $oFormNested->genForm();
  891. } 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
  892. $oFormNested = new BxDolFormNested($aInput['name'], $aInput['ghost_template'], $this->aParams['db']['submit_name'], $this->oTemplate);
  893. $sGhostTemplate = $oFormNested->getCode();
  894. } elseif (isset($aInput['ghost_template']) && is_array($aInput['ghost_template']) && $aInput['ghost_template']) { // form is submitted and ghost template is array of BxDolFormNested objects
  895. $sGhostTemplate = array ();
  896. foreach ($aInput['ghost_template'] as $iFileId => $oFormNested)
  897. if (is_object($oFormNested) && $oFormNested instanceof BxDolFormNested)
  898. $sGhostTemplate[$iFileId] = $oFormNested->genForm();
  899. } elseif (isset($aInput['ghost_template']) && is_string($aInput['ghost_template'])) { // ghost template is just string template, without nested form
  900. $sGhostTemplate = $aInput['ghost_template'];
  901. }
  902. return $sGhostTemplate;
  903. }
  904. protected function genCustomInputUsernamesSuggestions ($aInput)
  905. {
  906. $this->addCssJsUi();
  907. $sVals = '';
  908. if (!empty($aInput['value']) && is_array($aInput['value'])) {
  909. foreach ($aInput['value'] as $sVal) {
  910. if (!$sVal || !($oProfile = BxDolProfile::getInstance($sVal)))
  911. continue;
  912. $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>';
  913. }
  914. $sVals = trim($sVals, ',');
  915. }
  916. return $this->oTemplate->parseHtmlByName('form_field_custom_suggestions.html', array(
  917. 'id' => $aInput['name'] . time() . mt_rand(0, 100),
  918. 'url_get_recipients' => $aInput['ajax_get_suggestions'],
  919. 'name' => $aInput['name'],
  920. 'b_img' => isset($aInput['custom']['b_img']) ? (int)$aInput['custom']['b_img'] : 1,
  921. 'only_once' => isset($aInput['custom']['only_once']) ? 1 : 0,
  922. 'on_select' => isset($aInput['custom']['on_select']) ? $aInput['custom']['on_select']: 'null',
  923. 'placeholder' => bx_html_attribute(isset($aInput['placeholder']) ? $aInput['placeholder'] : _t('_sys_form_paceholder_profiles_suggestions'), BX_ESCAPE_STR_QUOTE),
  924. 'vals' => $sVals,
  925. ));
  926. }
  927. protected function genCustomViewRowValueLabels ($aInput)
  928. {
  929. if (empty($aInput['value']) || !is_array($aInput['value']) || !($oMetatags = BxDolMetatags::getObjectInstance($aInput['meta_object'])) || !$oMetatags->keywordsIsEnabled())
  930. return null;
  931. $s = '';
  932. foreach ($aInput['value'] as $sLabel)
  933. $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>';
  934. return $this->oTemplate->parseHtmlByName('form_field_labels_view.html', array(
  935. 'values' => $s,
  936. ));
  937. }
  938. protected function genCustomInputLabels ($aInput)
  939. {
  940. $aValues = array();
  941. $oLabel = BxDolLabel::getInstance();
  942. $this->_getLabelOptions(0, $oLabel, $aValues);
  943. $aInput['type'] = 'select_multiple';
  944. $aInput['values'] = $aValues;
  945. return $this->genInputSelectMultiple($aInput);
  946. }
  947. protected function _getLabelOptions($iParent, &$oLabel, &$aValues)
  948. {
  949. $aLabels = $oLabel->getLabels(array('type' => 'parent', 'parent' => $iParent));
  950. foreach($aLabels as $aLabel) {
  951. $aValues[] = array('key' => $aLabel['value'], 'value' => str_repeat('&nbsp;&nbsp;&nbsp;', (int)$aLabel['level']) . ' ' . $aLabel['value']);
  952. $this->_getLabelOptions($aLabel['id'], $oLabel, $aValues);
  953. }
  954. }
  955. /*
  956. protected function genCustomInputLabels ($aInput)
  957. {
  958. // generate currently selected labels
  959. $sValue = '';
  960. if (!empty($aInput['value']) && is_array($aInput['value'])) {
  961. sort($aInput['value'], SORT_LOCALE_STRING);
  962. foreach ($aInput['value'] as $sVal) {
  963. $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>';
  964. }
  965. $sValue = trim($sValue, ',');
  966. }
  967. // generate "following" labels
  968. $aFollowingLabels = bx_srv('bx_channels', 'get_following_channels_names', array(bx_get_logged_profile_id()));
  969. if (!is_array($aFollowingLabels))
  970. $aFollowingLabels = array();
  971. $aFollowingLabels = array_intersect($aFollowingLabels, $aInput['values']);
  972. $aFollowingLabels = array_diff($aFollowingLabels, !empty($aInput['value']) && is_array($aInput['value']) ? $aInput['value'] : array());
  973. $aValues = array_diff($aInput['values'],
  974. !empty($aInput['value']) && is_array($aInput['value']) ? $aInput['value'] : array(),
  975. !empty($aFollowingLabels) && is_array($aFollowingLabels) ? $aFollowingLabels : array());
  976. $sValues = '';
  977. if (!empty($aFollowingLabels)) {
  978. sort($aFollowingLabels, SORT_LOCALE_STRING);
  979. foreach ($aFollowingLabels as $sVal) {
  980. $sValues .= '<b class="val bx-def-color-bg-hl bx-def-round-corners">' . trim($sVal) . '</b>';
  981. }
  982. if (!empty($aValues))
  983. $sValues .= '<a href="#" class="bx-form-input-autotoken-labels-show-more">' . _t('_sys_show_more') . '</a><i class="bx-form-input-autotoken-labels-more">';
  984. }
  985. // generate all possible labels
  986. if (!empty($aValues)) {
  987. sort($aValues, SORT_LOCALE_STRING);
  988. foreach ($aValues as $sVal) {
  989. $sValues .= '<b class="val bx-def-color-bg-hl bx-def-round-corners">' . trim($sVal) . '</b>';
  990. }
  991. $sValues = trim($sValues, ',');
  992. }
  993. if (!empty($aFollowingLabels) && !empty($aValues))
  994. $sValues .= '</i>';
  995. return $this->oTemplate->parseHtmlByName('form_field_labels.html', array(
  996. 'id' => $aInput['name'] . time() . mt_rand(0, 100),
  997. 'name' => $aInput['name'],
  998. 'value' => $sValue,
  999. 'values' => $sValues,
  1000. ));
  1001. }
  1002. */
  1003. /**
  1004. * Generate Select Element
  1005. *
  1006. * @param array $aInput
  1007. * @return string
  1008. */
  1009. function genInputSelect(&$aInput)
  1010. {
  1011. $sCurValue = isset($aInput['value']) ? $aInput['value'] : '';
  1012. return $this->_genInputSelect($aInput, false, $sCurValue, '_isSelected');
  1013. }
  1014. /**
  1015. * Generate Multiple Select Element
  1016. *
  1017. * @param array $aInput
  1018. * @return string
  1019. */
  1020. function genInputSelectMultiple(&$aInput)
  1021. {
  1022. $aCurValues = array();
  1023. if (isset($aInput['value']) && $aInput['value'])
  1024. $aCurValues = is_array($aInput['value']) ? $aInput['value'] : array();
  1025. return $this->_genInputSelect($aInput, true, $aCurValues, '_isSelectedMultiple');
  1026. }
  1027. /**
  1028. * Generate Checkbox Set Element
  1029. *
  1030. * @param array $aInput
  1031. * @return string
  1032. */
  1033. function genInputCheckboxSet(&$aInput)
  1034. {
  1035. $aCurValues = array();
  1036. if (isset($aInput['value']) && $aInput['value'])
  1037. $aCurValues = is_array($aInput['value']) ? $aInput['value'] : array();
  1038. return $this->_genInputsSet($aInput, 'checkbox', $aCurValues, '_isSelectedMultiple', '[]');
  1039. }
  1040. /**
  1041. * Generate Radiobuttons Set Element
  1042. *
  1043. * @param array $aInput
  1044. * @return string
  1045. */
  1046. function genInputRadioSet(&$aInput)
  1047. {
  1048. $sCurValue = isset($aInput['value']) ? $aInput['value'] : '';
  1049. return $this->_genInputsSet($aInput, 'radio', $sCurValue, '_isSelected');
  1050. }
  1051. function _isSelected ($sValue, $sCurValue)
  1052. {
  1053. return ((string)$sValue === (string)$sCurValue);
  1054. }
  1055. function _isSelectedMultiple ($sValue, $aCurValues)
  1056. {
  1057. return in_array($sValue, $aCurValues);
  1058. }
  1059. function _genInputSelect(&$aInput, $isMultiple, $mixedCurrentVal, $sIsSelectedFunc)
  1060. {
  1061. $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
  1062. $aAttrs['name'] = $aInput['name'];
  1063. if ($isMultiple) {
  1064. $aAttrs['name'] .= '[]';
  1065. $aAttrs['multiple'] = 'multiple';
  1066. }
  1067. // for inputs with labels generate id
  1068. if (isset($aInput['label']))
  1069. $aAttrs['id'] = $this->getInputId($aInput);
  1070. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-def-font-inputs bx-form-input-{$aInput['type']}");
  1071. // generate options
  1072. $sOptions = '';
  1073. if (isset($aInput['values']) and is_array($aInput['values'])) {
  1074. foreach ($aInput['values'] as $sValue => $sTitle) {
  1075. $sAttrsOpt = "";
  1076. if(is_array($sTitle)) {
  1077. if(isset($sTitle['type'])) {
  1078. switch($sTitle['type']) {
  1079. case 'group_header':
  1080. $sTitle = bx_process_output($sTitle['value']);
  1081. $sOptions .= <<<BLAH
  1082. <optgroup label="$sTitle">
  1083. BLAH;
  1084. break;
  1085. case 'group_end':
  1086. $sOptions .= <<<BLAH
  1087. </optgroup>
  1088. BLAH;
  1089. break;
  1090. }
  1091. continue;
  1092. }
  1093. $aAttrsOpt = array();
  1094. if(!empty($sTitle['attrs']) && is_array($sTitle['attrs']))
  1095. $aAttrsOpt = $sTitle['attrs'];
  1096. if(isset($sTitle['class']))
  1097. $aAttrsOpt['class'] = !empty($aAttrsOpt['class']) ? $aAttrsOpt['class'] . ' ' . $sTitle['class'] : $sTitle['class'];
  1098. if(isset($sTitle['style']))
  1099. $aAttrsOpt['style'] = !empty($aAttrsOpt['style']) ? $aAttrsOpt['style'] . ' ' . $sTitle['style'] : $sTitle['style'];
  1100. $sAttrsOpt = !empty($aAttrsOpt) ? bx_convert_array2attrs($aAttrsOpt) : '';
  1101. $sValue = $sTitle['key'];
  1102. $sTitle = $sTitle['value'];
  1103. }
  1104. $sValueC = bx_html_attribute($sValue);
  1105. $sTitleC = bx_process_output($sTitle);
  1106. $sSelected = $this->$sIsSelectedFunc($sValue, $mixedCurrentVal) ? 'selected="selected"' : '';
  1107. $sOptions .= <<<BLAH
  1108. <option value="$sValueC" $sAttrsOpt $sSelected>$sTitleC</option>
  1109. BLAH;
  1110. }
  1111. }
  1112. // generate element
  1113. $sCode = <<<BLAH
  1114. <select $sAttrs>
  1115. $sOptions
  1116. </select>
  1117. BLAH;
  1118. return $sCode;
  1119. }
  1120. function _genInputsSet(&$aInput, $sType, $mixedCurrentVal, $sIsCheckedFunc, $sNameAppend = '')
  1121. {
  1122. $aAttrs = empty($aInput['attrs']) || 'radio_set' == $aInput['type'] || 'checkbox_set' == $aInput['type'] ? array() : $aInput['attrs'];
  1123. $aAttrs['name'] = $aInput['name'];
  1124. // for inputs with labels generate id
  1125. if (isset($aInput['label']))
  1126. $aAttrs['id'] = $this->getInputId($aInput);
  1127. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-form-input-{$aInput['type']}");
  1128. // generate options
  1129. $sDivider = isset($aInput['dv']) ? $aInput['dv'] : $this->_sDivider;
  1130. $sOptions = '';
  1131. if (isset($aInput['values']) && is_array($aInput['values'])) {
  1132. if (count($aInput['values']) > 3 && $sDivider == $this->_sDivider)
  1133. $sDivider = $this->_sDividerAlt;
  1134. // generate complex input using simple standard inputs
  1135. foreach ($aInput['values'] as $sValue => $sLabel) {
  1136. if(is_array($sLabel)) {
  1137. $sValue = $sLabel['key'];
  1138. $sLabel = $sLabel['value'];
  1139. }
  1140. // create new simple input
  1141. $aNewInput = array(
  1142. 'type' => $sType,
  1143. 'name' => $aInput['name'] . $sNameAppend,
  1144. 'value' => $sValue,
  1145. 'checked' => $this->$sIsCheckedFunc($sValue, $mixedCurrentVal),
  1146. 'label' => $sLabel,
  1147. 'attrs' => !empty($aInput['attrs']) && ('radio_set' == $aInput['type'] || 'checkbox_set' == $aInput['type']) ? $aInput['attrs'] : false,
  1148. );
  1149. $sNewInput = $this->genInput($aNewInput);
  1150. // attach new input to complex
  1151. $sOptions .= ($sNewInput . $sDivider);
  1152. }
  1153. }
  1154. // generate element
  1155. $sCode = <<<BLAH
  1156. <div $sAttrs>
  1157. $sOptions
  1158. </div>
  1159. BLAH;
  1160. return $sCode;
  1161. }
  1162. function genInputLocation(&$aInput)
  1163. {
  1164. $isManualInput = (int)(isset($aInput['manual_input']) && $aInput['manual_input']);
  1165. $sIdStatus = $this->getInputId($aInput) . '_status';
  1166. $sIdInput = $this->getInputId($aInput) . '_location';
  1167. $sProto = (0 === strncmp('https', BX_DOL_URL_ROOT, 5)) ? 'https' : 'http';
  1168. $aVars = array (
  1169. 'key' => trim(getParam('sys_maps_api_key')),
  1170. 'lang' => bx_lang_name(),
  1171. 'name' => $aInput['name'],
  1172. 'id_status' => $sIdStatus,
  1173. 'id_input' => $sIdInput,
  1174. 'manual_input' => $isManualInput,
  1175. 'bx_if:manual_input' => array(
  1176. 'condition' => $isManualInput,
  1177. 'content' => array(),
  1178. ),
  1179. 'bx_if:auto_input' => array(
  1180. 'condition' => !$isManualInput,
  1181. 'content' => array(
  1182. 'id_status' => $sIdStatus,
  1183. 'location_string' => _t('_sys_location_undefined'),
  1184. ),
  1185. ),
  1186. );
  1187. $aLocationIndexes = array ('lat', 'lng', 'country', 'state', 'city', 'zip', 'street', 'street_number');
  1188. foreach ($aLocationIndexes as $sKey)
  1189. $aVars[$sKey] = $this->getLocationVal($aInput, $sKey);
  1190. if ($aVars['country']) {
  1191. $aCountries = BxDolFormQuery::getDataItems('Country');
  1192. $s = ($aVars['street_number'] ? $aVars['street_number'] . ', ' : '') . ($aVars['street'] ? $aVars['street'] . ', ' : '') . ($aVars['city'] ? $aVars['city'] . ', ' : '') . ($aVars['state'] ? $aVars['state'] . ', ' : '') . $aCountries[$aVars['country']];
  1193. $aVars['bx_if:auto_input']['content']['location_string'] = $s;
  1194. }
  1195. if ($isManualInput) {
  1196. $aInput['type'] = 'text';
  1197. $aInput['attrs']['id'] = $sIdInput;
  1198. $aVars['input'] = $this->genInputStandard($aInput);
  1199. }
  1200. else {
  1201. if ($this->getLocationVal($aInput, 'lat') && $this->getLocationVal($aInput, 'lng'))
  1202. $aInput['checked'] = true;
  1203. else
  1204. $aInput['checked'] = $this->getCleanValue($aInput['name'] . '_lat') && $this->getCleanValue($aInput['name'] . '_lng') ? 1 : 0;
  1205. $aVars['input'] = $this->genInputSwitcher($aInput);
  1206. }
  1207. return $this->oTemplate->parseHtmlByName('form_field_location.html', $aVars);
  1208. }
  1209. public function setLocationVal ($aInput, $sIndex, $sVal)
  1210. {
  1211. $s = $aInput['name'] . '_' . $sIndex;
  1212. $this->_aSpecificValues[$s] = $sVal;
  1213. }
  1214. protected function getLocationVal ($aInput, $sIndex)
  1215. {
  1216. $s = $aInput['name'] . '_' . $sIndex;
  1217. if (isset($this->_aSpecificValues[$s]))
  1218. return $this->_aSpecificValues[$s];
  1219. return $this->getCleanValue($s);
  1220. }
  1221. function genInputCaptcha(&$aInput)
  1222. {
  1223. $aAttrs = empty($aInput['attrs']) ? array() : $aInput['attrs'];
  1224. // for inputs with labels generate id
  1225. if (isset($aInput['label']))
  1226. $aAttrs['id'] = $this->getInputId($aInput);
  1227. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-form-input-{$aInput['type']}");
  1228. $oCaptcha = BxDolCaptcha::getObjectInstance();
  1229. return "<div $sAttrs>" . ($oCaptcha ? $oCaptcha->display($this->_bDynamicMode) : _t('_sys_txt_captcha_not_available')) . "</div>";
  1230. }
  1231. /**
  1232. * Generate Label Element
  1233. *
  1234. * @param string $sLabel Text of the Label
  1235. * @param string $sInputID Dependant Input Element ID
  1236. * @return string HTML code
  1237. */
  1238. function genLabel(&$aInput)
  1239. {
  1240. if (!isset($aInput['label']) or empty($aInput['label']))
  1241. return '';
  1242. $sLabel = $aInput['label'];
  1243. $sInputID = $this->getInputId($aInput);
  1244. $sRet = '<label for="' . $sInputID . '">' . bx_process_output($sLabel) . '</label>';
  1245. return $sRet;
  1246. }
  1247. function genInfoIcon($sInfo)
  1248. {
  1249. return '<div class="bx-form-info bx-def-font-grayed bx-def-font-small">' . bx_process_output($sInfo, BX_DATA_HTML) . '</div>';
  1250. }
  1251. function genErrorIcon( $sError = '' )
  1252. {
  1253. if ($this->bEnableErrorIcon) {
  1254. $sStyle = '';
  1255. if (!$sError)
  1256. $sStyle = 'style="display:none;"';
  1257. return '<div class="bx-form-warn" ' . $sStyle . '>' . $sError . '</div>';
  1258. }
  1259. }
  1260. function getOpenSection($aAttrs = array(), $sLegend = '')
  1261. {
  1262. if (!$this->_isSectionOpened) {
  1263. if (!$aAttrs || !is_array($aAttrs))
  1264. $aAttrs = array();
  1265. if ($sLegend)
  1266. $sClassesAdd = "bx-form-section-header";
  1267. else
  1268. $sClassesAdd = "bx-form-section-divider";
  1269. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-form-section bx-def-padding-sec-top bx-def-border-top " . $sClassesAdd);
  1270. $this->_isSectionOpened = true;
  1271. 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";
  1272. } else {
  1273. return '';
  1274. }
  1275. }
  1276. function getCloseSection()
  1277. {
  1278. if ($this->_isSectionOpened) {
  1279. $this->_isSectionOpened = false;
  1280. return "</div> </div> </div> \n<!-- form header content ends -->\n";
  1281. } else {
  1282. return '';
  1283. }
  1284. }
  1285. function getOpenSectionViewMode($aAttrs = array(), $sLegend = '')
  1286. {
  1287. if (!$this->_isSectionOpened) {
  1288. if (!$aAttrs || !is_array($aAttrs))
  1289. $aAttrs = array();
  1290. if ($sLegend)
  1291. $sClassesAdd = "bx-form-section-header";
  1292. else
  1293. $sClassesAdd = "bx-form-section-divider";
  1294. $sAttrs = bx_convert_array2attrs($aAttrs, "bx-form-section bx-form-view-section bx-def-padding-sec-top bx-def-border-top " . $sClassesAdd);
  1295. $this->_isSectionOpened = true;
  1296. 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";
  1297. } else {
  1298. return '';
  1299. }
  1300. }
  1301. function getCloseSectionViewMode()
  1302. {
  1303. if ($this->_isSectionOpened) {
  1304. $this->_isSectionOpened = false;
  1305. return "</div> </div> </div> \n<!-- form header content ends -->\n";
  1306. } else {
  1307. return '';
  1308. }
  1309. }
  1310. static function getJsUiLangs ()
  1311. {
  1312. 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);
  1313. }
  1314. function addCssJsUi ()
  1315. {
  1316. if (self::$_isCssJsUiAdded)
  1317. return;
  1318. $aUiLangs = $this->getJsUiLangs ();
  1319. $sUiLang = BxDolLanguages::getInstance()->detectLanguageFromArray ($aUiLangs);
  1320. $this->_addJs(array(
  1321. 'jquery-ui/jquery-ui.custom.min.js',
  1322. 'jquery-ui/i18n/jquery.ui.datepicker-' . $sUiLang . '.min.js',
  1323. ), "'undefined' === typeof($.datepicker)");
  1324. $this->_addCss('jquery-ui/jquery-ui.css');
  1325. self::$_isCssJsUiAdded = true;
  1326. }
  1327. function addCssJsTimepicker ()
  1328. {
  1329. if (self::$_isCssJsTimepickerAdded)
  1330. return;
  1331. $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);
  1332. $sCalendarLang = BxDolLanguages::getInstance()->detectLanguageFromArray ($aCalendarLangs);
  1333. $this->_addCss('timepicker-addon/jquery-ui-timepicker-addon.css');
  1334. $this->_addJs(array(
  1335. 'timepicker-addon/jquery-ui-timepicker-addon.min.js',
  1336. 'timepicker-addon/jquery-ui-sliderAccess.js',
  1337. 'timepicker-addon/i18n/jquery-ui-timepicker-' . $sCalendarLang . '.js',
  1338. 'jquery.ui.touch-punch.min.js',
  1339. ), "'undefined' === typeof($.fn.datetimepicker)");
  1340. self::$_isCssJsTimepickerAdded = true;
  1341. }
  1342. function addCssJsMinicolors ()
  1343. {
  1344. if (self::$_isCssJsMinicolorsAdded)
  1345. return;
  1346. $this->_addCss(BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'jquery-minicolors/|jquery.minicolors.css');
  1347. $this->_addJs('jquery-minicolors/jquery.minicolors.min.js', "'undefined' === typeof($.minicolors)");
  1348. self::$_isCssJsMinicolorsAdded = true;
  1349. }
  1350. function addCssJsViewMode ()
  1351. {
  1352. if (self::$_isCssJsAddedViewMode)
  1353. return;
  1354. $this->_addCss('forms.css');
  1355. self::$_isCssJsAddedViewMode = true;
  1356. }
  1357. function addCssJsCore ()
  1358. {
  1359. if (self::$_isCssJsAdded)
  1360. return;
  1361. $this->_addCss('forms.css');
  1362. $this->_addJs('jquery.webForms.js', "'undefined' === typeof($.fn.addWebForms)");
  1363. self::$_isCssJsAdded = true;
  1364. }
  1365. function addCssJs ()
  1366. {
  1367. if (isset($this->aParams['view_mode']) && $this->aParams['view_mode']) {
  1368. $this->addCssJsViewMode ();
  1369. } else {
  1370. $this->addCssJsCore();
  1371. }
  1372. }
  1373. protected function _processCssJs()
  1374. {
  1375. $sRet = '';
  1376. if ($this->_bDynamicMode) {
  1377. $sRet .= $this->oTemplate->addCss($this->_aCss, true);
  1378. $sRet .= "\n<script>\n";
  1379. $sRet .= "\nglJsLoadOnaddWebForms = [];\n";
  1380. foreach ($this->_aJs as $sCondition => $aJs) {
  1381. $sJs = $this->oTemplate->addJs($aJs, true);
  1382. if (!$sJs)
  1383. continue;
  1384. $sRet .= "if ($sCondition)\n";
  1385. if (preg_match_all("/src=\"(.*?)\"/", $sJs, $aMatches))
  1386. $sRet .= "\tglJsLoadOnaddWebForms = glJsLoadOnaddWebForms.concat(" . json_encode($aMatches[1]) . ");\n";
  1387. }
  1388. $sRet .= "\n</script>\n";
  1389. }
  1390. else {
  1391. $this->oTemplate->addCss($this->_aCss);
  1392. $aJs = array();
  1393. foreach ($this->_aJs as $sCondition => $a)
  1394. $aJs = array_merge($aJs, $a);
  1395. $this->oTemplate->addJs($aJs);
  1396. }
  1397. return $sRet;
  1398. }
  1399. protected function _addJs($mixed, $sJsCondition)
  1400. {
  1401. if (!is_array($mixed))
  1402. $mixed = array($mixed);
  1403. $this->_aJs[$sJsCondition] = $mixed;
  1404. }
  1405. protected function _addCss($mixed)
  1406. {
  1407. if (!is_array($mixed))
  1408. $mixed = array($mixed);
  1409. foreach ($mixed as $s)
  1410. $this->_aCss[$s] = $s;
  1411. }
  1412. }
  1413. /** @} */