BxBaseStudioOptions.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  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. 'dark' => [
  248. 'type' => 'switcher',
  249. 'name' => 'dark',
  250. 'caption' => _t('_adm_stg_txt_mix_dark'),
  251. 'info' => '',
  252. 'value' => '1',
  253. 'db' => ['pass' => 'Int']
  254. ],
  255. 'duplicate' => [
  256. 'type' => 'select',
  257. 'name' => 'duplicate',
  258. 'caption' => _t('_adm_stg_txt_mix_duplicate'),
  259. 'info' => _t('_adm_stg_txt_mix_duplicate_inf'),
  260. 'values' => [
  261. ['key' => '', 'value' => _t('_None')]
  262. ],
  263. 'value' => '',
  264. ],
  265. 'controls' => [
  266. 'type' => 'input_set', [
  267. 'type' => 'submit',
  268. 'name' => 'save',
  269. 'value' => _t('_adm_btn_settings_save'),
  270. ], [
  271. 'type' => 'button',
  272. 'name' => 'cancel',
  273. 'value' => _t('_adm_txt_confirm_cancel'),
  274. 'attrs' => [
  275. 'class' => 'bx-def-margin-sec-left-auto',
  276. 'onclick' => '$(".bx-popup-applied:visible").dolPopupHide()'
  277. ]
  278. ]
  279. ]
  280. ]
  281. ];
  282. if(is_string($this->sCategory))
  283. $aMixesBrowse = ['type' => 'by_type_category', 'mix_type' => $this->sType, 'mix_category' => $this->sCategory];
  284. else
  285. $aMixesBrowse = ['type' => 'by_type', 'value' => $this->sType];
  286. $aMixes = [];
  287. $this->oDb->getMixes($aMixesBrowse, $aMixes, false);
  288. foreach($aMixes as $aMix)
  289. $aForm['inputs']['duplicate']['values'][] = ['key' => $aMix['name'], 'value' => $aMix['title']];
  290. $oForm = new BxTemplStudioFormView($aForm);
  291. $oForm->initChecker();
  292. if($oForm->isSubmittedAndValid()) {
  293. $iId = $oForm->insert([
  294. 'type' => $this->sType,
  295. 'category' => is_string($this->sCategory) ? $this->sCategory : '',
  296. 'name' => $oForm->generateUri()
  297. ]);
  298. if($iId === false)
  299. return ['code' => '1', 'message' => _t('_adm_stg_err_cannot_perform')];
  300. $this->oDb->updateMixes(['active' => 0], [
  301. 'type' => $this->sType,
  302. 'category' => is_string($this->sCategory) ? $this->sCategory : '',
  303. 'active' => 1
  304. ]);
  305. $this->oDb->updateMixes(['active' => 1], ['id' => $iId]);
  306. $aDuplicate = [];
  307. $this->oDb->getMixes(['type' => 'by_name', 'value' => $oForm->getCleanValue('duplicate')], $aDuplicate, false);
  308. if(!empty($aDuplicate) && is_array($aDuplicate))
  309. $this->oDb->duplicateMixesOptions($aDuplicate['id'], $iId);
  310. $this->clearCache();
  311. return ['eval' => $sJsObject . '.onMixCreate(oData);'];
  312. }
  313. return [
  314. 'popup' => BxTemplStudioFunctions::getInstance()->popupBox('adm-stg-create-mix-popup', _t('_adm_stg_txt_create_mix_popup'), $oTemplate->parseHtmlByName('options_create_mix.html', [
  315. 'js_object' => $sJsObject,
  316. 'form_id' => $sForm,
  317. 'form' => $oForm->getCode(true),
  318. ]))
  319. ];
  320. }
  321. public function getPopupCodeImportMix()
  322. {
  323. $oTemplate = BxDolStudioTemplate::getInstance();
  324. $sJsObject = $this->getJsObject();
  325. $sForm = 'adm-settings-import-mix-form';
  326. $aForm = [
  327. 'form_attrs' => [
  328. 'id' => $sForm,
  329. 'name' => $sForm,
  330. 'action' => bx_append_url_params($this->sBaseUrl, [$this->sParamPrefix . '_action' => 'import-mix']),
  331. 'method' => 'post',
  332. 'enctype' => 'multipart/form-data'
  333. ],
  334. 'params' => [
  335. 'db' => [
  336. 'table' => 'sys_options_mixes',
  337. 'key' => 'id',
  338. 'uri' => 'name',
  339. 'uri_title' => 'title',
  340. 'submit_name' => 'save'
  341. ],
  342. ],
  343. 'inputs' => [
  344. 'type' => [
  345. 'type' => 'hidden',
  346. 'name' => 'type',
  347. 'value' => $this->sType
  348. ],
  349. 'category' => [
  350. 'type' => 'hidden',
  351. 'name' => 'category',
  352. 'value' => is_array($this->sCategory) ? json_encode($this->sCategory) : $this->sCategory,
  353. ],
  354. 'file' => [
  355. 'type' => 'file',
  356. 'name' => 'file',
  357. 'caption' => '',
  358. 'value' => '',
  359. ],
  360. 'controls' => [
  361. 'type' => 'input_set', [
  362. 'type' => 'submit',
  363. 'name' => 'save',
  364. 'value' => _t('_adm_btn_settings_import'),
  365. ], [
  366. 'type' => 'button',
  367. 'name' => 'cancel',
  368. 'value' => _t('_adm_txt_confirm_cancel'),
  369. 'attrs' => [
  370. 'class' => 'bx-def-margin-sec-left-auto',
  371. 'onclick' => '$(".bx-popup-applied:visible").dolPopupHide()'
  372. ]
  373. ]
  374. ]
  375. ]
  376. ];
  377. $oForm = new BxTemplStudioFormView($aForm);
  378. $oForm->initChecker();
  379. if($oForm->isSubmittedAndValid()) {
  380. $sError = _t('_adm_stg_err_cannot_perform');
  381. $aFile = $_FILES['file'];
  382. if(empty($aFile['tmp_name']))
  383. return ['code' => '1', 'message' => $sError];
  384. $sFile = $aFile['tmp_name'];
  385. $rHandle = @fopen($sFile, "r");
  386. if(!$rHandle)
  387. return ['code' => '2', 'message' => $sError];
  388. $sContents = fread($rHandle, filesize($sFile));
  389. fclose($rHandle);
  390. $aContent = json_decode($sContents, true);
  391. if(!is_array($aContent) || empty($aContent['mix']) || empty($aContent['options']))
  392. return ['code' => '3', 'message' => $sError];
  393. $aMix = [];
  394. $this->oDb->getMixes(['type' => 'by_name', 'value' => $aContent['mix']['name']], $aMix, false);
  395. if(!empty($aMix) && is_array($aMix))
  396. return ['code' => '4', 'message' => _t('_adm_stg_err_mix_already_exists')];
  397. $iId = $oForm->insert([
  398. 'type' => $aContent['mix']['type'],
  399. 'category' => $aContent['mix']['category'],
  400. 'name' => $aContent['mix']['name'],
  401. 'title' => $aContent['mix']['title']
  402. ]);
  403. if($iId === false)
  404. return ['code' => '5', 'message' => $sError];
  405. foreach($aContent['options'] as $sKey => $sValue)
  406. $this->oDb->insertMixesOptions([
  407. 'option' => $sKey,
  408. 'mix_id' => $iId,
  409. 'value' => $sValue
  410. ]);
  411. $this->oDb->updateMixes(['active' => 0], [
  412. 'type' => $this->sType,
  413. 'category' => is_string($this->sCategory) ? $this->sCategory : '',
  414. 'active' => 1
  415. ]);
  416. $this->oDb->updateMixes(['active' => 1], ['id' => $iId]);
  417. $this->clearCache();
  418. return ['eval' => $sJsObject . '.onMixImport(oData);'];
  419. }
  420. return [
  421. 'popup' => BxTemplStudioFunctions::getInstance()->popupBox('adm-stg-import-mix-popup', _t('_adm_stg_txt_import_mix_popup'), $oTemplate->parseHtmlByName('options_import_mix.html', [
  422. 'js_object' => $sJsObject,
  423. 'form_id' => $sForm,
  424. 'form' => $oForm->getCode(true),
  425. ]))
  426. ];
  427. }
  428. protected function header($aCategory, $aFields)
  429. {
  430. return array_merge([
  431. 'category_' . $aCategory['id'] . '_beg' => [
  432. 'type' => 'block_header',
  433. 'name' => 'category_' . $aCategory['id'] . '_beg',
  434. 'caption' => _t($aCategory['caption']),
  435. 'collapsable' => true,
  436. 'collapsed' => !$aCategory['selected']
  437. ]
  438. ],
  439. $aFields
  440. );
  441. }
  442. protected function field($aItem, $aItems2Mixes)
  443. {
  444. $mixedValue = isset($aItems2Mixes[$aItem['name']]) ? $aItems2Mixes[$aItem['name']] : $aItem['value'];
  445. $sMethod = 'getCustomValue' . bx_gen_method_name(trim(str_replace($this->sType, '', $aItem['name']), '_'));
  446. if(method_exists($this, $sMethod))
  447. $mixedValue = $this->$sMethod($aItem, $mixedValue);
  448. $aAttributes = array();
  449. if($this->isReadOnly())
  450. $aAttributes = array_merge($aAttributes, [
  451. 'disabled' => 'disabled'
  452. ]);
  453. $aField = [];
  454. switch($aItem['type']) {
  455. case 'value':
  456. $aField = [
  457. 'type' => 'text',
  458. 'name' => $aItem['name'],
  459. 'caption' => _t($aItem['caption']),
  460. 'value' => $mixedValue,
  461. 'attrs' => array_merge($aAttributes, ['readonly' => 'readonly']),
  462. 'db' => ['pass' => 'Xss'],
  463. ];
  464. break;
  465. case 'digit':
  466. $aField = [
  467. 'type' => 'text',
  468. 'name' => $aItem['name'],
  469. 'caption' => _t($aItem['caption']),
  470. 'value' => $mixedValue,
  471. 'attrs' => $aAttributes,
  472. 'db' => ['pass' => 'Xss'],
  473. ];
  474. break;
  475. case 'text':
  476. $aField = [
  477. 'type' => 'textarea',
  478. 'name' => $aItem['name'],
  479. 'caption' => _t($aItem['caption']),
  480. 'value' => $mixedValue,
  481. 'attrs' => $aAttributes,
  482. 'db' => ['pass' => 'XssHtml'],
  483. ];
  484. break;
  485. case 'code':
  486. $aField = [
  487. 'type' => 'textarea',
  488. 'code' => true,
  489. 'name' => $aItem['name'],
  490. 'caption' => _t($aItem['caption']),
  491. 'value' => $mixedValue,
  492. 'attrs' => $aAttributes,
  493. 'db' => ['pass' => 'XssHtml'],
  494. ];
  495. break;
  496. case 'checkbox':
  497. $aField = [
  498. 'type' => 'checkbox',
  499. 'name' => $aItem['name'],
  500. 'caption' => _t($aItem['caption']),
  501. 'value' => 'on',
  502. 'checked' => $mixedValue == 'on',
  503. 'attrs' => $aAttributes,
  504. 'db' => ['pass' => 'Xss'],
  505. ];
  506. break;
  507. case 'list':
  508. case 'rlist':
  509. $aField = [
  510. 'type' => 'checkbox_set',
  511. 'name' => $aItem['name'],
  512. 'caption' => _t($aItem['caption']),
  513. 'value' => !empty($mixedValue) ? explode(',', $mixedValue) : [],
  514. 'reverse' => $aItem['type'] == 'rlist',
  515. 'attrs' => $aAttributes,
  516. 'db' => ['pass' => 'Xss'],
  517. ];
  518. if (BxDolService::isSerializedService($aItem['extra']))
  519. $aField['values'] = BxDolService::callSerialized($aItem['extra']);
  520. else
  521. foreach(explode(',', $aItem['extra']) as $sValue)
  522. $aField['values'][$sValue] = $sValue;
  523. break;
  524. case 'select':
  525. $aField = [
  526. 'type' => 'select',
  527. 'name' => $aItem['name'],
  528. 'caption' => _t($aItem['caption']),
  529. 'value' => $mixedValue,
  530. 'values' => [],
  531. 'attrs' => $aAttributes,
  532. 'db' => ['pass' => 'Xss'],
  533. ];
  534. if (BxDolService::isSerializedService($aItem['extra']))
  535. $aField['values'] = BxDolService::callSerialized($aItem['extra']);
  536. else
  537. foreach(explode(',', $aItem['extra']) as $sValue)
  538. $aField['values'][] = ['key' => $sValue, 'value' => $sValue];
  539. break;
  540. case 'file':
  541. $aField = [
  542. 'type' => 'file',
  543. 'name' => $aItem['name'],
  544. 'caption' => _t($aItem['caption']),
  545. 'value' => $mixedValue,
  546. 'attrs' => $aAttributes,
  547. 'db' => ['pass' => 'Xss']
  548. ];
  549. break;
  550. case 'image':
  551. //--- Concatenation integer values as strings is required to get unique content id
  552. $iContentId = (int)($aItem['id'] . ($this->bMixes && isset($this->aMix['id']) ? $this->aMix['id'] : 0));
  553. $aField = [
  554. 'type' => 'files',
  555. 'name' => $aItem['name'],
  556. 'storage_object' => $this->sStorage,
  557. 'storage_private' => 0,
  558. 'images_transcoder' => $this->sTranscoder,
  559. 'uploaders' => ['sys_settings_html5'],
  560. 'upload_buttons_titles' => ['HTML5' => _t('_sys_uploader_button_name_single')],
  561. 'multiple' => false,
  562. 'content_id' => $iContentId,
  563. 'ghost_template' => ['inputs' => []],
  564. 'caption' => _t($aItem['caption']),
  565. 'value' => $mixedValue,
  566. 'attrs' => $aAttributes,
  567. 'db' => ['pass' => 'Xss']
  568. ];
  569. break;
  570. case 'rgb':
  571. case 'rgba':
  572. $aField = [
  573. 'type' => $aItem['type'],
  574. 'name' => $aItem['name'],
  575. 'caption' => _t($aItem['caption']),
  576. 'value' => $mixedValue,
  577. 'attrs' => $aAttributes,
  578. 'db' => ['pass' => 'Xss'],
  579. ];
  580. break;
  581. case 'datetime':
  582. $aField = [
  583. 'type' => 'datetime',
  584. 'name' => $aItem['name'],
  585. 'caption' => _t($aItem['caption']),
  586. 'value' => $mixedValue,
  587. 'attrs' => $aAttributes,
  588. 'db' => ['pass' => 'DateTimeUtc'],
  589. ];
  590. break;
  591. }
  592. return $aField;
  593. }
  594. }
  595. /** @} */