BxBaseStudioSettings.php 24 KB

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