BxBaseStudioBuilderPage.php 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup TridentView Trident Studio Representation classes
  7. * @ingroup TridentStudio
  8. * @{
  9. */
  10. class BxBaseStudioBuilderPage extends BxDolStudioBuilderPage
  11. {
  12. protected $sParamsDivider = '#';
  13. protected $sSelectKeyPrefix = 'id-';
  14. protected $sActionPageCreate = 'page_create';
  15. protected $sActionPageDelete = 'page_delete';
  16. protected $sActionPageEdit = 'page_edit';
  17. protected $sActionBlockCreate = 'block_create';
  18. protected $sActionBlockEdit = 'block_edit';
  19. protected $sStorage;
  20. protected $sTranscoder;
  21. protected $aUploaders;
  22. protected $sBaseUrl;
  23. protected $sTypeUrl;
  24. protected $sPageUrl;
  25. protected $aHtmlIds = array(
  26. 'add_popup_id' => 'adm-bp-add-popup',
  27. 'edit_popup_id' => 'adm-bp-edit-popup',
  28. 'uri_field_id' => 'adm-bp-field-uri',
  29. 'url_field_id' => 'adm-bp-field-url',
  30. 'settings_group_id' => 'adm-bp-settings-group-',
  31. 'settings_groups_id' => 'adm-bp-settings-groups',
  32. 'create_block_popup_id' => 'adm-bp-create-block-popup',
  33. 'edit_block_popup_id' => 'adm-bp-edit-block-popup',
  34. 'edit_block_editor_id' => 'adm-bp-edit-block-editor',
  35. 'block_id' => 'adm-bpb-',
  36. 'block_list_id' => 'adm-bpl-',
  37. 'block_lists_id' => 'adm-bp-block-lists',
  38. 'layout_id' => 'adm-bpl-',
  39. );
  40. protected $aPageSettings = array(
  41. array('name' => 'options', 'title' => '_adm_bp_mi_page_options', 'active' => 1),
  42. array('name' => 'cover', 'title' => '_adm_bp_mi_page_cover', 'active' => 0),
  43. array('name' => 'layout', 'title' => '_adm_bp_mi_page_layout', 'active' => 0),
  44. array('name' => 'visibility', 'title' => '_adm_bp_mi_page_visibility', 'active' => 0),
  45. array('name' => 'cache', 'title' => '_adm_bp_mi_page_cache', 'active' => 0),
  46. array('name' => 'seo', 'title' => '_adm_bp_mi_page_seo', 'active' => 0)
  47. );
  48. function __construct($sType = '', $sPage = '')
  49. {
  50. parent::__construct($sType, $sPage);
  51. $this->sStorage = 'sys_images';
  52. $this->sTranscoder = 'sys_builder_page_preview';
  53. $this->aUploaders = array('sys_builder_page_simple', 'sys_builder_page_html5');
  54. $this->sBaseUrl = BX_DOL_URL_STUDIO . 'builder_page.php';
  55. $this->sTypeUrl = $this->sBaseUrl . '?type=%s';
  56. $this->sPageUrl = $this->sTypeUrl . '&page=%s';
  57. }
  58. function getPageCss()
  59. {
  60. $oTemplate = BxDolStudioTemplate::getInstance();
  61. foreach($this->aUploaders as $sUploader) {
  62. $oUploader = BxDolUploader::getObjectInstance($sUploader, $this->sStorage, '', $oTemplate);
  63. if($oUploader)
  64. $oUploader->addCssJs();
  65. }
  66. return array_merge(parent::getPageCss(), array(
  67. BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'codemirror/|codemirror.css',
  68. 'page_layouts.css',
  69. 'builder_page.css'
  70. ));
  71. }
  72. function getPageJs()
  73. {
  74. return array_merge(parent::getPageJs(), array(
  75. 'codemirror/codemirror.min.js',
  76. 'jquery-ui/jquery.ui.core.min.js',
  77. 'jquery-ui/jquery.ui.widget.min.js',
  78. 'jquery-ui/jquery.ui.mouse.min.js',
  79. 'jquery-ui/jquery.ui.sortable.min.js',
  80. 'jquery.ui.touch-punch.min.js',
  81. 'jquery.easing.js',
  82. 'jquery.form.min.js',
  83. 'functions.js',
  84. 'builder_page.js'
  85. ));
  86. }
  87. function getPageJsObject()
  88. {
  89. return 'oBxDolStudioBuilderPage';
  90. }
  91. function getPageMenu($aMenu = array(), $aMarkers = array())
  92. {
  93. $aMenuItems = array(
  94. BX_DOL_STUDIO_MODULE_SYSTEM => array(
  95. 'name' => BX_DOL_STUDIO_MODULE_SYSTEM,
  96. 'icon' => 'cog',
  97. ),
  98. BX_DOL_STUDIO_MODULE_CUSTOM => array(
  99. 'name' => BX_DOL_STUDIO_MODULE_CUSTOM,
  100. 'icon' => 'wrench',
  101. 'title' => '_adm_bp_cpt_type_' . BX_DOL_STUDIO_MODULE_CUSTOM,
  102. )
  103. );
  104. $aModulesDb = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules'));
  105. foreach($aModulesDb as $aModuleDb) {
  106. $sName = $aModuleDb['name'];
  107. if(!empty($aMenuItems[$sName]))
  108. $aMenuItems[$sName] = array_merge($aMenuItems[$sName], $aModuleDb);
  109. else
  110. $aMenuItems[$sName] = $aModuleDb;
  111. if(empty($aMenuItems[$sName]['icon']))
  112. $aMenuItems[$sName]['icon'] = BxDolStudioUtils::getModuleIcon($aModuleDb, 'menu', false);
  113. }
  114. $aMenu = array();
  115. foreach($aMenuItems as $aMenuItem)
  116. $aMenu[] = array(
  117. 'name' => $aMenuItem['name'],
  118. 'icon' => $aMenuItem['icon'],
  119. 'link' => sprintf($this->sTypeUrl, $aMenuItem['name']),
  120. 'title' => $aMenuItem['title'],
  121. 'selected' => $aMenuItem['name'] == $this->sType
  122. );
  123. return parent::getPageMenu($aMenu);
  124. }
  125. function getPageCode($bHidden = false)
  126. {
  127. $oPage = BxTemplPage::getObjectInstance($this->sPage);
  128. $oTemplate = BxDolStudioTemplate::getInstance();
  129. $sJsObject = $this->getPageJsObject();
  130. $sTxtEmpty = _t('_sys_txt_empty');
  131. $sContent = "";
  132. if(($bPage = $this->sPage != '') === true) {
  133. $aTmplVars = array();
  134. for($i = 1; $i <= $this->aPageRebuild['layout_cells_number']; $i++) {
  135. $aBlocks = array();
  136. $this->oDb->getBlocks(array('type' => 'by_object_cell', 'object' => $this->aPageRebuild['object'], 'cell' => $i), $aBlocks, false);
  137. $aTmplVarsCell = array('id' => $i, 'bx_repeat:blocks' => array());
  138. foreach($aBlocks as $aBlock) {
  139. $sTitle = !empty($aBlock['title_system']) ? _t($aBlock['title_system']) : $oPage->getBlockTitle($aBlock);
  140. list($sIcon, $sIconUrl) = $this->getBlockIcon($aBlock);
  141. $aTmplVarsCell['bx_repeat:blocks'][] = array(
  142. 'html_id' => $this->aHtmlIds['block_id'] . $aBlock['id'],
  143. 'bx_if:is_inactive' => array(
  144. 'condition' => (int)$aBlock['active'] == 0,
  145. 'content' => array()
  146. ),
  147. 'bx_if:show_link' => array(
  148. 'condition' => true,
  149. 'content' => array(
  150. 'onclick' => $sJsObject . ".performAction('block_edit', {id: " . $aBlock['id'] . "})",
  151. 'title' => !empty($sTitle) ? $sTitle : $sTxtEmpty,
  152. )
  153. ),
  154. 'bx_if:show_text' => array(
  155. 'condition' => false,
  156. 'content' => array()
  157. ),
  158. 'bx_if:image' => array (
  159. 'condition' => (bool)$sIconUrl,
  160. 'content' => array('icon_url' => $sIconUrl),
  161. ),
  162. 'bx_if:icon' => array (
  163. 'condition' => (bool)$sIcon,
  164. 'content' => array('icon' => $sIcon),
  165. ),
  166. 'module' => $this->getModuleTitle($aBlock['module']),
  167. 'visible_for' => _t('_adm_bp_txt_visible_for', BxDolStudioUtils::getVisibilityTitle($aBlock['visible_for_levels'])),
  168. 'bx_if:show_checkbox' => array(
  169. 'condition' => false,
  170. 'content' => array()
  171. ),
  172. 'bx_if:show_drag_handle' => array(
  173. 'condition' => true,
  174. 'content' => array()
  175. )
  176. );
  177. }
  178. $aTmplVars['cell_' . $i] = $oTemplate->parseHtmlByName('bp_cell.html', $aTmplVarsCell);
  179. }
  180. $sContent = $oTemplate->parseHtmlByName($this->aPageRebuild['layout_template'], $aTmplVars);
  181. }
  182. $aLanguages = BxDolStudioLanguagesUtils::getInstance()->getLanguages();
  183. $aTmplVars = array(
  184. 'js_object' => $sJsObject,
  185. 'action_url' => $this->sBaseUrl,
  186. 'page_url' => sprintf($this->sPageUrl, '{0}', '{1}'),
  187. 'type' => $this->sType,
  188. 'page' => $this->sPage,
  189. 'html_ids' => json_encode($this->aHtmlIds),
  190. 'languahes' => json_encode($aLanguages),
  191. 'content' => $this->getBlockCode(array(
  192. 'items' => $sContent
  193. ))
  194. );
  195. $oTemplate->addJsTranslation(array(
  196. '_adm_bp_wrn_page_delete',
  197. '_adm_bp_wrn_page_block_delete'
  198. ));
  199. return $oTemplate->parseHtmlByName('builder_page.html', $aTmplVars);
  200. }
  201. function getBlockPanelTop($aBlock)
  202. {
  203. return parent::getBlockPanelTop(
  204. array('panel_top' => BxDolStudioTemplate::getInstance()->parseHtmlByName('bp_block_panel_top.html', $this->_getTmplVarsBlockPanelTop()))
  205. );
  206. }
  207. protected function actionPageCreate()
  208. {
  209. $oTemplate = BxDolStudioTemplate::getInstance();
  210. $sModule = BX_DOL_STUDIO_MODULE_CUSTOM;
  211. $aForm = array(
  212. 'form_attrs' => array(
  213. 'id' => 'adm-bp-page-create',
  214. 'action' => sprintf($this->sPageUrl, $this->sType, $this->sPage) . '&bp_action=' . $this->sActionPageCreate,
  215. 'method' => 'post'
  216. ),
  217. 'params' => array (
  218. 'db' => array(
  219. 'table' => 'sys_objects_page',
  220. 'key' => 'id',
  221. 'uri' => '',
  222. 'uri_title' => '',
  223. 'submit_name' => 'do_submit'
  224. ),
  225. ),
  226. 'inputs' => array (
  227. 'module' => array(
  228. 'type' => 'hidden',
  229. 'name' => 'module',
  230. 'value' => $sModule,
  231. 'db' => array (
  232. 'pass' => 'Xss',
  233. ),
  234. ),
  235. 'deletable' => array(
  236. 'type' => 'hidden',
  237. 'name' => 'deletable',
  238. 'value' => 1,
  239. 'db' => array (
  240. 'pass' => 'Int',
  241. ),
  242. ),
  243. 'settings' => array(
  244. 'type' => 'custom',
  245. 'name' => 'settings',
  246. 'content' => $oTemplate->parseHtmlByName('bp_edit_page_form.html', $this->_getTmplVarsPageSettings()),
  247. ),
  248. )
  249. );
  250. $oForm = new BxTemplStudioFormView($aForm);
  251. $oForm->initChecker();
  252. if($oForm->isSubmittedAndValid()) {
  253. unset($oForm->aInputs['settings']);
  254. foreach($this->aPageSettings as $aSetting)
  255. $oForm->aInputs = array_merge($oForm->aInputs, $this->{'getSettings' . $this->getClassName($aSetting['name']) . 'Fields'}());
  256. $sLanguage = BxDolStudioLanguagesUtils::getInstance()->getCurrentLangName(false);
  257. $sObject = BxDolForm::getSubmittedValue('title-' . $sLanguage, $aForm['form_attrs']['method']);
  258. $sObject = uriGenerate($sObject, 'sys_objects_page', 'object', 'object');
  259. $sUri = $oForm->getCleanValue('uri');
  260. $aPage = array();
  261. $this->oDb->getPages(array('type' => 'by_uri', 'value' => $sUri), $aPage, false);
  262. if(!empty($aPage) && is_array($aPage))
  263. return array('msg' => _t('_adm_bp_err_page_uri'));
  264. $iVisibleFor = BxDolStudioUtils::getVisibilityValue($oForm->getCleanValue('visible_for'), $oForm->getCleanValue('visible_for_levels'));
  265. BxDolForm::setSubmittedValue('visible_for_levels', $iVisibleFor, $aForm['form_attrs']['method']);
  266. unset($oForm->aInputs['visible_for']);
  267. $iId = (int)$oForm->insert(array('object' => $sObject, 'url' => $this->sPageBaseUrl . $sUri));
  268. if($iId != 0)
  269. return array('eval' => $this->getPageJsObject() . '.onCreatePage(\'' . $sModule . '\', \'' . $sObject . '\')');
  270. else
  271. return array('msg' => _t('_adm_bp_err_page_create'));
  272. }
  273. $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['add_popup_id'], _t('_adm_bp_txt_create_popup'), $oTemplate->parseHtmlByName('bp_add_page.html', array(
  274. 'form_id' => $aForm['form_attrs']['id'],
  275. 'form' => $oForm->getCode(true)
  276. )));
  277. return array('popup' => $sContent);
  278. }
  279. protected function actionPageEdit()
  280. {
  281. $sJsObject = $this->getPageJsObject();
  282. $oTemplate = BxDolStudioTemplate::getInstance();
  283. $aForm = array(
  284. 'form_attrs' => array(
  285. 'id' => 'adm-bp-page-edit',
  286. 'action' => sprintf($this->sPageUrl, $this->sType, $this->sPage) . '&bp_action=' . $this->sActionPageEdit,
  287. 'method' => 'post'
  288. ),
  289. 'params' => array (
  290. 'db' => array(
  291. 'table' => 'sys_objects_page',
  292. 'key' => 'id',
  293. 'uri' => '',
  294. 'uri_title' => '',
  295. 'submit_name' => 'do_submit'
  296. ),
  297. ),
  298. 'inputs' => array (
  299. 'settings' => array(
  300. 'type' => 'custom',
  301. 'name' => 'settings',
  302. 'content' => $oTemplate->parseHtmlByName('bp_edit_page_form.html', $this->_getTmplVarsPageSettings($this->aPageRebuild, false)),
  303. ),
  304. )
  305. );
  306. $oForm = new BxTemplStudioFormView($aForm);
  307. $oForm->initChecker();
  308. if($oForm->isSubmittedAndValid()) {
  309. unset($oForm->aInputs['settings']);
  310. foreach($this->aPageSettings as $aSetting)
  311. $oForm->aInputs = array_merge($oForm->aInputs, $this->{'getSettings' . $this->getClassName($aSetting['name']) . 'Fields'}($this->aPageRebuild, false));
  312. $iVisibleFor = BxDolStudioUtils::getVisibilityValue($oForm->getCleanValue('visible_for'), $oForm->getCleanValue('visible_for_levels'));
  313. BxDolForm::setSubmittedValue('visible_for_levels', $iVisibleFor, $aForm['form_attrs']['method']);
  314. unset($oForm->aInputs['visible_for']);
  315. if($oForm->update($this->aPageRebuild['id'])) {
  316. $iLevelId = $oForm->getCleanValue('layout_id');
  317. if(!empty($iLevelId) && $iLevelId != $this->aPageRebuild['layout_id']) {
  318. $aLayoutOld = array();
  319. $this->oDb->getLayouts(array('type' => 'by_id', 'value' => $this->aPageRebuild['layout_id']), $aLayoutOld, false);
  320. $aLayoutNew = array();
  321. $this->oDb->getLayouts(array('type' => 'by_id', 'value' => $iLevelId), $aLayoutNew, false);
  322. if($aLayoutOld['cells_number'] > $aLayoutNew['cells_number'] && $this->oDb->resetBlocksByPage($this->sPage, $aLayoutNew['cells_number']) === false)
  323. return array('msg' => _t('_adm_bp_err_save'));
  324. return array('eval' => $sJsObject . '.onSaveSettings()');
  325. }
  326. return array();
  327. }
  328. else
  329. return array('msg' => _t('_adm_bp_err_save'));
  330. }
  331. $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['edit_popup_id'], _t('_adm_bp_txt_settings_popup'), $oTemplate->parseHtmlByName('bp_edit_page.html', array(
  332. 'form_id' => $aForm['form_attrs']['id'],
  333. 'form' => $oForm->getCode(true)
  334. )));
  335. return array('popup' => $sContent);
  336. }
  337. protected function actionPageDelete()
  338. {
  339. if(empty($this->sPage) || empty($this->aPageRebuild) || !is_array($this->aPageRebuild))
  340. return array('msg' => _t('_adm_bp_err_page_delete'));
  341. $oLangauge = BxDolStudioLanguagesUtils::getInstance();
  342. $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
  343. $aBlocks = array();
  344. $this->oDb->getBlocks(array('type' => 'by_object', 'value' => $this->sPage), $aBlocks, false);
  345. if(is_array($aBlocks) && !empty($aBlocks)) {
  346. foreach($aBlocks as $aBlock)
  347. $this->onBlockDelete($aBlock);
  348. $this->oDb->deleteBlocks(array('type' => 'by_object', 'value' => $this->sPage));
  349. }
  350. if($this->oDb->deletePages(array('type' => 'by_object', 'value' => $this->sPage))) {
  351. $oLangauge->deleteLanguageString($this->aPageRebuild['title_system']);
  352. $oLangauge->deleteLanguageString($this->aPageRebuild['title']);
  353. return array('eval' => 'window.parent.location.href = "' . sprintf($this->sTypeUrl, $this->sType) . '";');
  354. }
  355. return array('msg' => _t('_adm_bp_err_page_delete'));
  356. }
  357. protected function actionBlockList()
  358. {
  359. $sModule = BX_DOL_STUDIO_BP_TYPE_DEFAULT;
  360. if(bx_get('bp_module') !== false)
  361. $sModule = bx_process_input(bx_get('bp_module'));
  362. return array(
  363. 'content' => $this->getBlockList($sModule)
  364. );
  365. }
  366. protected function actionBlockCreate()
  367. {
  368. $sJsObject = $this->getPageJsObject();
  369. $oTemplate = BxDolStudioTemplate::getInstance();
  370. $sSelected = BX_DOL_STUDIO_BP_SKELETONS;
  371. $aForm = array(
  372. 'form_attrs' => array(
  373. 'id' => 'adm-bp-block-create',
  374. 'action' => sprintf($this->sPageUrl, $this->sType, $this->sPage) . '&bp_action=' . $this->sActionBlockCreate,
  375. 'method' => 'post'
  376. ),
  377. 'params' => array (
  378. 'db' => array(
  379. 'table' => 'sys_pages_blocks',
  380. 'key' => 'id',
  381. 'uri' => '',
  382. 'uri_title' => '',
  383. 'submit_name' => 'do_submit'
  384. ),
  385. ),
  386. 'inputs' => array (
  387. 'blocks' => array(
  388. 'type' => 'custom',
  389. 'name' => 'blocks',
  390. 'content' => '',
  391. 'db' => array (
  392. 'pass' => 'Int',
  393. ),
  394. ),
  395. )
  396. );
  397. $aMenu = array(
  398. BX_DOL_STUDIO_BP_SKELETONS => array(
  399. 'name' => BX_DOL_STUDIO_BP_SKELETONS,
  400. 'icon' => 'qrcode',
  401. 'title' => '_sys_block_types_skeletons',
  402. 'selected' => $sSelected == BX_DOL_STUDIO_BP_SKELETONS,
  403. ),
  404. BX_DOL_STUDIO_MODULE_SYSTEM => array(
  405. 'name' => BX_DOL_STUDIO_MODULE_SYSTEM,
  406. 'icon' => 'cog',
  407. 'title' => '_sys_block_types_system',
  408. 'selected' => $sSelected == BX_DOL_STUDIO_MODULE_SYSTEM,
  409. ),
  410. BX_DOL_STUDIO_MODULE_CUSTOM => array(
  411. 'name' => BX_DOL_STUDIO_MODULE_CUSTOM,
  412. 'icon' => 'wrench',
  413. 'title' => '_sys_block_types_custom',
  414. 'selected' => $sSelected == BX_DOL_STUDIO_MODULE_CUSTOM,
  415. )
  416. );
  417. $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules'));
  418. $aModulesWithBlocks = $this->oDb->getModulesWithCopyableBlocks();
  419. foreach($aModules as $aModule) {
  420. $sName = $aModule['name'];
  421. if(!in_array($sName, $aModulesWithBlocks))
  422. continue;
  423. if(!empty($aMenu[$sName]))
  424. $aMenu[$sName] = array_merge($aMenu[$sName], $aModule);
  425. else
  426. $aMenu[$sName] = $aModule;
  427. if(empty($aMenu[$sName]['icon']))
  428. $aMenu[$sName]['icon'] = BxDolStudioUtils::getModuleIcon($aModule, 'menu', false);
  429. }
  430. foreach($aMenu as $sKey => $aItem)
  431. $aMenu[$sKey]['onclick'] = $sJsObject . '.onChangeModule(\'' . $aItem['name'] . '\', this);';
  432. $oMenu = new BxTemplStudioMenu(array('template' => 'menu_side.html', 'menu_items' => $aMenu));
  433. $aTmplParams = array(
  434. 'menu' => $oMenu->getCode(),
  435. 'html_block_lists_id' => $this->aHtmlIds['block_lists_id'],
  436. 'blocks' => $this->getBlockList($sSelected)
  437. );
  438. $aForm['inputs']['blocks']['content'] = $oTemplate->parseHtmlByName('bp_add_block_form.html', $aTmplParams);
  439. $oForm = new BxTemplStudioFormView($aForm);
  440. $oForm->initChecker();
  441. if($oForm->isSubmittedAndValid()) {
  442. $aIds = $oForm->getCleanValue('blocks');
  443. $aBlocks = array();
  444. $this->oDb->getBlocks(array('type' => 'by_ids', 'value' => $aIds), $aBlocks, false);
  445. $oLanguage = BxDolStudioLanguagesUtils::getInstance();
  446. $oStorege = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
  447. $bResult = true;
  448. foreach($aBlocks as $aBlock) {
  449. $sModule = $aBlock['module'];
  450. $sTitleKey = $this->getSystemName($aBlock['title'] . '_' . time());
  451. $aTitleValues = $oLanguage->getLanguageString($aBlock['title']);
  452. unset($aBlock['id']);
  453. $aBlock['object'] = $this->sPage;
  454. $aBlock['cell_id'] = 1;
  455. $aBlock['module'] = $this->getBlockModule($aBlock);
  456. $aBlock['title'] = $sTitleKey;
  457. $aBlock['copyable'] = $sModule == BX_DOL_STUDIO_BP_SKELETONS ? 1 : 0;
  458. $aBlock['deletable'] = 1;
  459. //--- Process Lang copy
  460. $sContentKey = $sContentValue = "";
  461. if($aBlock['type'] == BX_DOL_STUDIO_BP_BLOCK_LANG && $aBlock['content'] != '') {
  462. $sContentKey = $this->getSystemName($aBlock['content'] . '_' . time());
  463. $sContentValue = _t($aBlock['content']);
  464. $aBlock['content'] = $sContentKey;
  465. $oLanguage->addLanguageString($sContentKey, $sContentValue);
  466. }
  467. //--- Process Image copy
  468. $iImageId = $sImageAlign = "";
  469. if($aBlock['type'] == BX_DOL_STUDIO_BP_BLOCK_IMAGE && $aBlock['content'] != '') {
  470. list($iImageId, $sImageAlign) = explode($this->sParamsDivider, $aBlock['content']);
  471. $aBlock['content'] = "";
  472. if(is_numeric($iImageId) && (int)$iImageId != 0 && ($iImageId = $oStorege->storeFileFromStorage(array('id' => $iImageId))) !== false)
  473. $aBlock['content'] = implode($this->sParamsDivider, array($iImageId, $sImageAlign));
  474. }
  475. if(!$this->oDb->insertBlock($aBlock)) {
  476. if($sContentKey != "")
  477. $oLanguage->deleteLanguageString($sContentKey);
  478. if($iImageId != "")
  479. $oStorege->deleteFile((int)$iImageId, 0);
  480. $bResult = false;
  481. break;
  482. }
  483. //--- Process Title copy
  484. foreach($aTitleValues as $iLangId => $aTitleValue)
  485. $oLanguage->addLanguageString($sTitleKey, $aTitleValue['string'], $iLangId);
  486. }
  487. if($bResult)
  488. return array('eval' => $sJsObject . '.onCreateBlock(oData)');
  489. else
  490. return array('msg' => _t('_adm_bp_err_block_added'));
  491. }
  492. $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['create_block_popup_id'], _t('_adm_bp_txt_new_block_popup'), $oTemplate->parseHtmlByName('bp_add_block.html', array(
  493. 'action' => 'create',
  494. 'form_id' => $aForm['form_attrs']['id'],
  495. 'form' => $oForm->getCode(true)
  496. )));
  497. return array('popup' => $sContent);
  498. }
  499. protected function actionBlockEdit()
  500. {
  501. $sJsObject = $this->getPageJsObject();
  502. $oTemplate = BxDolStudioTemplate::getInstance();
  503. $iId = (int)bx_get('id');
  504. if(!$iId)
  505. return array();
  506. $aBlock = array();
  507. $this->oDb->getBlocks(array('type' => 'by_id', 'value' => $iId), $aBlock, false);
  508. if(empty($aBlock) || !is_array($aBlock))
  509. return array('msg' => _t('_adm_bp_err_block_not_found'));
  510. bx_import('BxDolStudioUtils');
  511. $aForm = array(
  512. 'form_attrs' => array(
  513. 'id' => 'adm-bp-block-edit',
  514. 'action' => sprintf($this->sPageUrl, $this->sType, $this->sPage) . '&bp_action=' . $this->sActionBlockEdit,
  515. 'method' => 'post'
  516. ),
  517. 'params' => array (
  518. 'db' => array(
  519. 'table' => 'sys_pages_blocks',
  520. 'key' => 'id',
  521. 'uri' => '',
  522. 'uri_title' => '',
  523. 'submit_name' => 'do_submit'
  524. ),
  525. ),
  526. 'inputs' => array (
  527. 'id' => array(
  528. 'type' => 'hidden',
  529. 'name' => 'id',
  530. 'value' => $iId,
  531. 'db' => array (
  532. 'pass' => 'Int',
  533. ),
  534. ),
  535. 'title' => array(
  536. 'type' => 'text_translatable',
  537. 'name' => 'title',
  538. 'caption' => _t('_adm_bp_txt_block_title'),
  539. 'info' => _t('_adm_bp_dsc_block_title'),
  540. 'value' => $aBlock['title'],
  541. 'required' => '1',
  542. 'db' => array (
  543. 'pass' => 'Xss',
  544. ),
  545. 'checker' => array (
  546. 'func' => 'length',
  547. 'params' => array(3,100),
  548. 'error' => _t('_adm_bp_err_block_title'),
  549. ),
  550. ),
  551. 'designbox_id' => array(
  552. 'type' => 'select',
  553. 'name' => 'designbox_id',
  554. 'caption' => _t('_adm_bp_txt_block_designbox'),
  555. 'info' => '',
  556. 'value' => $this->sSelectKeyPrefix . $aBlock['designbox_id'],
  557. 'values' => array(
  558. array('key' => '', 'value' => _t('_adm_bp_txt_block_designbox_empty')),
  559. ),
  560. 'required' => '1',
  561. 'db' => array (
  562. 'pass' => 'Xss',
  563. ),
  564. 'checker' => array (
  565. 'func' => 'avail',
  566. 'params' => array(),
  567. 'error' => _t('_adm_bp_err_block_designbox'),
  568. ),
  569. ),
  570. 'hidden_on' => array(
  571. 'type' => 'select_multiple',
  572. 'name' => 'hidden_on',
  573. 'caption' => _t('_adm_bp_txt_block_hidden_on'),
  574. 'info' => '',
  575. 'value' => $aBlock['hidden_on'],
  576. 'values' => array(
  577. BX_DB_HIDDEN_PHONE => _t('_adm_bp_txt_block_hidden_on_phone'),
  578. BX_DB_HIDDEN_TABLET => _t('_adm_bp_txt_block_hidden_on_tablet'),
  579. BX_DB_HIDDEN_DESKTOP => _t('_adm_bp_txt_block_hidden_on_desktop')
  580. ),
  581. 'db' => array (
  582. 'pass' => 'Set',
  583. )
  584. ),
  585. 'visible_for' => array(
  586. 'type' => 'select',
  587. 'name' => 'visible_for',
  588. 'caption' => _t('_adm_bp_txt_block_visible_for'),
  589. 'info' => '',
  590. 'value' => $aBlock['visible_for_levels'] == BX_DOL_INT_MAX ? BX_DOL_STUDIO_VISIBLE_ALL : BX_DOL_STUDIO_VISIBLE_SELECTED,
  591. 'values' => array(
  592. array('key' => BX_DOL_STUDIO_VISIBLE_ALL, 'value' => _t('_adm_bp_txt_block_visible_for_all')),
  593. array('key' => BX_DOL_STUDIO_VISIBLE_SELECTED, 'value' => _t('_adm_bp_txt_block_visible_for_selected')),
  594. ),
  595. 'required' => '0',
  596. 'attrs' => array(
  597. 'onchange' => $sJsObject . '.onChangeVisibleFor(this)'
  598. ),
  599. 'db' => array (
  600. 'pass' => 'Xss',
  601. )
  602. ),
  603. 'visible_for_levels' => array(
  604. 'type' => 'checkbox_set',
  605. 'name' => 'visible_for_levels',
  606. 'caption' => _t('_adm_bp_txt_block_visible_for_levels'),
  607. 'info' => _t('_adm_bp_dsc_block_visible_for_levels'),
  608. 'value' => array(),
  609. 'values' => array(),
  610. 'tr_attrs' => array(
  611. 'style' => $aBlock['visible_for_levels'] == BX_DOL_INT_MAX ? 'display:none' : ''
  612. ),
  613. 'db' => array (
  614. 'pass' => 'Int',
  615. )
  616. ),
  617. 'active' => array(
  618. 'type' => 'switcher',
  619. 'name' => 'active',
  620. 'caption' => _t('_adm_bp_txt_block_active'),
  621. 'info' => '',
  622. 'value' => '1',
  623. 'checked' => $aBlock['active'] == '1',
  624. 'db' => array (
  625. 'pass' => 'Int',
  626. )
  627. ),
  628. 'controls' => array(
  629. 'name' => 'controls',
  630. 'type' => 'input_set',
  631. array(
  632. 'type' => 'submit',
  633. 'name' => 'do_submit',
  634. 'value' => _t('_adm_bp_btn_block_save')
  635. ),
  636. array (
  637. 'type' => 'reset',
  638. 'name' => 'close',
  639. 'value' => _t('_adm_bp_btn_block_cancel'),
  640. 'attrs' => array(
  641. 'onclick' => $sJsObject . '.onEditBlockCancel(this)',
  642. 'class' => 'bx-def-margin-sec-left',
  643. ),
  644. )
  645. )
  646. )
  647. );
  648. $aDBoxes = array();
  649. $this->oDb->getDesignBoxes(array('type' => 'ordered'), $aDBoxes, false);
  650. foreach($aDBoxes as $aDBox)
  651. $aForm['inputs']['designbox_id']['values'][] = array('key' => $this->sSelectKeyPrefix . $aDBox['id'], 'value' => _t($aDBox['title']));
  652. BxDolStudioUtils::getVisibilityValues($aBlock['visible_for_levels'], $aForm['inputs']['visible_for_levels']['values'], $aForm['inputs']['visible_for_levels']['value']);
  653. $aForm['inputs'] = $this->addInArray($aForm['inputs'], 'visible_for_levels', $this->getBlockContent($aBlock));
  654. if((int)$aBlock['deletable'] != 0)
  655. $aForm['inputs']['controls'][] = array (
  656. 'type' => 'reset',
  657. 'name' => 'close',
  658. 'value' => _t('_adm_bp_btn_block_delete'),
  659. 'attrs' => array(
  660. 'onclick' => $sJsObject . '.deleteBlock(' . $aBlock['id'] . ')',
  661. 'class' => 'bx-def-margin-sec-left',
  662. ),
  663. );
  664. $oForm = new BxTemplStudioFormView($aForm);
  665. $oForm->initChecker();
  666. if($oForm->isSubmittedAndValid()) {
  667. $this->onSaveBlock($oForm, $aBlock);
  668. if($oForm->update($iId) !== false)
  669. return array('eval' => $sJsObject . '.onEditBlock(oData)');
  670. else
  671. return array('msg' => _t('_adm_bp_err_block_edit'));
  672. }
  673. $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['edit_block_popup_id'], _t('_adm_bp_txt_edit_block_popup', _t($aBlock['title'])), $oTemplate->parseHtmlByName('bp_add_block.html', array(
  674. 'action' => 'edit',
  675. 'form_id' => $aForm['form_attrs']['id'],
  676. 'form' => $oForm->getCode(true)
  677. )));
  678. return array('popup' => array('html' => $sContent, 'options' => array('onBeforeShow' => $sJsObject . '.onEditBlockBeforeShow($el)')));
  679. }
  680. protected function actionBlockDelete()
  681. {
  682. $sJsObject = $this->getPageJsObject();
  683. $iId = (int)bx_get('id');
  684. $aBlock = array();
  685. $this->oDb->getBlocks(array('type' => 'by_id', 'value' => $iId), $aBlock, false);
  686. if(empty($aBlock) || !is_array($aBlock))
  687. return array('msg' => _t('_adm_bp_err_block_not_found'));
  688. if((int)$aBlock['deletable'] == 0)
  689. return array('msg' => _t('_adm_bp_err_block_not_deletable'));
  690. if(!$this->oDb->deleteBlocks(array('type' => 'by_id', 'value' => $iId)))
  691. return array('msg' => _t('_adm_bp_err_block_delete'));
  692. $this->onBlockDelete($aBlock);
  693. return array('eval' => $sJsObject . '.onDeleteBlock(' . $iId . ', oData)');
  694. }
  695. protected function actionImageDelete()
  696. {
  697. $sJsObject = $this->getPageJsObject();
  698. $iId = (int)bx_get('id');
  699. $aBlock = array();
  700. $this->oDb->getBlocks(array('type' => 'by_id', 'value' => $iId), $aBlock, false);
  701. if(empty($aBlock) || !is_array($aBlock))
  702. return array('msg' => _t('_adm_bp_err_block_not_found'));
  703. $iImageId = $sImageAlign = '';
  704. if($aBlock['content'] != '')
  705. list($iImageId, $sImageAlign) = explode($this->sParamsDivider, $aBlock['content']);
  706. if(is_numeric($iImageId) && (int)$iImageId != 0) {
  707. if(!BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES)->deleteFile((int)$iImageId, 0))
  708. return array('msg' => _t('_adm_bp_err_block_content_image_preview_delete'));
  709. $this->oDb->updateBlock($iId, array('content' => ''));
  710. }
  711. return $this->actionBlockEdit();
  712. }
  713. protected function actionUriGet()
  714. {
  715. $oLanguage = BxDolStudioLanguagesUtils::getInstance();
  716. $aLanguages = $oLanguage->getLanguages();
  717. $sLanguageDef = $oLanguage->getDefaultLangName();
  718. $sLanguageCur = $oLanguage->getCurrentLangName(false);
  719. $aValues = array();
  720. foreach($aLanguages as $sName => $sTitle)
  721. if(($mixedValue = bx_get($sName)) !== false)
  722. $aValues[$sName] = bx_process_input($mixedValue);
  723. $sUri = "";
  724. if(($mixedValue = bx_get('uri')) !== false)
  725. $sUri = bx_process_input($mixedValue);
  726. else if(array_key_exists('en', $aValues) && $aValues['en'] != '')
  727. $sUri = $aValues['en'];
  728. else if(array_key_exists($sLanguageDef, $aValues) && $aValues[$sLanguageDef] != '')
  729. $sUri = $aValues[$sLanguageDef];
  730. else if(array_key_exists($sLanguageCur, $aValues) && $aValues[$sLanguageCur] != '')
  731. $sUri = $aValues[$sLanguageCur];
  732. else if(count($aValues) > 0)
  733. foreach($aValues as $sValue)
  734. if(!empty($sValue)) {
  735. $sUri = $sValue;
  736. break;
  737. }
  738. $sUri = $sUri != "" ? uriGenerate($sUri, 'sys_objects_page', 'uri') : "";
  739. $sUrl = BxDolPermalinks::getInstance()->permalink($this->sPageBaseUrl . $sUri);
  740. return array('eval' => $this->getPageJsObject() . '.onGetUri(oData)', 'uri' => $sUri, 'url' => $sUrl);
  741. }
  742. protected function getSettingsOptions($aPage = array(), $bCreate = true, $bInputsOnly = false)
  743. {
  744. $aForm = array(
  745. 'form_attrs' => array(
  746. 'id' => 'adm-bp-settings-options',
  747. ),
  748. 'params' => array (
  749. 'remove_form' => '1',
  750. 'csrf' => array(
  751. 'disable' => true
  752. )
  753. ),
  754. 'inputs' => array (
  755. 'title_system' => array(
  756. 'type' => 'text_translatable',
  757. 'name' => 'title_system',
  758. 'caption' => _t('_adm_bp_txt_page_title_system'),
  759. 'info' => _t('_adm_bp_dsc_page_title_system'),
  760. 'value' => isset($aPage['title_system']) ? $aPage['title_system'] : '',
  761. 'required' => '1',
  762. 'db' => array (
  763. 'pass' => 'Xss',
  764. ),
  765. 'checker' => array (
  766. 'func' => 'length',
  767. 'params' => array(3,100),
  768. 'error' => _t('_adm_bp_err_page_title_system'),
  769. ),
  770. ),
  771. 'title' => array(
  772. 'type' => 'text_translatable',
  773. 'name' => 'title',
  774. 'caption' => _t('_adm_bp_txt_page_title'),
  775. 'info' => _t('_adm_bp_dsc_page_title'),
  776. 'value' => isset($aPage['title']) ? $aPage['title'] : '',
  777. 'required' => '1',
  778. 'db' => array (
  779. 'pass' => 'Xss',
  780. ),
  781. 'checker' => array (
  782. 'func' => 'length',
  783. 'params' => array(3,100),
  784. 'error' => _t('_adm_bp_err_page_title'),
  785. ),
  786. ),
  787. 'url' => array(
  788. 'type' => 'text',
  789. 'name' => 'url',
  790. 'caption' => _t('_adm_bp_txt_page_url'),
  791. 'info' => _t('_adm_bp_dsc_page_url'),
  792. 'value' => isset($aPage['url']) ? BxDolPermalinks::getInstance()->permalink($aPage['url']) : '',
  793. 'required' => '0',
  794. 'attrs' => array(
  795. 'id' => $this->aHtmlIds['url_field_id'],
  796. 'disabled' => 'disabled'
  797. ),
  798. ),
  799. )
  800. );
  801. if($bCreate) {
  802. $sJsObject = $this->getPageJsObject();
  803. $aForm['inputs']['title']['attrs']['onblur'] = $sJsObject . '.getUri(this);';
  804. $aForm['inputs'] = bx_array_insert_before(array(
  805. 'uri' => array(
  806. 'type' => 'text',
  807. 'name' => 'uri',
  808. 'caption' => _t('_adm_bp_txt_page_uri'),
  809. 'info' => _t('_adm_bp_dsc_page_uri'),
  810. 'value' => '',
  811. 'required' => '1',
  812. 'attrs' => array(
  813. 'id' => $this->aHtmlIds['uri_field_id'],
  814. 'onblur' => $sJsObject . '.getUri(this);'
  815. ),
  816. 'db' => array (
  817. 'pass' => 'Xss',
  818. ),
  819. 'checker' => array (
  820. 'func' => 'length',
  821. 'params' => array(3,100),
  822. 'error' => _t('_adm_bp_err_page_uri'),
  823. ),
  824. )
  825. ), $aForm['inputs'], 'url');
  826. }
  827. if($bInputsOnly)
  828. return $aForm['inputs'];
  829. $oForm = new BxTemplStudioFormView($aForm);
  830. return $oForm->getCode();
  831. }
  832. protected function getSettingsOptionsFields($aPage = array(), $bCreate = true)
  833. {
  834. return $this->getSettingsOptions($aPage, $bCreate, true);
  835. }
  836. protected function getSettingsCover($aPage = array(), $bCreate = true, $bInputsOnly = false)
  837. {
  838. $aForm = array(
  839. 'form_attrs' => array(
  840. 'id' => 'adm-bp-settings-cover',
  841. ),
  842. 'params' => array (
  843. 'remove_form' => '1',
  844. 'csrf' => array(
  845. 'disable' => true
  846. )
  847. ),
  848. 'inputs' => array (
  849. 'cover' => array(
  850. 'type' => 'switcher',
  851. 'name' => 'cover',
  852. 'caption' => _t('_adm_bp_txt_page_cover'),
  853. 'info' => '',
  854. 'value' => '1',
  855. 'checked' => $aPage['cover'] == '1',
  856. 'db' => array (
  857. 'pass' => 'Int',
  858. )
  859. ),
  860. 'cover_image' => array(
  861. 'type' => 'files',
  862. 'name' => 'cover_image',
  863. 'storage_object' => $this->sStorage,
  864. 'images_transcoder' => $this->sTranscoder,
  865. 'uploaders' => array ('sys_html5'),
  866. 'multiple' => false,
  867. 'content_id' => $aPage['id'],
  868. 'ghost_template' => BxDolStudioTemplate::getInstance()->parseHtmlByName('bp_fgt_cover.html', array(
  869. 'name' => 'cover_image',
  870. )),
  871. 'caption' => _t('_adm_bp_txt_page_cover_image'),
  872. 'db' => array (
  873. 'pass' => 'Int',
  874. )
  875. )
  876. )
  877. );
  878. if($bInputsOnly)
  879. return $aForm['inputs'];
  880. $oForm = new BxTemplStudioFormView($aForm);
  881. return $oForm->getCode();
  882. }
  883. protected function getSettingsCoverFields($aPage = array(), $bCreate = true)
  884. {
  885. return $this->getSettingsCover($aPage, $bCreate, true);
  886. }
  887. protected function getSettingsLayout($aPage = array(), $bCreate = true, $bInputsOnly = false)
  888. {
  889. $sJsObject = $this->getPageJsObject();
  890. $oTemplate = BxDolStudioTemplate::getInstance();
  891. $iLayout = isset($aPage['layout_id']) ? (int)$aPage['layout_id'] : 5;
  892. $aLayouts = array();
  893. $this->oDb->getLayouts(array('type' => 'all'), $aLayouts, false);
  894. $aTmplParams = array(
  895. 'bx_repeat:layouts' => array(),
  896. 'form' => ''
  897. );
  898. foreach($aLayouts as $aLayout)
  899. $aTmplParams['bx_repeat:layouts'][] = array(
  900. 'id' => $aLayout['id'],
  901. 'html_id' => $this->aHtmlIds['layout_id'] . $aLayout['id'],
  902. 'js_object' => $sJsObject,
  903. 'bx_if:active' => array(
  904. 'condition' => (int)$aLayout['id'] == $iLayout,
  905. 'content' => array()
  906. ),
  907. 'icon' => $oTemplate->getImageUrl($aLayout['icon']),
  908. 'title' => _t($aLayout['title']),
  909. );
  910. $aForm = array(
  911. 'form_attrs' => array(
  912. 'id' => 'adm-bp-settings-layout',
  913. ),
  914. 'params' => array (
  915. 'remove_form' => '1',
  916. 'csrf' => array(
  917. 'disable' => true
  918. )
  919. ),
  920. 'inputs' => array (
  921. 'layout_id' => array(
  922. 'type' => 'hidden',
  923. 'name' => 'layout_id',
  924. 'value' => $iLayout,
  925. 'db' => array (
  926. 'pass' => 'Int',
  927. ),
  928. )
  929. )
  930. );
  931. if($bInputsOnly)
  932. return $aForm['inputs'];
  933. $oForm = new BxTemplStudioFormView($aForm);
  934. $aTmplParams['form'] = $oForm->getCode();
  935. return $oTemplate->parseHtmlByName('bp_layouts.html', $aTmplParams);
  936. }
  937. protected function getSettingsLayoutFields($aPage = array(), $bCreate = true)
  938. {
  939. return $this->getSettingsLayout($aPage, $bCreate, true);
  940. }
  941. protected function getSettingsVisibility($aPage = array(), $bCreate = true, $bInputsOnly = false)
  942. {
  943. $iVisibleForLevels = isset($aPage['visible_for_levels']) ? (int)$aPage['visible_for_levels'] : BX_DOL_INT_MAX;
  944. if(isset($aPage['visible_for_levels_editable']) && (int)$aPage['visible_for_levels_editable'] == 0)
  945. $aInputs = array(
  946. 'visible_for_levels' => array(
  947. 'type' => 'custom',
  948. 'name' => 'visible_for_levels',
  949. 'content' => MsgBox(_t('_adm_bp_err_page_visible_for_levels'))
  950. )
  951. );
  952. else
  953. bx_import('BxDolStudioUtils');
  954. $aInputs = array(
  955. 'visible_for' => array(
  956. 'type' => 'select',
  957. 'name' => 'visible_for',
  958. 'caption' => _t('_adm_bp_txt_block_visible_for'),
  959. 'info' => '',
  960. 'value' => $iVisibleForLevels == BX_DOL_INT_MAX ? BX_DOL_STUDIO_VISIBLE_ALL : BX_DOL_STUDIO_VISIBLE_SELECTED,
  961. 'values' => array(
  962. array('key' => BX_DOL_STUDIO_VISIBLE_ALL, 'value' => _t('_adm_bp_txt_block_visible_for_all')),
  963. array('key' => BX_DOL_STUDIO_VISIBLE_SELECTED, 'value' => _t('_adm_bp_txt_block_visible_for_selected')),
  964. ),
  965. 'required' => '0',
  966. 'attrs' => array(
  967. 'onchange' => $this->getPageJsObject() . '.onChangeVisibleFor(this)'
  968. ),
  969. 'db' => array (
  970. 'pass' => 'Xss',
  971. )
  972. ),
  973. 'visible_for_levels' => array(
  974. 'type' => 'checkbox_set',
  975. 'name' => 'visible_for_levels',
  976. 'caption' => _t('_adm_bp_txt_page_visible_for_levels'),
  977. 'info' => _t('_adm_bp_dsc_page_visible_for_levels'),
  978. 'value' => '',
  979. 'values' => array(),
  980. 'tr_attrs' => array(
  981. 'style' => $iVisibleForLevels == BX_DOL_INT_MAX ? 'display:none' : ''
  982. ),
  983. 'db' => array (
  984. 'pass' => 'Int',
  985. )
  986. )
  987. );
  988. $aForm = array(
  989. 'form_attrs' => array(
  990. 'id' => 'adm-bp-settings-visibility',
  991. ),
  992. 'params' => array (
  993. 'remove_form' => '1',
  994. 'csrf' => array(
  995. 'disable' => true
  996. )
  997. ),
  998. 'inputs' => $aInputs
  999. );
  1000. BxDolStudioUtils::getVisibilityValues($iVisibleForLevels, $aForm['inputs']['visible_for_levels']['values'], $aForm['inputs']['visible_for_levels']['value']);
  1001. if($bInputsOnly)
  1002. return $aForm['inputs'];
  1003. $oForm = new BxTemplStudioFormView($aForm);
  1004. return $oForm->getCode();
  1005. }
  1006. protected function getSettingsVisibilityFields($aPage = array(), $bCreate = true)
  1007. {
  1008. return $this->getSettingsVisibility($aPage = array(), $bCreate, true);
  1009. }
  1010. protected function getSettingsCache($aPage = array(), $bCreate = true, $bInputsOnly = false)
  1011. {
  1012. $aForm = array(
  1013. 'form_attrs' => array(
  1014. 'id' => 'adm-bp-settings-cache',
  1015. ),
  1016. 'params' => array (
  1017. 'remove_form' => '1',
  1018. 'csrf' => array(
  1019. 'disable' => true
  1020. )
  1021. ),
  1022. 'inputs' => array (
  1023. 'cache_lifetime' => array(
  1024. 'type' => 'text',
  1025. 'name' => 'cache_lifetime',
  1026. 'caption' => _t('_adm_bp_txt_page_cache_lifetime'),
  1027. 'info' => _t('_adm_bp_dsc_page_cache_lifetime'),
  1028. 'value' => isset($aPage['cache_lifetime']) ? $aPage['cache_lifetime'] : 0,
  1029. 'required' => '',
  1030. 'attrs' => array(
  1031. 'disabled' => isset($aPage['cache_editable']) && (int)$aPage['cache_editable'] == 0 ? 'disabled' : ''
  1032. ),
  1033. 'db' => array (
  1034. 'pass' => 'Int',
  1035. )
  1036. ),
  1037. )
  1038. );
  1039. if($bInputsOnly)
  1040. return $aForm['inputs'];
  1041. $oForm = new BxTemplStudioFormView($aForm);
  1042. return $oForm->getCode();
  1043. }
  1044. protected function getSettingsCacheFields($aPage = array(), $bCreate = true)
  1045. {
  1046. return $this->getSettingsCache($aPage, $bCreate, true);
  1047. }
  1048. protected function getSettingsSeo($aPage = array(), $bCreate = true, $bInputsOnly = false)
  1049. {
  1050. $aForm = array(
  1051. 'form_attrs' => array(
  1052. 'id' => 'adm-bp-settings-seo',
  1053. ),
  1054. 'params' => array (
  1055. 'remove_form' => '1',
  1056. 'csrf' => array(
  1057. 'disable' => true
  1058. )
  1059. ),
  1060. 'inputs' => array (
  1061. 'meta_description' => array(
  1062. 'type' => 'textarea',
  1063. 'name' => 'meta_description',
  1064. 'caption' => _t('_adm_bp_txt_page_meta_description'),
  1065. 'info' => _t('_adm_bp_dsc_page_meta_description'),
  1066. 'value' => isset($aPage['meta_description']) ? $aPage['meta_description'] : '',
  1067. 'db' => array (
  1068. 'pass' => 'Xss',
  1069. ),
  1070. ),
  1071. 'meta_keywords' => array(
  1072. 'type' => 'textarea',
  1073. 'name' => 'meta_keywords',
  1074. 'caption' => _t('_adm_bp_txt_page_meta_keywords'),
  1075. 'info' => _t('_adm_bp_dsc_page_meta_keywords'),
  1076. 'value' => isset($aPage['meta_keywords']) ? $aPage['meta_keywords'] : '',
  1077. 'db' => array (
  1078. 'pass' => 'Xss',
  1079. ),
  1080. ),
  1081. 'meta_robots' => array(
  1082. 'type' => 'text',
  1083. 'name' => 'meta_robots',
  1084. 'caption' => _t('_adm_bp_txt_page_meta_robots'),
  1085. 'info' => _t('_adm_bp_dsc_page_meta_robots'),
  1086. 'value' => isset($aPage['meta_robots']) ? $aPage['meta_robots'] : '',
  1087. 'required' => '0',
  1088. 'db' => array (
  1089. 'pass' => 'Xss',
  1090. )
  1091. )
  1092. )
  1093. );
  1094. if($bInputsOnly)
  1095. return $aForm['inputs'];
  1096. $oForm = new BxTemplStudioFormView($aForm);
  1097. return $oForm->getCode();
  1098. }
  1099. protected function getSettingsSeoFields($aPage = array(), $bCreate = true)
  1100. {
  1101. return $this->getSettingsSeo($aPage, $bCreate, true);
  1102. }
  1103. protected function getBlockIcon($aBlock)
  1104. {
  1105. $sIcon = $sIconUrl = "";
  1106. $sResult = '';
  1107. switch($aBlock['type']) {
  1108. case BX_DOL_STUDIO_BP_BLOCK_RAW:
  1109. $sResult = 'file-text-o';
  1110. break;
  1111. case BX_DOL_STUDIO_BP_BLOCK_HTML:
  1112. $sResult = 'code';
  1113. break;
  1114. case BX_DOL_STUDIO_BP_BLOCK_RSS:
  1115. $sResult = 'rss';
  1116. break;
  1117. case BX_DOL_STUDIO_BP_BLOCK_IMAGE:
  1118. $sResult = 'picture-o';
  1119. break;
  1120. case BX_DOL_STUDIO_BP_BLOCK_LANG:
  1121. $sResult = 'globe';
  1122. break;
  1123. case BX_DOL_STUDIO_BP_BLOCK_MENU:
  1124. $sResult = 'list-alt';
  1125. break;
  1126. case BX_DOL_STUDIO_BP_BLOCK_SERVICE:
  1127. $sResult = $this->getModuleIcon($aBlock['module'], 'page');
  1128. break;
  1129. }
  1130. if(strpos($sResult, '.') === false)
  1131. $sIcon = $sResult;
  1132. else
  1133. $sIconUrl = $sResult;
  1134. return array($sIcon, $sIconUrl);
  1135. }
  1136. protected function getBlockModule($aBlock)
  1137. {
  1138. return $aBlock['module'] != BX_DOL_STUDIO_BP_SKELETONS ? $aBlock['module'] : BX_DOL_STUDIO_MODULE_CUSTOM;
  1139. }
  1140. protected function getBlockContent($aBlock)
  1141. {
  1142. $aFields = array();
  1143. switch($aBlock['type']) {
  1144. case BX_DOL_STUDIO_BP_BLOCK_RAW:
  1145. $aFields = array(
  1146. 'content' => array(
  1147. 'type' => 'textarea',
  1148. 'name' => 'content',
  1149. 'caption' => _t('_adm_bp_txt_block_content_raw'),
  1150. 'info' => _t('_adm_bp_dsc_block_content_raw'),
  1151. 'value' => $aBlock['content'],
  1152. 'required' => '0',
  1153. 'code' => 1,
  1154. 'attrs' => array('class' => 'bx-form-input-textarea-codemirror'),
  1155. 'db' => array (
  1156. 'pass' => 'XssHtml',
  1157. ),
  1158. ),
  1159. );
  1160. break;
  1161. case BX_DOL_STUDIO_BP_BLOCK_HTML:
  1162. $aFields = array(
  1163. 'content' => array(
  1164. 'type' => 'textarea',
  1165. 'name' => 'content',
  1166. 'caption' => _t('_adm_bp_txt_block_content_raw'),
  1167. 'info' => _t('_adm_bp_dsc_block_content_raw'),
  1168. 'value' => $aBlock['content'],
  1169. 'required' => '0',
  1170. 'html' => 1,
  1171. 'attrs' => array('id' => $this->aHtmlIds['edit_block_editor_id']),
  1172. 'db' => array (
  1173. 'pass' => 'XssHtml',
  1174. ),
  1175. ),
  1176. 'attachments' => array(
  1177. 'type' => 'files',
  1178. 'name' => 'attachments',
  1179. 'storage_object' => $this->sStorage,
  1180. 'images_transcoder' => $this->sTranscoder,
  1181. 'uploaders' => $this->aUploaders,
  1182. 'multiple' => true,
  1183. 'content_id' => $aBlock['id'],
  1184. 'ghost_template' => BxDolStudioTemplate::getInstance()->parseHtmlByName('bp_fgt_attachments.html', array(
  1185. 'js_object' => $this->getPageJsObject(),
  1186. 'name' => 'attachments',
  1187. 'editor_id' => $this->aHtmlIds['edit_block_editor_id'],
  1188. )),
  1189. 'caption' => _t('_adm_bp_txt_block_content_attachments_html')
  1190. )
  1191. );
  1192. break;
  1193. case BX_DOL_STUDIO_BP_BLOCK_LANG:
  1194. $aFields = array(
  1195. 'content' => array(
  1196. 'type' => 'textarea',
  1197. 'name' => 'content',
  1198. 'caption' => _t('_adm_bp_txt_block_content_lang'),
  1199. 'info' => _t('_adm_bp_dsc_block_content_lang'),
  1200. 'value' => $aBlock['content'] != '' ? _t($aBlock['content']) : '',
  1201. 'required' => '0',
  1202. 'html' => 1,
  1203. 'db' => array (
  1204. 'pass' => 'XssHtml',
  1205. ),
  1206. ),
  1207. );
  1208. break;
  1209. case BX_DOL_STUDIO_BP_BLOCK_IMAGE:
  1210. $iImageId = $sImageAlign = '';
  1211. if($aBlock['content'] != '')
  1212. list($iImageId, $sImageAlign) = explode($this->sParamsDivider, $aBlock['content']);
  1213. $aFields = array(
  1214. 'content' => array(
  1215. 'type' => 'hidden',
  1216. 'name' => 'content',
  1217. 'value' => '',
  1218. 'db' => array (
  1219. 'pass' => 'Xss',
  1220. ),
  1221. ),
  1222. 'image_file' => array(
  1223. 'type' => 'image_uploader',
  1224. 'name' => 'image_file',
  1225. 'caption' => _t('_adm_bp_txt_block_content_image_file'),
  1226. 'caption_preview' => _t('_adm_bp_txt_block_content_image_preview'),
  1227. 'info' => _t('_adm_bp_dsc_block_content_image_file'),
  1228. 'ajax_action_delete' => $this->getPageJsObject() . '.deleteBlockImage(' . $aBlock['id'] . ')',
  1229. 'value' => (int)$iImageId
  1230. ),
  1231. 'image_align' => array(
  1232. 'type' => 'select',
  1233. 'name' => 'image_align',
  1234. 'caption' => _t('_adm_bp_txt_block_content_image_align'),
  1235. 'info' => '',
  1236. 'value' => $sImageAlign,
  1237. 'values' => array(
  1238. array('key' => '', 'value' => _t('_adm_bp_txt_block_content_image_align_empty')),
  1239. array('key' => 'left', 'value' => _t('_adm_bp_txt_block_content_image_align_left')),
  1240. array('key' => 'center', 'value' => _t('_adm_bp_txt_block_content_image_align_center')),
  1241. array('key' => 'right', 'value' => _t('_adm_bp_txt_block_content_image_align_right')),
  1242. ),
  1243. 'required' => '0',
  1244. 'db' => array (
  1245. 'pass' => 'Xss',
  1246. ),
  1247. ),
  1248. );
  1249. break;
  1250. case BX_DOL_STUDIO_BP_BLOCK_RSS:
  1251. $sRssUrl = $sRssLength = '';
  1252. if($aBlock['content'] != '')
  1253. list($sRssUrl, $sRssLength) = explode($this->sParamsDivider, $aBlock['content']);
  1254. $aFields = array(
  1255. 'content' => array(
  1256. 'type' => 'hidden',
  1257. 'name' => 'content',
  1258. 'value' => '',
  1259. 'db' => array (
  1260. 'pass' => 'Xss',
  1261. ),
  1262. ),
  1263. 'rss_url' => array(
  1264. 'type' => 'text',
  1265. 'name' => 'rss_url',
  1266. 'caption' => _t('_adm_bp_txt_block_content_rss_url'),
  1267. 'info' => _t('_adm_bp_dsc_block_content_rss_url'),
  1268. 'value' => $sRssUrl,
  1269. 'required' => '0',
  1270. 'db' => array (
  1271. 'pass' => 'Xss',
  1272. ),
  1273. ),
  1274. 'rss_length' => array(
  1275. 'type' => 'text',
  1276. 'name' => 'rss_length',
  1277. 'caption' => _t('_adm_bp_txt_block_content_rss_length'),
  1278. 'info' => _t('_adm_bp_dsc_block_content_rss_length'),
  1279. 'value' => $sRssLength,
  1280. 'required' => '0',
  1281. 'db' => array (
  1282. 'pass' => 'Int',
  1283. ),
  1284. ),
  1285. );
  1286. break;
  1287. case BX_DOL_STUDIO_BP_BLOCK_MENU:
  1288. $aFields = array(
  1289. 'content' => array(
  1290. 'type' => 'select',
  1291. 'name' => 'content',
  1292. 'caption' => _t('_adm_bp_txt_block_content_menu'),
  1293. 'info' => '',
  1294. 'value' => $aBlock['content'],
  1295. 'values' => array(),
  1296. 'required' => '0',
  1297. 'db' => array (
  1298. 'pass' => 'Xss',
  1299. ),
  1300. )
  1301. );
  1302. $aMenus = $this->oDb->getMenus();
  1303. foreach($aMenus as $sKey => $sValue)
  1304. $aFields['content']['values'][$sKey] = _t($sValue);
  1305. asort($aFields['content']['values']);
  1306. $aFields['content']['values'] = array_merge(array('' => _t('_adm_bp_txt_block_content_menu_empty')), $aFields['content']['values']);
  1307. break;
  1308. case BX_DOL_STUDIO_BP_BLOCK_SERVICE:
  1309. $aService = array('module' => '', 'method' => '');
  1310. if($aBlock['content'] != '')
  1311. $aService = unserialize($aBlock['content']);
  1312. $aFields = array(
  1313. 'service_module' => array(
  1314. 'type' => 'value',
  1315. 'name' => 'service_module',
  1316. 'caption' => _t('_adm_bp_txt_block_content_service_module'),
  1317. 'value' => $this->getModuleTitle($aService['module'])
  1318. ),
  1319. 'service_method' => array(
  1320. 'type' => 'value',
  1321. 'name' => 'service_method',
  1322. 'caption' => _t('_adm_bp_txt_block_content_service_method'),
  1323. 'value' => $aService['method']
  1324. )
  1325. );
  1326. break;
  1327. }
  1328. return $aFields;
  1329. }
  1330. protected function getBlockList($sModule)
  1331. {
  1332. if(empty($sModule))
  1333. return '';
  1334. $sJsObject = $this->getPageJsObject();
  1335. $oTemplate = BxDolStudioTemplate::getInstance();
  1336. $oForm = new BxTemplStudioFormView(array());
  1337. $aInputCheckbox = array(
  1338. 'type' => 'checkbox',
  1339. 'name' => 'blocks[]',
  1340. 'attrs' => array(
  1341. 'onChange' => 'javascript:' . $sJsObject . '.onSelectBlock(this);'
  1342. ),
  1343. 'value' => ''
  1344. );
  1345. $aTmplParams = array(
  1346. 'html_block_list_id' => $this->aHtmlIds['block_list_id'] . $sModule,
  1347. 'bx_repeat:blocks' => array()
  1348. );
  1349. $aBlocks = $this->getBlocks($sModule);
  1350. foreach($aBlocks as $aBlock) {
  1351. list($sIcon, $sIconUrl) = $this->getBlockIcon($aBlock);
  1352. $aInputCheckbox['value'] = $aBlock['id'];
  1353. $aTmplParams['bx_repeat:blocks'][] = array(
  1354. 'js_object' => $sJsObject,
  1355. 'html_id' => $this->aHtmlIds['block_id'] . $aBlock['id'],
  1356. 'bx_if:is_inactive' => array(
  1357. 'condition' => false,
  1358. 'content' => array()
  1359. ),
  1360. 'bx_if:show_link' => array(
  1361. 'condition' => false,
  1362. 'content' => array()
  1363. ),
  1364. 'bx_if:show_text' => array(
  1365. 'condition' => true,
  1366. 'content' => array(
  1367. 'title' => _t(!empty($aBlock['title_system']) ? $aBlock['title_system'] : $aBlock['title']),
  1368. )
  1369. ),
  1370. 'bx_if:image' => array (
  1371. 'condition' => (bool)$sIconUrl,
  1372. 'content' => array('icon_url' => $sIconUrl),
  1373. ),
  1374. 'bx_if:icon' => array (
  1375. 'condition' => (bool)$sIcon,
  1376. 'content' => array('icon' => $sIcon),
  1377. ),
  1378. 'module' => $this->getModuleTitle($aBlock['module']),
  1379. 'visible_for' => _t('_adm_bp_txt_visible_for', BxDolStudioUtils::getVisibilityTitle($aBlock['visible_for_levels'])),
  1380. 'bx_if:show_checkbox' => array(
  1381. 'condition' => true,
  1382. 'content' => array(
  1383. 'content' => $oForm->genRow($aInputCheckbox)
  1384. )
  1385. ),
  1386. 'bx_if:show_drag_handle' => array(
  1387. 'condition' => false,
  1388. 'content' => array()
  1389. )
  1390. );
  1391. }
  1392. return $oTemplate->parseHtmlByName('bp_blocks_list.html', $aTmplParams);
  1393. }
  1394. protected function onBlockDelete($aBlock)
  1395. {
  1396. if($aBlock['module'] != BX_DOL_STUDIO_MODULE_CUSTOM)
  1397. return;
  1398. BxDolStudioLanguagesUtils::getInstance()->deleteLanguageString($aBlock['title']);
  1399. //--- Process Lang block
  1400. if($aBlock['type'] == BX_DOL_STUDIO_BP_BLOCK_LANG && $aBlock['content'] != '')
  1401. BxDolStudioLanguagesUtils::getInstance()->deleteLanguageString($aBlock['content']);
  1402. //--- Process Image block
  1403. if($aBlock['type'] == BX_DOL_STUDIO_BP_BLOCK_IMAGE && $aBlock['content'] != '') {
  1404. $iImageId = $sImageAlign = '';
  1405. list($iImageId, $sImageAlign) = explode($this->sParamsDivider, $aBlock['content']);
  1406. if(is_numeric($iImageId) && (int)$iImageId != 0)
  1407. BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES)->deleteFile((int)$iImageId, 0);
  1408. }
  1409. }
  1410. protected function getBlocks($sModule)
  1411. {
  1412. $aBlocks = array();
  1413. $this->oDb->getBlocks(array('type' => 'by_module_to_copy', 'value' => $sModule), $aBlocks, false);
  1414. return $aBlocks;
  1415. }
  1416. protected function _getTmplVarsBlockPanelTop()
  1417. {
  1418. $sJsObject = $this->getPageJsObject();
  1419. $oForm = new BxTemplStudioFormView(array());
  1420. $aInputPages = array(
  1421. 'type' => 'select',
  1422. 'name' => 'page',
  1423. 'attrs' => array(
  1424. 'onChange' => 'javascript:' . $this->getPageJsObject() . '.onChangePage(this)'
  1425. ),
  1426. 'value' => $this->sPage,
  1427. 'values' => array(
  1428. array('key' => '', 'value' => _t('_adm_bp_txt_select_page'))
  1429. )
  1430. );
  1431. $aPages = $aCounter = array();
  1432. $this->oDb->getPages(array('type' => 'by_module', 'value' => $this->sType), $aPages, false);
  1433. $this->oDb->getBlocks(array('type' => 'counter_by_pages'), $aCounter, false);
  1434. foreach($aPages as $aPage)
  1435. $aInputPages['values'][] = array('key' => $aPage['object'], 'value' => _t($aPage['title_system']) . " (" . (isset($aCounter[$aPage['object']]) ? $aCounter[$aPage['object']] : "0") . ")");
  1436. $aTmplVarsActions = array();
  1437. if(($this->sPage != '' && !empty($this->aPageRebuild)) !== false)
  1438. $aTmplVarsActions = $this->_getTmplVarsBlockPanelTopActions();
  1439. return array(
  1440. 'js_object' => $this->getPageJsObject(),
  1441. 'selector' => $oForm->genRow($aInputPages),
  1442. 'action_page_create' => $this->sActionPageCreate,
  1443. 'bx_if:show_actions' => array(
  1444. 'condition' => $this->sPage != '',
  1445. 'content' => $aTmplVarsActions
  1446. )
  1447. );
  1448. }
  1449. protected function _getTmplVarsBlockPanelTopActions()
  1450. {
  1451. $sJsObject = $this->getPageJsObject();
  1452. $oPermalinks = BxDolPermalinks::getInstance();
  1453. return array(
  1454. 'js_object' => $sJsObject,
  1455. 'url_view' => BX_DOL_URL_ROOT . $oPermalinks->permalink($this->aPageRebuild['url']),
  1456. 'action_page_edit' => $this->sActionPageEdit,
  1457. 'bx_if:can_delete' => array(
  1458. 'condition' => (int)$this->aPageRebuild['deletable'] == 1,
  1459. 'content' => array(
  1460. 'js_object' => $sJsObject
  1461. )
  1462. ),
  1463. 'action_block_create' => $this->sActionBlockCreate,
  1464. );
  1465. }
  1466. protected function _getTmplVarsPageSettings($aPage = array(), $bCreate = true)
  1467. {
  1468. $sJsObject = $this->getPageJsObject();
  1469. $aTmplParams = array(
  1470. 'menu' => array(),
  1471. 'html_settings_groups_id' => $this->aHtmlIds['settings_groups_id'],
  1472. 'bx_repeat:settings_groups' => array(),
  1473. 'submit' => _t($bCreate ? '_adm_bp_btn_page_create' : '_adm_bp_btn_page_apply')
  1474. );
  1475. foreach($this->aPageSettings as $aSetting) {
  1476. //--- get menu items
  1477. $aTmplParams['menu'][$aSetting['name']] = array(
  1478. 'name' => $aSetting['name'],
  1479. 'icon' => '',
  1480. 'onclick' => $sJsObject . '.onChangeSettingGroup(\'' . $aSetting['name'] . '\', this);',
  1481. 'title' => $aSetting['title'],
  1482. 'selected' => isset($aSetting['active']) && (int)$aSetting['active'] == 1
  1483. );
  1484. //--- get settings
  1485. $aTmplParams['bx_repeat:settings_groups'][] = array(
  1486. 'html_settings_group_id' => $this->aHtmlIds['settings_group_id'] . $aSetting['name'],
  1487. 'bx_if:hidden' => array(
  1488. 'condition' => $aSetting['active'] != 1,
  1489. 'content' => array()
  1490. ),
  1491. 'content' => $this->{'getSettings' . $this->getClassName($aSetting['name'])}($aPage, $bCreate)
  1492. );
  1493. }
  1494. $oMenu = new BxTemplStudioMenu(array('template' => 'menu_side.html', 'menu_items' => $aTmplParams['menu']));
  1495. $aTmplParams['menu'] = $oMenu->getCode();
  1496. return $aTmplParams;
  1497. }
  1498. }
  1499. /** @} */