BxBaseStudioSettings.php 27 KB

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