BxBaseStudioOptions.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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 UnaView UNA Studio Representation classes
  7. * @ingroup UnaStudio
  8. * @{
  9. */
  10. class BxBaseStudioOptions extends BxDolStudioOptions
  11. {
  12. public function __construct($sType = '', $mixedCategory = '', $sMix = '')
  13. {
  14. parent::__construct($sType, $mixedCategory);
  15. }
  16. public function getCss()
  17. {
  18. return ['forms.css', 'options.css'];
  19. }
  20. public function getJs()
  21. {
  22. return ['jquery.form.min.js', 'jquery.webForms.js', 'options.js'];
  23. }
  24. public function getJsObject()
  25. {
  26. return 'oBxDolStudioOptions';
  27. }
  28. public function getCode($sCategorySelected = '')
  29. {
  30. $oTemplate = BxDolStudioTemplate::getInstance();
  31. $sJsObject = $this->getJsObject();
  32. $aCategories = [];
  33. $iCategories = $this->oDb->getCategories(['type' => 'by_type_name_key_name', 'type_name' => $this->sType, 'category_name' => $this->sCategory, 'hidden' => 0], $aCategories);
  34. if($iCategories > 0)
  35. $aCategories = array_keys($aCategories);
  36. $bMix = false;
  37. $aOptions2Mixes = [];
  38. if($this->bMixes) {
  39. if(!empty($this->sMix))
  40. $aMixesBrowse = ['type' => 'by_name', 'value' => $this->sMix];
  41. else if(is_string($this->sCategory))
  42. $aMixesBrowse = ['type' => 'by_type_category', 'mix_type' => $this->sType, 'mix_category' => $this->sCategory, 'active' => 1];
  43. else
  44. $aMixesBrowse = ['type' => 'by_type', 'value' => $this->sType, 'active' => 1];
  45. $aMix = array();
  46. $this->oDb->getMixes($aMixesBrowse, $aMix, false);
  47. if(!empty($aMix) && is_array($aMix)) {
  48. $this->aMix = $aMix;
  49. $this->sMix = $aMix['name'];
  50. $bMix = true;
  51. $this->oDb->getMixesOptions(['type' => 'by_mix_id_pair_option_value', 'value' => $this->aMix['id']], $aOptions2Mixes, false);
  52. }
  53. else
  54. $this->sMix = BX_DOL_STUDIO_STG_MIX_DEFAULT;
  55. }
  56. $bWrap = count($aCategories) > 1;
  57. $aForm = [
  58. 'form_attrs' => [
  59. 'id' => 'adm-settings-form',
  60. 'name' => 'adm-settings-form',
  61. 'action' => bx_append_url_params($this->sBaseUrl, ['type' => $this->sType]),
  62. 'method' => 'post',
  63. 'enctype' => 'multipart/form-data',
  64. 'target' => 'adm-settings-iframe',
  65. 'onsubmit' => 'return ' . $sJsObject . '.onSubmit(this)'
  66. ],
  67. 'params' => [
  68. 'db' => [
  69. 'table' => 'sys_options',
  70. 'key' => 'id',
  71. 'uri' => '',
  72. 'uri_title' => '',
  73. 'submit_name' => 'save'
  74. ],
  75. ],
  76. 'inputs' => []
  77. ];
  78. if($bMix)
  79. $aForm['inputs']['mix_id'] = [
  80. 'type' => 'hidden',
  81. 'name' => 'mix_id',
  82. 'value' => $this->aMix['id'],
  83. 'db' => [
  84. 'pass' => 'Int',
  85. ],
  86. ];
  87. foreach($aCategories as $sCategory) {
  88. $aFields = [];
  89. if(empty($sCategory))
  90. continue;
  91. $aCategory = array();
  92. $iCategory = $this->oDb->getCategories(['type' => 'by_name', 'value' => $sCategory], $aCategory);
  93. if($iCategory != 1)
  94. continue;
  95. $aOptions = array();
  96. $iOptions = $this->oDb->getOptions(['type' => 'by_category_id', 'value' => $aCategory['id']], $aOptions);
  97. foreach($aOptions as $aOption)
  98. $aFields[$aOption['name']] = $this->field($aOption, $aOptions2Mixes);
  99. if($bWrap) {
  100. $aCategory['selected'] = $aCategory['name'] == $sCategorySelected;
  101. $aFields = $this->header($aCategory, $aFields);
  102. }
  103. $aForm['inputs'] = array_merge($aForm['inputs'], $aFields);
  104. }
  105. $aForm['inputs'] = array_merge(
  106. $aForm['inputs'], (!$bWrap ? [] : [
  107. 'header_save' => [
  108. 'type' => 'block_header',
  109. ],
  110. ]), [
  111. 'categories' => [
  112. 'type' => 'hidden',
  113. 'name' => 'categories',
  114. 'value' => implode(',', $aCategories),
  115. 'db' => [
  116. 'pass' => 'Xss',
  117. ],
  118. ]
  119. ], ($this->isReadOnly() ? [] : [
  120. 'save' => [
  121. 'type' => 'submit',
  122. 'name' => 'save',
  123. 'value' => _t("_adm_btn_settings_save")
  124. ],
  125. ])
  126. );
  127. $oForm = new BxTemplStudioFormView($aForm, $oTemplate);
  128. $oForm->initChecker();
  129. if($oForm->isSubmittedAndValid()) {
  130. echo $this->saveChanges($oForm);
  131. exit;
  132. }
  133. $bTmplVarsMixes = false;
  134. $aTmplVarsMixes = [];
  135. if($this->bMixes) {
  136. if(is_string($this->sCategory))
  137. $aMixesBrowse = ['type' => 'by_type_category', 'mix_type' => $this->sType, 'mix_category' => $this->sCategory];
  138. else
  139. $aMixesBrowse = ['type' => 'by_type', 'value' => $this->sType];
  140. $aMixes = [];
  141. $this->oDb->getMixes($aMixesBrowse, $aMixes, false);
  142. $aMixes = array_merge([['name' => BX_DOL_STUDIO_STG_MIX_DEFAULT, 'title' => _t('_adm_stg_txt_mix_' . BX_DOL_STUDIO_STG_MIX_DEFAULT)]], $aMixes);
  143. foreach($aMixes as $aMix)
  144. $aTmplVarsMixes[] = [
  145. 'value' => $aMix['name'],
  146. 'title' => $aMix['title'],
  147. 'bx_if:show_checked_mix' => [
  148. 'condition' => !empty($this->sMix) && $aMix['name'] == $this->sMix,
  149. 'content' => []
  150. ]
  151. ];
  152. $bTmplVarsMixes = !empty($aTmplVarsMixes);
  153. }
  154. $bMixSelected = !empty($this->sMix) && !empty($this->aMix);
  155. $aTmplVarsButton = [];
  156. if($bMixSelected)
  157. $aTmplVarsButton = [
  158. 'js_object' => $sJsObject,
  159. 'id' => $this->aMix['id']
  160. ];
  161. return $oTemplate->parseHtmlByName('options.html', [
  162. 'base_url' => $this->sBaseUrl,
  163. 'param_prefix' => $this->sParamPrefix,
  164. 'js_object' => $sJsObject,
  165. 'type' => $this->sType,
  166. 'category' => is_array($this->sCategory) ? json_encode($this->sCategory) : $this->sCategory,
  167. 'mix' => $this->sMix,
  168. 'bx_if:show_mixes' => [
  169. 'condition' => $this->bMixes,
  170. 'content' => [
  171. 'js_object' => $sJsObject,
  172. 'bx_if:show_select_mix' => [
  173. 'condition' => $bTmplVarsMixes,
  174. 'content' => [
  175. 'js_object' => $sJsObject,
  176. 'bx_repeat:mixes' => $aTmplVarsMixes,
  177. ]
  178. ],
  179. 'bx_if:show_publish_mix' => [
  180. 'condition' => $bMixSelected && (int)$this->aMix['published'] == 0,
  181. 'content' => $aTmplVarsButton
  182. ],
  183. 'bx_if:show_hide_mix' => [
  184. 'condition' => $bMixSelected && (int)$this->aMix['published'] != 0,
  185. 'content' => $aTmplVarsButton
  186. ],
  187. 'bx_if:show_export_mix' => [
  188. 'condition' => $bMixSelected,
  189. 'content' => $aTmplVarsButton
  190. ],
  191. 'bx_if:show_delete_mix' => [
  192. 'condition' => $bMixSelected,
  193. 'content' => $aTmplVarsButton
  194. ],
  195. ]
  196. ],
  197. 'form' => $oForm->getCode()
  198. ]);
  199. }
  200. public function getPopupCodeCreateMix()
  201. {
  202. $oTemplate = BxDolStudioTemplate::getInstance();
  203. $sJsObject = $this->getJsObject();
  204. $sForm = 'adm-settings-create-mix-form';
  205. $aForm = [
  206. 'form_attrs' => [
  207. 'id' => $sForm,
  208. 'name' => $sForm,
  209. 'action' => bx_append_url_params($this->sBaseUrl, [$this->sParamPrefix . '_action' => 'create-mix']),
  210. 'method' => 'post',
  211. 'enctype' => 'multipart/form-data'
  212. ],
  213. 'params' => [
  214. 'db' => [
  215. 'table' => 'sys_options_mixes',
  216. 'key' => 'id',
  217. 'uri' => 'name',
  218. 'uri_title' => 'title',
  219. 'submit_name' => 'save'
  220. ],
  221. ],
  222. 'inputs' => [
  223. 'type' => [
  224. 'type' => 'hidden',
  225. 'name' => 'type',
  226. 'value' => $this->sType
  227. ],
  228. 'category' => [
  229. 'type' => 'hidden',
  230. 'name' => 'category',
  231. 'value' => is_array($this->sCategory) ? json_encode($this->sCategory) : $this->sCategory,
  232. ],
  233. 'title' => [
  234. 'type' => 'text',
  235. 'name' => 'title',
  236. 'caption' => _t('_adm_stg_txt_mix_title'),
  237. 'info' => _t('_adm_stg_txt_mix_title_inf'),
  238. 'value' => '',
  239. 'required' => true,
  240. 'checker' => [
  241. 'func' => 'avail',
  242. 'params' => [],
  243. 'error' => _t('_adm_stg_txt_mix_title_err')
  244. ],
  245. 'db' => ['pass' => 'Xss']
  246. ],
  247. 'duplicate' => [
  248. 'type' => 'select',
  249. 'name' => 'duplicate',
  250. 'caption' => _t('_adm_stg_txt_mix_duplicate'),
  251. 'info' => _t('_adm_stg_txt_mix_duplicate_inf'),
  252. 'values' => [
  253. ['key' => '', 'value' => _t('_None')]
  254. ],
  255. 'value' => '',
  256. ],
  257. 'controls' => [
  258. 'type' => 'input_set', [
  259. 'type' => 'submit',
  260. 'name' => 'save',
  261. 'value' => _t('_adm_btn_settings_save'),
  262. ], [
  263. 'type' => 'button',
  264. 'name' => 'cancel',
  265. 'value' => _t('_adm_txt_confirm_cancel'),
  266. 'attrs' => [
  267. 'class' => 'bx-def-margin-sec-left-auto',
  268. 'onclick' => '$(".bx-popup-applied:visible").dolPopupHide()'
  269. ]
  270. ]
  271. ]
  272. ]
  273. ];
  274. if(is_string($this->sCategory))
  275. $aMixesBrowse = ['type' => 'by_type_category', 'mix_type' => $this->sType, 'mix_category' => $this->sCategory];
  276. else
  277. $aMixesBrowse = ['type' => 'by_type', 'value' => $this->sType];
  278. $aMixes = [];
  279. $this->oDb->getMixes($aMixesBrowse, $aMixes, false);
  280. foreach($aMixes as $aMix)
  281. $aForm['inputs']['duplicate']['values'][] = ['key' => $aMix['name'], 'value' => $aMix['title']];
  282. $oForm = new BxTemplStudioFormView($aForm);
  283. $oForm->initChecker();
  284. if($oForm->isSubmittedAndValid()) {
  285. $iId = $oForm->insert([
  286. 'type' => $this->sType,
  287. 'category' => is_string($this->sCategory) ? $this->sCategory : '',
  288. 'name' => $oForm->generateUri()
  289. ]);
  290. if($iId === false)
  291. return ['code' => '1', 'message' => _t('_adm_stg_err_cannot_perform')];
  292. $this->oDb->updateMixes(['active' => 0], [
  293. 'type' => $this->sType,
  294. 'category' => is_string($this->sCategory) ? $this->sCategory : '',
  295. 'active' => 1
  296. ]);
  297. $this->oDb->updateMixes(['active' => 1], ['id' => $iId]);
  298. $aDuplicate = [];
  299. $this->oDb->getMixes(['type' => 'by_name', 'value' => $oForm->getCleanValue('duplicate')], $aDuplicate, false);
  300. if(!empty($aDuplicate) && is_array($aDuplicate))
  301. $this->oDb->duplicateMixesOptions($aDuplicate['id'], $iId);
  302. $this->clearCache();
  303. return ['eval' => $sJsObject . '.onMixCreate(oData);'];
  304. }
  305. return [
  306. 'popup' => BxTemplStudioFunctions::getInstance()->popupBox('adm-stg-create-mix-popup', _t('_adm_stg_txt_create_mix_popup'), $oTemplate->parseHtmlByName('options_create_mix.html', [
  307. 'js_object' => $sJsObject,
  308. 'form_id' => $sForm,
  309. 'form' => $oForm->getCode(true),
  310. ]))
  311. ];
  312. }
  313. public function getPopupCodeImportMix()
  314. {
  315. $oTemplate = BxDolStudioTemplate::getInstance();
  316. $sJsObject = $this->getJsObject();
  317. $sForm = 'adm-settings-import-mix-form';
  318. $aForm = [
  319. 'form_attrs' => [
  320. 'id' => $sForm,
  321. 'name' => $sForm,
  322. 'action' => bx_append_url_params($this->sBaseUrl, [$this->sParamPrefix . '_action' => 'import-mix']),
  323. 'method' => 'post',
  324. 'enctype' => 'multipart/form-data'
  325. ],
  326. 'params' => [
  327. 'db' => [
  328. 'table' => 'sys_options_mixes',
  329. 'key' => 'id',
  330. 'uri' => 'name',
  331. 'uri_title' => 'title',
  332. 'submit_name' => 'save'
  333. ],
  334. ],
  335. 'inputs' => [
  336. 'type' => [
  337. 'type' => 'hidden',
  338. 'name' => 'type',
  339. 'value' => $this->sType
  340. ],
  341. 'category' => [
  342. 'type' => 'hidden',
  343. 'name' => 'category',
  344. 'value' => is_array($this->sCategory) ? json_encode($this->sCategory) : $this->sCategory,
  345. ],
  346. 'file' => [
  347. 'type' => 'file',
  348. 'name' => 'file',
  349. 'caption' => '',
  350. 'value' => '',
  351. ],
  352. 'controls' => [
  353. 'type' => 'input_set', [
  354. 'type' => 'submit',
  355. 'name' => 'save',
  356. 'value' => _t('_adm_btn_settings_import'),
  357. ], [
  358. 'type' => 'button',
  359. 'name' => 'cancel',
  360. 'value' => _t('_adm_txt_confirm_cancel'),
  361. 'attrs' => [
  362. 'class' => 'bx-def-margin-sec-left-auto',
  363. 'onclick' => '$(".bx-popup-applied:visible").dolPopupHide()'
  364. ]
  365. ]
  366. ]
  367. ]
  368. ];
  369. $oForm = new BxTemplStudioFormView($aForm);
  370. $oForm->initChecker();
  371. if($oForm->isSubmittedAndValid()) {
  372. $sError = _t('_adm_stg_err_cannot_perform');
  373. $aFile = $_FILES['file'];
  374. if(empty($aFile['tmp_name']))
  375. return ['code' => '1', 'message' => $sError];
  376. $sFile = $aFile['tmp_name'];
  377. $rHandle = @fopen($sFile, "r");
  378. if(!$rHandle)
  379. return ['code' => '2', 'message' => $sError];
  380. $sContents = fread($rHandle, filesize($sFile));
  381. fclose($rHandle);
  382. $aContent = json_decode($sContents, true);
  383. if(!is_array($aContent) || empty($aContent['mix']) || empty($aContent['options']))
  384. return ['code' => '3', 'message' => $sError];
  385. $aMix = [];
  386. $this->oDb->getMixes(['type' => 'by_name', 'value' => $aContent['mix']['name']], $aMix, false);
  387. if(!empty($aMix) && is_array($aMix))
  388. return ['code' => '4', 'message' => _t('_adm_stg_err_mix_already_exists')];
  389. $iId = $oForm->insert([
  390. 'type' => $aContent['mix']['type'],
  391. 'category' => $aContent['mix']['category'],
  392. 'name' => $aContent['mix']['name'],
  393. 'title' => $aContent['mix']['title']
  394. ]);
  395. if($iId === false)
  396. return ['code' => '5', 'message' => $sError];
  397. foreach($aContent['options'] as $sKey => $sValue)
  398. $this->oDb->insertMixesOptions([
  399. 'option' => $sKey,
  400. 'mix_id' => $iId,
  401. 'value' => $sValue
  402. ]);
  403. $this->oDb->updateMixes(['active' => 0], [
  404. 'type' => $this->sType,
  405. 'category' => is_string($this->sCategory) ? $this->sCategory : '',
  406. 'active' => 1
  407. ]);
  408. $this->oDb->updateMixes(['active' => 1], ['id' => $iId]);
  409. $this->clearCache();
  410. return ['eval' => $sJsObject . '.onMixImport(oData);'];
  411. }
  412. return [
  413. 'popup' => BxTemplStudioFunctions::getInstance()->popupBox('adm-stg-import-mix-popup', _t('_adm_stg_txt_import_mix_popup'), $oTemplate->parseHtmlByName('options_import_mix.html', [
  414. 'js_object' => $sJsObject,
  415. 'form_id' => $sForm,
  416. 'form' => $oForm->getCode(true),
  417. ]))
  418. ];
  419. }
  420. protected function header($aCategory, $aFields)
  421. {
  422. return array_merge([
  423. 'category_' . $aCategory['id'] . '_beg' => [
  424. 'type' => 'block_header',
  425. 'name' => 'category_' . $aCategory['id'] . '_beg',
  426. 'caption' => _t($aCategory['caption']),
  427. 'collapsable' => true,
  428. 'collapsed' => !$aCategory['selected']
  429. ]
  430. ],
  431. $aFields
  432. );
  433. }
  434. protected function field($aItem, $aItems2Mixes)
  435. {
  436. $mixedValue = isset($aItems2Mixes[$aItem['name']]) ? $aItems2Mixes[$aItem['name']] : $aItem['value'];
  437. $sMethod = 'getCustomValue' . bx_gen_method_name(trim(str_replace($this->sType, '', $aItem['name']), '_'));
  438. if(method_exists($this, $sMethod))
  439. $mixedValue = $this->$sMethod($aItem, $mixedValue);
  440. $aAttributes = array();
  441. if($this->isReadOnly())
  442. $aAttributes = array_merge($aAttributes, [
  443. 'disabled' => 'disabled'
  444. ]);
  445. $aField = [];
  446. switch($aItem['type']) {
  447. case 'value':
  448. $aField = [
  449. 'type' => 'text',
  450. 'name' => $aItem['name'],
  451. 'caption' => _t($aItem['caption']),
  452. 'value' => $mixedValue,
  453. 'attrs' => array_merge($aAttributes, ['readonly' => 'readonly']),
  454. 'db' => ['pass' => 'Xss'],
  455. ];
  456. break;
  457. case 'digit':
  458. $aField = [
  459. 'type' => 'text',
  460. 'name' => $aItem['name'],
  461. 'caption' => _t($aItem['caption']),
  462. 'value' => $mixedValue,
  463. 'attrs' => $aAttributes,
  464. 'db' => ['pass' => 'Xss'],
  465. ];
  466. break;
  467. case 'text':
  468. $aField = [
  469. 'type' => 'textarea',
  470. 'name' => $aItem['name'],
  471. 'caption' => _t($aItem['caption']),
  472. 'value' => $mixedValue,
  473. 'attrs' => $aAttributes,
  474. 'db' => ['pass' => 'XssHtml'],
  475. ];
  476. break;
  477. case 'checkbox':
  478. $aField = [
  479. 'type' => 'checkbox',
  480. 'name' => $aItem['name'],
  481. 'caption' => _t($aItem['caption']),
  482. 'value' => 'on',
  483. 'checked' => $mixedValue == 'on',
  484. 'attrs' => $aAttributes,
  485. 'db' => ['pass' => 'Xss'],
  486. ];
  487. break;
  488. case 'list':
  489. case 'rlist':
  490. $aField = [
  491. 'type' => 'checkbox_set',
  492. 'name' => $aItem['name'],
  493. 'caption' => _t($aItem['caption']),
  494. 'value' => !empty($mixedValue) ? explode(',', $mixedValue) : [],
  495. 'reverse' => $aItem['type'] == 'rlist',
  496. 'attrs' => $aAttributes,
  497. 'db' => ['pass' => 'Xss'],
  498. ];
  499. if (BxDolService::isSerializedService($aItem['extra']))
  500. $aField['values'] = BxDolService::callSerialized($aItem['extra']);
  501. else
  502. foreach(explode(',', $aItem['extra']) as $sValue)
  503. $aField['values'][$sValue] = $sValue;
  504. break;
  505. case 'select':
  506. $aField = [
  507. 'type' => 'select',
  508. 'name' => $aItem['name'],
  509. 'caption' => _t($aItem['caption']),
  510. 'value' => $mixedValue,
  511. 'values' => [],
  512. 'attrs' => $aAttributes,
  513. 'db' => ['pass' => 'Xss'],
  514. ];
  515. if (BxDolService::isSerializedService($aItem['extra']))
  516. $aField['values'] = BxDolService::callSerialized($aItem['extra']);
  517. else
  518. foreach(explode(',', $aItem['extra']) as $sValue)
  519. $aField['values'][] = ['key' => $sValue, 'value' => $sValue];
  520. break;
  521. case 'file':
  522. $aField = [
  523. 'type' => 'file',
  524. 'name' => $aItem['name'],
  525. 'caption' => _t($aItem['caption']),
  526. 'value' => $mixedValue,
  527. 'attrs' => $aAttributes,
  528. 'db' => ['pass' => 'Xss']
  529. ];
  530. break;
  531. case 'image':
  532. //--- Concatenation integer values as strings is required to get unique content id
  533. $iContentId = (int)($aItem['id'] . ($this->bMixes && isset($this->aMix['id']) ? $this->aMix['id'] : 0));
  534. $aField = [
  535. 'type' => 'files',
  536. 'name' => $aItem['name'],
  537. 'storage_object' => $this->sStorage,
  538. 'storage_private' => 0,
  539. 'images_transcoder' => $this->sTranscoder,
  540. 'uploaders' => ['sys_settings_html5'],
  541. 'upload_buttons_titles' => ['HTML5' => _t('_sys_uploader_button_name_single')],
  542. 'multiple' => false,
  543. 'content_id' => $iContentId,
  544. 'ghost_template' => ['inputs' => []],
  545. 'caption' => _t($aItem['caption']),
  546. 'value' => $mixedValue,
  547. 'attrs' => $aAttributes,
  548. 'db' => ['pass' => 'Xss']
  549. ];
  550. break;
  551. case 'rgb':
  552. case 'rgba':
  553. $aField = [
  554. 'type' => $aItem['type'],
  555. 'name' => $aItem['name'],
  556. 'caption' => _t($aItem['caption']),
  557. 'value' => $mixedValue,
  558. 'attrs' => $aAttributes,
  559. 'db' => ['pass' => 'Xss'],
  560. ];
  561. break;
  562. case 'datetime':
  563. $aField = [
  564. 'type' => 'datetime',
  565. 'name' => $aItem['name'],
  566. 'caption' => _t($aItem['caption']),
  567. 'value' => $mixedValue,
  568. 'attrs' => $aAttributes,
  569. 'db' => ['pass' => 'DateTimeUtc'],
  570. ];
  571. break;
  572. }
  573. return $aField;
  574. }
  575. }
  576. /** @} */