BxBaseStudioSettings.php 26 KB

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