| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523 |
- <?php
- /**
- * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
- * CC-BY License - http://creativecommons.org/licenses/by/3.0/
- *
- * @defgroup DolphinView Dolphin Studio Representation classes
- * @ingroup DolphinStudio
- * @{
- */
- defined('BX_DOL') or die('hack attempt');
- bx_import('BxDolStudioUtils');
- bx_import('BxDolStudioBuilderPage');
- bx_import('BxTemplStudioFormView');
- class BxBaseStudioBuilderPage extends BxDolStudioBuilderPage {
- protected $sParamsDivider = '#';
- protected $sSelectKeyPrefix = 'id-';
- protected $sActionPageCreate = 'page_create';
- protected $sActionPageDelete = 'page_delete';
- protected $sActionPageEdit = 'page_edit';
- protected $sActionBlockCreate = 'block_create';
- protected $sActionBlockEdit = 'block_edit';
- protected $sBaseUrl;
- protected $sTypeUrl;
- protected $sPageUrl;
- protected $aHtmlIds = array(
- 'create_popup_id' => 'adm-bp-create-popup',
- 'edit_popup_id' => 'adm-bp-edit-popup',
- 'uri_field_id' => 'adm-bp-field-uri',
- 'settings_group_id' => 'adm-bp-settings-group-',
- 'settings_groups_id' => 'adm-bp-settings-groups',
- 'create_block_popup_id' => 'adm-bp-create-block-popup',
- 'edit_block_popup_id' => 'adm-bp-edit-block-popup',
- 'block_id' => 'adm-bpb-',
- 'block_list_id' => 'adm-bpl-',
- 'block_lists_id' => 'adm-bp-block-lists',
- 'layout_id' => 'adm-bpl-',
- );
- function __construct($sType = '', $sPage = '') {
- parent::__construct($sType, $sPage);
- $this->sBaseUrl = BX_DOL_URL_STUDIO . 'builder_page.php';
- $this->sTypeUrl = $this->sBaseUrl . '?type=%s';
- $this->sPageUrl = $this->sTypeUrl . '&page=%s';
- }
- function getPageCss() {
- return array_merge(parent::getPageCss(), array('page_layouts.css', 'builder_page.css'));
- }
- function getPageJs() {
- return array_merge(parent::getPageJs(), array(
- 'jquery.ui.core.min.js',
- 'jquery.ui.widget.min.js',
- 'jquery.ui.mouse.min.js',
- 'jquery.ui.sortable.min.js',
- 'jquery.easing.js',
- 'jquery.touch.js',
- 'jquery.form.js',
- 'functions.js',
- 'builder_page.js'
- ));
- }
- function getPageJsObject() {
- return 'oBxDolStudioBuilderPage';
- }
- function getPageMenu($aMenu = array(), $aMarkers = array()) {
- $aMenuItems = array(
- BX_DOL_STUDIO_MODULE_SYSTEM => array(
- 'name' => BX_DOL_STUDIO_MODULE_SYSTEM,
- 'icon' => 'std-mi.png',
- ),
- BX_DOL_STUDIO_MODULE_CUSTOM => array(
- 'name' => BX_DOL_STUDIO_MODULE_CUSTOM,
- 'icon' => 'mi-bp-custom.png',
- 'title' => '_adm_bp_cpt_type_' . BX_DOL_STUDIO_MODULE_CUSTOM,
- )
- );
- bx_import('BxDolModuleQuery');
- $aModulesDb = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules'));
- foreach($aModulesDb as $aModuleDb)
- if(!empty($aMenuItems[$aModuleDb['name']]))
- $aMenuItems[$aModuleDb['name']] = array_merge($aMenuItems[$aModuleDb['name']], $aModuleDb);
- else
- $aMenuItems[$aModuleDb['name']] = $aModuleDb;
- $aMenu = array();
- foreach($aMenuItems as $aMenuItem)
- $aMenu[] = array(
- 'name' => $aMenuItem['name'],
- 'icon' => isset($aMenuItem['path']) && $aMenuItem['path'] != '' && $aMenuItem['uri'] != '' ? $aMenuItem['uri'] . '@modules/' . $aMenuItem['path'] . '|std-mi.png' : $aMenuItem['icon'],
- 'link' => sprintf($this->sTypeUrl, $aMenuItem['name']),
- 'title' => $aMenuItem['title'],
- 'selected' => $aMenuItem['name'] == $this->sType
- );
- return parent::getPageMenu($aMenu);
- }
- function getPageCode($bHidden = false) {
- bx_import('BxTemplPage');
- $oPage = BxTemplPage::getObjectInstance($this->sPage);
- $oJson = new Services_JSON();
- $oTemplate = BxDolStudioTemplate::getInstance();
- $sJsObject = $this->getPageJsObject();
- $sContent = "";
- if(($bPage = $this->sPage != '') === true) {
- $aTmplVars = array();
- for($i = 1; $i <= $this->aPageRebuild['layout_cells_number']; $i++) {
- $aBlocks = array();
- $this->oDb->getBlocks(array('type' => 'by_object_cell', 'object' => $this->aPageRebuild['object'], 'cell' => $i), $aBlocks, false);
- $aTmplVarsCell = array('id' => $i, 'bx_repeat:blocks' => array());
- foreach($aBlocks as $aBlock)
- $aTmplVarsCell['bx_repeat:blocks'][] = array(
- 'html_id' => $this->aHtmlIds['block_id'] . $aBlock['id'],
- 'bx_if:show_link' => array(
- 'condition' => true,
- 'content' => array(
- 'onclick' => $sJsObject . ".performAction('block_edit', {id: " . $aBlock['id'] . "})",
- 'title' => $oPage->getBlockTitle($aBlock),
- )
- ),
- 'bx_if:show_text' => array(
- 'condition' => false,
- 'content' => array()
- ),
- 'icon' => $this->getBlockIcon($aBlock),
- 'module' => $this->getModuleTitle($aBlock['module']),
- 'visible_for' => _t('_adm_bp_txt_visible_for', BxDolStudioUtils::getVisibilityTitle($aBlock['visible_for_levels'])),
- 'bx_if:show_checkbox' => array(
- 'condition' => false,
- 'content' => array()
- ),
- 'bx_if:show_drag_handle' => array(
- 'condition' => true,
- 'content' => array()
- )
- );
- $aTmplVars['cell_' . $i] = $oTemplate->parseHtmlByName('bp_cell.html', $aTmplVarsCell);
- }
- $sContent = $oTemplate->parseHtmlByName($this->aPageRebuild['layout_template'], $aTmplVars);
- }
- bx_import('BxDolStudioLanguagesUtils');
- $aLanguages = BxDolStudioLanguagesUtils::getInstance()->getLanguages();
- $aTmplVars = array(
- 'js_object' => $sJsObject,
- 'action_url' => $this->sBaseUrl,
- 'page_url' => sprintf($this->sPageUrl, '{0}', '{1}'),
- 'type' => $this->sType,
- 'page' => $this->sPage,
- 'html_ids' => $oJson->encode($this->aHtmlIds),
- 'languahes' => $oJson->encode($aLanguages),
- 'bx_repeat:blocks' => array(
- array(
- 'caption' => '',
- 'panel_top' => $this->getBlockPanelTop(),
- 'items' => $sContent,
- 'panel_bottom' => ''
- )
- )
- );
- $oTemplate->addJsTranslation('_adm_bp_wrn_page_delete');
- return $oTemplate->parseHtmlByName('builder_page.html', $aTmplVars);
- }
- function getBlockPanelTop($aParams = array()) {
- $oTemplate = BxDolStudioTemplate::getInstance();
- $sJsObject = $this->getPageJsObject();
- $oForm = new BxTemplStudioFormView(array());
- $aInputPages = array(
- 'type' => 'select',
- 'name' => 'page',
- 'attrs' => array(
- 'onChange' => 'javascript:' . $this->getPageJsObject() . '.onChangePage(this)'
- ),
- 'value' => $this->sPage,
- 'values' => array(
- array('key' => '', 'value' => _t('_adm_bp_txt_select_page'))
- )
- );
- $aPages = $aCounter = array();
- $this->oDb->getPages(array('type' => 'by_module', 'value' => $this->sType), $aPages, false);
- $this->oDb->getBlocks(array('type' => 'counter_by_pages'), $aCounter, false);
- foreach($aPages as $aPage)
- $aInputPages['values'][] = array('key' => $aPage['object'], 'value' => _t($aPage['title_system']) . " (" . (isset($aCounter[$aPage['object']]) ? $aCounter[$aPage['object']] : "0") . ")");
- bx_import('BxDolPermalinks');
- $oPermalinks = BxDolPermalinks::getInstance();
- $aTmplVarsActions = array();
- if(($this->sPage != '' && !empty($this->aPageRebuild)) !== false)
- $aTmplVarsActions = array(
- 'js_object' => $sJsObject,
- 'url_view' => BX_DOL_URL_ROOT . $oPermalinks->permalink($this->aPageRebuild['url']),
- 'action_page_edit' => $this->sActionPageEdit,
- 'bx_if:can_delete' => array(
- 'condition' => (int)$this->aPageRebuild['deletable'] == 1,
- 'content' => array(
- 'js_object' => $sJsObject
- )
- ),
- 'action_block_create' => $this->sActionBlockCreate,
- );
- $aTmplVars = array(
- 'js_object' => $this->getPageJsObject(),
- 'selector' => $oForm->genRow($aInputPages),
- 'action_page_create' => $this->sActionPageCreate,
- 'bx_if:show_actions' => array(
- 'condition' => $this->sPage != '',
- 'content' => $aTmplVarsActions
- )
- );
- return parent::getBlockPanelTop(
- array('panel_top' => $oTemplate->parseHtmlByName('bp_block_panel_top.html', $aTmplVars))
- );
- }
- protected function actionPageCreate() {
- $oTemplate = BxDolStudioTemplate::getInstance();
- $sModule = BX_DOL_STUDIO_MODULE_CUSTOM;
- $aForm = array(
- 'form_attrs' => array(
- 'id' => 'adm-bp-page-create',
- 'action' => sprintf($this->sPageUrl, $this->sType, $this->sPage) . '&bp_action=' . $this->sActionPageCreate,
- 'method' => 'post'
- ),
- 'params' => array (
- 'db' => array(
- 'table' => 'sys_objects_page',
- 'key' => 'id',
- 'uri' => '',
- 'uri_title' => '',
- 'submit_name' => 'do_submit'
- ),
- ),
- 'inputs' => array (
- 'module' => array(
- 'type' => 'hidden',
- 'name' => 'module',
- 'value' => $sModule,
- 'db' => array (
- 'pass' => 'Xss',
- ),
- ),
- 'deletable' => array(
- 'type' => 'hidden',
- 'name' => 'deletable',
- 'value' => 1,
- 'db' => array (
- 'pass' => 'Int',
- ),
- ),
- 'title_system' => array(
- 'type' => 'text_translatable',
- 'name' => 'title_system',
- 'caption' => _t('_adm_bp_txt_page_title_system'),
- 'info' => _t('_adm_bp_dsc_page_title_system'),
- 'value' => '_sys_bpb',
- 'required' => '1',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- 'checker' => array (
- 'func' => 'length',
- 'params' => array(3,100),
- 'error' => _t('_adm_bp_err_page_name'),
- ),
- ),
- 'title' => array(
- 'type' => 'text_translatable',
- 'name' => 'title',
- 'caption' => _t('_adm_bp_txt_page_title'),
- 'info' => _t('_adm_bp_dsc_page_title'),
- 'value' => '_sys_bpb',
- 'required' => '1',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- 'checker' => array (
- 'func' => 'length',
- 'params' => array(3,100),
- 'error' => _t('_adm_bp_err_page_title'),
- ),
- ),
- 'uri' => array(
- 'type' => 'text',
- 'name' => 'uri',
- 'caption' => _t('_adm_bp_txt_page_uri'),
- 'info' => _t('_adm_bp_dsc_page_uri'),
- 'value' => '',
- 'required' => '1',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- 'attrs' => array(
- 'id' => $this->aHtmlIds['uri_field_id'],
- 'onfocus' => $this->getPageJsObject() . '.getUri(this);'
- ),
- 'checker' => array (
- 'func' => 'length',
- 'params' => array(3,100),
- 'error' => _t('_adm_bp_err_page_uri'),
- ),
- ),
- 'layout_id' => array(
- 'type' => 'select',
- 'name' => 'layout_id',
- 'caption' => _t('_adm_bp_txt_page_layout'),
- 'info' => '',
- 'value' => '',
- 'values' => array(
- array('key' => '', 'value' => _t('_adm_bp_txt_page_layout_empty')),
- ),
- 'required' => '1',
- 'db' => array (
- 'pass' => 'Int',
- ),
- 'checker' => array (
- 'func' => 'avail',
- 'params' => array(),
- 'error' => _t('_adm_bp_err_page_layout'),
- ),
- ),
- 'meta_description' => array(
- 'type' => 'textarea',
- 'name' => 'meta_description',
- 'caption' => _t('_adm_bp_txt_page_meta_description'),
- 'info' => _t('_adm_bp_dsc_page_meta_description'),
- 'value' => '',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- ),
- 'controls' => array(
- 'name' => 'controls',
- 'type' => 'input_set',
- array(
- 'type' => 'submit',
- 'name' => 'do_submit',
- 'value' => _t('_adm_bp_btn_page_create'),
- ),
- array (
- 'type' => 'reset',
- 'name' => 'close',
- 'value' => _t('_adm_bp_btn_page_cancel'),
- 'attrs' => array(
- 'onclick' => "$('.bx-popup-applied:visible').dolPopupHide()",
- 'class' => 'bx-def-margin-sec-left',
- ),
- )
- )
- )
- );
- $aLayouts = array();
- $this->oDb->getLayouts(array('type' => 'all'), $aLayouts, false);
- foreach($aLayouts as $aLayout)
- $aForm['inputs']['layout_id']['values'][] = array('key' => $aLayout['id'], 'value' => _t($aLayout['title']));
- $oForm = new BxTemplStudioFormView($aForm);
- $oForm->initChecker();
- $sContent = "";
- if($oForm->isSubmittedAndValid()) {
- bx_import('BxDolStudioLanguagesUtils');
- $sLanguage = BxDolStudioLanguagesUtils::getInstance()->getCurrentLangName(false);
- $sObject = BxDolForm::getSubmittedValue('title-' . $sLanguage, $aForm['form_attrs']['method']);
- $sObject = uriGenerate($sObject, 'sys_objects_page', 'object', 'object');
- $sUri = $oForm->getCleanValue('uri');
- $iId = (int)$oForm->insert(array('object' => $sObject, 'url' => $this->sPageBaseUrl . $sUri));
- if($iId != 0)
- return array('eval' => $this->getPageJsObject() . '.onCreatePage(\'' . $sModule . '\', \'' . $sObject . '\')');
- else
- return array('msg' => _t('_adm_bp_err_page_create'));
- }
- bx_import('BxTemplStudioFunctions');
- $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['create_popup_id'], _t('_adm_bp_txt_create_popup'), $oTemplate->parseHtmlByName('bp_add_page.html', array(
- 'form_id' => $aForm['form_attrs']['id'],
- 'form' => $oForm->getCode(true)
- )));
- return array('popup' => $sContent);
- }
- protected function actionPageEdit() {
- $sJsObject = $this->getPageJsObject();
- $oTemplate = BxDolStudioTemplate::getInstance();
- $aForm = array(
- 'form_attrs' => array(
- 'id' => 'adm-bp-page-edit',
- 'action' => sprintf($this->sPageUrl, $this->sType, $this->sPage) . '&bp_action=' . $this->sActionPageEdit,
- 'method' => 'post'
- ),
- 'params' => array (
- 'db' => array(
- 'table' => 'sys_objects_page',
- 'key' => 'id',
- 'uri' => '',
- 'uri_title' => '',
- 'submit_name' => 'do_submit'
- ),
- ),
- 'inputs' => array (
- 'settings' => array(
- 'type' => 'custom',
- 'name' => 'settings',
- 'content' => '',
- ),
- )
- );
- $aSettings = array(
- array('name' => 'options', 'title' => '_adm_bp_mi_page_options', 'active' => 1),
- array('name' => 'layout', 'title' => '_adm_bp_mi_page_layout', 'active' => 0),
- array('name' => 'visibility', 'title' => '_adm_bp_mi_page_visibility', 'active' => 0),
- array('name' => 'cache', 'title' => '_adm_bp_mi_page_cache', 'active' => 0),
- array('name' => 'seo', 'title' => '_adm_bp_mi_page_seo', 'active' => 0)
- );
- $aTmplParams = array(
- 'menu' => array(),
- 'html_settings_groups_id' => $this->aHtmlIds['settings_groups_id'],
- 'bx_repeat:settings_groups' => array()
- );
- foreach($aSettings as $aSetting) {
- //--- get menu items
- $aTmplParams['menu'][$aSetting['name']] = array(
- 'name' => $aSetting['name'],
- 'icon' => '',
- 'onclick' => $sJsObject . '.onChangeSettingGroup(\'' . $aSetting['name'] . '\', this);',
- 'title' => $aSetting['title'],
- 'selected' => isset($aSetting['active']) && (int)$aSetting['active'] == 1
- );
- //--- get settings
- $aTmplParams['bx_repeat:settings_groups'][] = array(
- 'html_settings_group_id' => $this->aHtmlIds['settings_group_id'] . $aSetting['name'],
- 'bx_if:hidden' => array(
- 'condition' => $aSetting['active'] != 1,
- 'content' => array()
- ),
- 'content' => $this->{'getSettings' . $this->getClassName($aSetting['name'])}()
- );
- }
- bx_import('BxTemplStudioMenu');
- $oMenu = new BxTemplStudioMenu(array('template' => 'menu_side.html', 'menu_items' => $aTmplParams['menu']));
- $aTmplParams['menu'] = $oMenu->getCode();
- $aForm['inputs']['settings']['content'] = $oTemplate->parseHtmlByName('bp_edit_page_form.html', $aTmplParams);
- $oForm = new BxTemplStudioFormView($aForm);
- $oForm->initChecker();
- $sContent = "";
- if($oForm->isSubmittedAndValid()) {
- unset($oForm->aInputs['settings']);
- foreach($aSettings as $aSetting)
- $oForm->aInputs = array_merge($oForm->aInputs, $this->{'getSettings' . $this->getClassName($aSetting['name'])}(true));
-
- $iVisibleFor = BxDolStudioUtils::getVisibilityValue($oForm->getCleanValue('visible_for'), $oForm->getCleanValue('visible_for_levels'));
- BxDolForm::setSubmittedValue('visible_for_levels', $iVisibleFor, $aForm['form_attrs']['method']);
- unset($oForm->aInputs['visible_for']);
- if($oForm->update($this->aPageRebuild['id'])) {
- $iLevelId = $oForm->getCleanValue('layout_id');
- if(!empty($iLevelId) && $iLevelId != $this->aPageRebuild['layout_id']) {
- $aLayoutOld = array();
- $this->oDb->getLayouts(array('type' => 'by_id', 'value' => $this->aPageRebuild['layout_id']), $aLayoutOld, false);
- $aLayoutNew = array();
- $this->oDb->getLayouts(array('type' => 'by_id', 'value' => $iLevelId), $aLayoutNew, false);
- if($aLayoutOld['cells_number'] > $aLayoutNew['cells_number'] && $this->oDb->resetBlocksByPage($this->sPage, $aLayoutNew['cells_number']) === false)
- return array('msg' => _t('_adm_bp_err_save'));
- return array('eval' => $sJsObject . '.onSaveSettings()');
- }
- return array();
- }
- else
- return array('msg' => _t('_adm_bp_err_save'));
- }
- bx_import('BxTemplStudioFunctions');
- $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['edit_popup_id'], _t('_adm_bp_txt_settings_popup'), $oTemplate->parseHtmlByName('bp_edit_page.html', array(
- 'form_id' => $aForm['form_attrs']['id'],
- 'form' => $oForm->getCode(true)
- )));
- return array('popup' => $sContent);
- }
- protected function actionPageDelete() {
- if(empty($this->sPage) || empty($this->aPageRebuild) || !is_array($this->aPageRebuild))
- return array('msg' => _t('_adm_bp_err_page_delete'));
- bx_import('BxDolStudioLanguagesUtils');
- $oLangauge = BxDolStudioLanguagesUtils::getInstance();
- bx_import('BxDolStorage');
- $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
- $aBlocks = array();
- $this->oDb->getBlocks(array('type' => 'by_object', 'value' => $this->sPage), $aBlocks, false);
- if(is_array($aBlocks) && !empty($aBlocks)) {
- foreach($aBlocks as $aBlock)
- $this->onBlockDelete($aBlock);
- $this->oDb->deleteBlocks(array('type' => 'by_object', 'value' => $this->sPage));
- }
- if($this->oDb->deletePages(array('type' => 'by_object', 'value' => $this->sPage))) {
- $oLangauge->deleteLanguageString($this->aPageRebuild['title_system']);
- $oLangauge->deleteLanguageString($this->aPageRebuild['title']);
- return array('eval' => 'window.parent.location.href = "' . BX_DOL_URL_STUDIO . 'builder_page.php?type=' . $this->sType . '";');
- }
- return array('msg' => _t('_adm_bp_err_page_delete'));
- }
- protected function actionBlockList() {
- $sModule = BX_DOL_STUDIO_BP_TYPE_DEFAULT;
- if(bx_get('bp_module') !== false)
- $sModule = bx_process_input(bx_get('bp_module'));
- return array(
- 'content' => $this->getBlockList($sModule)
- );
- }
- protected function actionBlockCreate() {
- $sJsObject = $this->getPageJsObject();
- $oTemplate = BxDolStudioTemplate::getInstance();
- $sSelected = BX_DOL_STUDIO_BP_SKELETONS;
- $aForm = array(
- 'form_attrs' => array(
- 'id' => 'adm-bp-block-create',
- 'action' => sprintf($this->sPageUrl, $this->sType, $this->sPage) . '&bp_action=' . $this->sActionBlockCreate,
- 'method' => 'post'
- ),
- 'params' => array (
- 'db' => array(
- 'table' => 'sys_pages_blocks',
- 'key' => 'id',
- 'uri' => '',
- 'uri_title' => '',
- 'submit_name' => 'do_submit'
- ),
- ),
- 'inputs' => array (
- 'blocks' => array(
- 'type' => 'custom',
- 'name' => 'blocks',
- 'content' => '',
- 'db' => array (
- 'pass' => 'Int',
- ),
- ),
- )
- );
- $aMenu = array(
- BX_DOL_STUDIO_BP_SKELETONS => array(
- 'name' => BX_DOL_STUDIO_BP_SKELETONS,
- 'icon' => 'mi-bp-skeletons.png',
- 'title' => '_sys_block_types_skeletons',
- 'selected' => $sSelected == BX_DOL_STUDIO_BP_SKELETONS,
- ),
- BX_DOL_STUDIO_MODULE_SYSTEM => array(
- 'name' => BX_DOL_STUDIO_MODULE_SYSTEM,
- 'icon' => 'std-mi.png',
- 'title' => '_sys_block_types_system',
- 'selected' => $sSelected == BX_DOL_STUDIO_MODULE_SYSTEM,
- ),
- BX_DOL_STUDIO_MODULE_CUSTOM => array(
- 'name' => BX_DOL_STUDIO_MODULE_CUSTOM,
- 'icon' => 'mi-bp-custom.png',
- 'title' => '_sys_block_types_custom',
- 'selected' => $sSelected == BX_DOL_STUDIO_MODULE_CUSTOM,
- )
- );
- bx_import('BxDolModuleQuery');
- $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules'));
- foreach($aModules as $aModule) {
- if($aModule['path'] != '' && $aModule['uri'] != '')
- $aModule['icon'] = $aModule['uri'] . '@modules/' . $aModule['path'] . '|std-mi.png';
- if(!empty($aMenu[$aModule['name']]))
- $aMenu[$aModule['name']] = array_merge($aMenu[$aModule['name']], $aModule);
- else
- $aMenu[$aModule['name']] = $aModule;
- }
- foreach($aMenu as $sKey => $aItem)
- $aMenu[$sKey]['onclick'] = $sJsObject . '.onChangeModule(\'' . $aItem['name'] . '\', this);';
- bx_import('BxTemplStudioMenu');
- $oMenu = new BxTemplStudioMenu(array('template' => 'menu_side.html', 'menu_items' => $aMenu));
- $aTmplParams = array(
- 'menu' => $oMenu->getCode(),
- 'html_block_lists_id' => $this->aHtmlIds['block_lists_id'],
- 'blocks' => $this->getBlockList($sSelected)
- );
- $aForm['inputs']['blocks']['content'] = $oTemplate->parseHtmlByName('bp_add_block_form.html', $aTmplParams);
- $oForm = new BxTemplStudioFormView($aForm);
- $oForm->initChecker();
- if($oForm->isSubmittedAndValid()) {
- $aIds = $oForm->getCleanValue('blocks');
- $aBlocks = array();
- $this->oDb->getBlocks(array('type' => 'by_ids', 'value' => $aIds), $aBlocks, false);
- bx_import('BxDolStudioLanguagesUtils');
- $oLanguage = BxDolStudioLanguagesUtils::getInstance();
-
- bx_import('BxDolStorage');
- $oStorege = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
- $bResult = true;
- foreach($aBlocks as $aBlock) {
- $sTitleKey = $this->getSystemName($aBlock['title'] . '_' . time());
- $sTitleValue = _t($aBlock['title']);
- unset($aBlock['id']);
- $aBlock['object'] = $this->sPage;
- $aBlock['cell_id'] = 1;
- $aBlock['module'] = $this->getBlockModule($aBlock);
- $aBlock['title'] = $sTitleKey;
- $aBlock['deletable'] = 1;
- //--- Process Lang copy
- $sContentKey = $sContentValue = "";
- if($aBlock['type'] == BX_DOL_STUDIO_BP_BLOCK_LANG && $aBlock['content'] != '') {
- $sContentKey = $this->getSystemName($aBlock['content'] . '_' . time());
- $sContentValue = _t($aBlock['content']);
- $aBlock['content'] = $sContentKey;
- $oLanguage->addLanguageString($sContentKey, $sContentValue);
- }
- //--- Process Image copy
- $iImageId = $sImageAlign = "";
- if($aBlock['type'] == BX_DOL_STUDIO_BP_BLOCK_IMAGE && $aBlock['content'] != '') {
- list($iImageId, $sImageAlign) = explode($this->sParamsDivider, $aBlock['content']);
- $aBlock['content'] = "";
- if(is_numeric($iImageId) && (int)$iImageId != 0 && ($iImageId = $oStorege->storeFileFromStorage(array('id' => $iImageId))) !== false)
- $aBlock['content'] = implode($this->sParamsDivider, array($iImageId, $sImageAlign));
- }
- if(!$this->oDb->insertBlock($aBlock)) {
- if($sContentKey != "")
- $oLanguage->deleteLanguageString($sContentKey);
- if($iImageId != "")
- $oStorege->deleteFile((int)$iImageId, 0);
- $bResult = false;
- break;
- }
- $oLanguage->addLanguageString($sTitleKey, $sTitleValue);
- }
- if($bResult)
- return array('eval' => $sJsObject . '.onCreateBlock(oData)');
- else
- return array('msg' => _t('_adm_bp_err_block_added'));
- }
- bx_import('BxTemplStudioFunctions');
- $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['create_block_popup_id'], _t('_adm_bp_txt_new_block_popup'), $oTemplate->parseHtmlByName('bp_add_block.html', array(
- 'form_id' => $aForm['form_attrs']['id'],
- 'form' => $oForm->getCode(true)
- )));
- return array('popup' => $sContent);
- }
- protected function actionBlockEdit() {
- $sJsObject = $this->getPageJsObject();
- $oTemplate = BxDolStudioTemplate::getInstance();
- $iId = (int)bx_get('id');
- if(!$iId)
- return array();
- $aBlock = array();
- $this->oDb->getBlocks(array('type' => 'by_id', 'value' => $iId), $aBlock, false);
- if(empty($aBlock) || !is_array($aBlock))
- return array('msg' => _t('_adm_bp_err_block_not_found'));
- $aForm = array(
- 'form_attrs' => array(
- 'id' => 'adm-bp-block-edit',
- 'action' => sprintf($this->sPageUrl, $this->sType, $this->sPage) . '&bp_action=' . $this->sActionBlockEdit,
- 'method' => 'post'
- ),
- 'params' => array (
- 'db' => array(
- 'table' => 'sys_pages_blocks',
- 'key' => 'id',
- 'uri' => '',
- 'uri_title' => '',
- 'submit_name' => 'do_submit'
- ),
- ),
- 'inputs' => array (
- 'id' => array(
- 'type' => 'hidden',
- 'name' => 'id',
- 'value' => $iId,
- 'db' => array (
- 'pass' => 'Int',
- ),
- ),
- 'title' => array(
- 'type' => 'text_translatable',
- 'name' => 'title',
- 'caption' => _t('_adm_bp_txt_block_title'),
- 'info' => _t('_adm_bp_dsc_block_title'),
- 'value' => $aBlock['title'],
- 'required' => '1',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- 'checker' => array (
- 'func' => 'length',
- 'params' => array(3,100),
- 'error' => _t('_adm_bp_err_block_title'),
- ),
- ),
- 'designbox_id' => array(
- 'type' => 'select',
- 'name' => 'designbox_id',
- 'caption' => _t('_adm_bp_txt_block_designbox'),
- 'info' => '',
- 'value' => $this->sSelectKeyPrefix . $aBlock['designbox_id'],
- 'values' => array(
- array('key' => '', 'value' => _t('_adm_bp_txt_block_designbox_empty')),
- ),
- 'required' => '1',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- 'checker' => array (
- 'func' => 'avail',
- 'params' => array(),
- 'error' => _t('_adm_bp_err_block_designbox'),
- ),
- ),
- 'visible_for' => array(
- 'type' => 'select',
- 'name' => 'visible_for',
- 'caption' => _t('_adm_bp_txt_block_visible_for'),
- 'info' => '',
- 'value' => $aBlock['visible_for_levels'] == BX_DOL_INT_MAX ? BX_DOL_STUDIO_VISIBLE_ALL : BX_DOL_STUDIO_VISIBLE_SELECTED,
- 'values' => array(
- array('key' => BX_DOL_STUDIO_VISIBLE_ALL, 'value' => _t('_adm_bp_txt_block_visible_for_all')),
- array('key' => BX_DOL_STUDIO_VISIBLE_SELECTED, 'value' => _t('_adm_bp_txt_block_visible_for_selected')),
- ),
- 'required' => '0',
- 'attrs' => array(
- 'onchange' => $this->getPageJsObject() . '.onChangeVisibleFor(this)'
- ),
- 'db' => array (
- 'pass' => 'Xss',
- )
- ),
- 'visible_for_levels' => array(
- 'type' => 'checkbox_set',
- 'name' => 'visible_for_levels',
- 'caption' => _t('_adm_bp_txt_block_visible_for_levels'),
- 'info' => _t('_adm_bp_dsc_block_visible_for_levels'),
- 'value' => array(),
- 'values' => array(),
- 'tr_attrs' => array(
- 'style' => $aBlock['visible_for_levels'] == BX_DOL_INT_MAX ? 'display:none' : ''
- ),
- 'db' => array (
- 'pass' => 'Int',
- )
- ),
- 'controls' => array(
- 'name' => 'controls',
- 'type' => 'input_set',
- array(
- 'type' => 'submit',
- 'name' => 'do_submit',
- 'value' => _t('_adm_bp_btn_block_save'),
- ),
- array (
- 'type' => 'reset',
- 'name' => 'close',
- 'value' => _t('_adm_bp_btn_block_cancel'),
- 'attrs' => array(
- 'onclick' => "$('.bx-popup-applied:visible').dolPopupHide()",
- 'class' => 'bx-def-margin-sec-left',
- ),
- ),
- array (
- 'type' => 'reset',
- 'name' => 'close',
- 'value' => _t('_adm_bp_btn_block_delete'),
- 'attrs' => array(
- 'onclick' => $this->getPageJsObject() . ".deleteBlock(" . $aBlock['id'] . ")",
- 'class' => 'bx-def-margin-sec-left',
- ),
- )
- )
- )
- );
- $aDBoxes = array();
- $this->oDb->getDesignBoxes(array('type' => 'ordered'), $aDBoxes, false);
- foreach($aDBoxes as $aDBox)
- $aForm['inputs']['designbox_id']['values'][] = array('key' => $this->sSelectKeyPrefix . $aDBox['id'], 'value' => _t($aDBox['title']));
- BxDolStudioUtils::getVisibilityValues($aBlock['visible_for_levels'], $aForm['inputs']['visible_for_levels']['values'], $aForm['inputs']['visible_for_levels']['value']);
- $aForm['inputs'] = $this->addInArray($aForm['inputs'], 'visible_for_levels', $this->getBlockContent($aBlock));
- $oForm = new BxTemplStudioFormView($aForm);
- $oForm->initChecker();
- if($oForm->isSubmittedAndValid()) {
- $this->onSaveBlock($oForm, $aBlock);
- if($oForm->update($iId) !== false)
- return array('eval' => $sJsObject . '.onEditBlock(oData)');
- else
- return array('msg' => _t('_adm_bp_err_block_edit'));
- }
- bx_import('BxTemplStudioFunctions');
- $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(
- 'form_id' => $aForm['form_attrs']['id'],
- 'form' => $oForm->getCode(true)
- )));
- return array('popup' => $sContent);
- }
- protected function actionBlockDelete() {
- $sJsObject = $this->getPageJsObject();
- $iId = (int)bx_get('id');
- $aBlock = array();
- $this->oDb->getBlocks(array('type' => 'by_id', 'value' => $iId), $aBlock, false);
- if(empty($aBlock) || !is_array($aBlock))
- return array('msg' => _t('_adm_bp_err_block_not_found'));
- if(!$this->oDb->deleteBlocks(array('type' => 'by_id', 'value' => $iId)))
- return array('msg' => _t('_adm_bp_err_block_delete'));
- $this->onBlockDelete($aBlock);
- return array('eval' => $sJsObject . '.onDeleteBlock(' . $iId . ', oData)');
- }
- protected function actionImageDelete() {
- $sJsObject = $this->getPageJsObject();
- $iId = (int)bx_get('id');
- $aBlock = array();
- $this->oDb->getBlocks(array('type' => 'by_id', 'value' => $iId), $aBlock, false);
- if(empty($aBlock) || !is_array($aBlock))
- return array('msg' => _t('_adm_bp_err_block_not_found'));
- $iImageId = $sImageAlign = '';
- if($aBlock['content'] != '')
- list($iImageId, $sImageAlign) = explode($this->sParamsDivider, $aBlock['content']);
- if(is_numeric($iImageId) && (int)$iImageId != 0) {
- bx_import('BxDolStorage');
- if(!BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES)->deleteFile((int)$iImageId, 0))
- return array('msg' => _t('_adm_bp_err_block_content_image_preview_delete'));
- $this->oDb->updateBlock($iId, array('content' => ''));
- }
- return $this->actionBlockEdit();
- }
- protected function actionUriGet() {
- bx_import('BxDolStudioLanguagesUtils');
- $oLanguage = BxDolStudioLanguagesUtils::getInstance();
- $aLanguages = $oLanguage->getLanguages();
- $sLanguageDef = $oLanguage->getDefaultLangName();
- $sLanguageCur = $oLanguage->getCurrentLangName(false);
- $aValues = array();
- foreach($aLanguages as $sName => $sTitle)
- if(($mixedValue = bx_get($sName)) !== false)
- $aValues[$sName] = bx_process_input($mixedValue);
- $sUri = "";
- if(array_key_exists('en', $aValues) && $aValues['en'] != '')
- $sUri = $aValues['en'];
- else if(array_key_exists($sLanguageDef, $aValues) && $aValues[$sLanguageDef] != '')
- $sUri = $aValues[$sLanguageDef];
- else if(array_key_exists($sLanguageCur, $aValues) && $aValues[$sLanguageCur] != '')
- $sUri = $aValues[$sLanguageCur];
- else if(count($aValues) > 0)
- foreach($aValues as $sValue)
- if(!empty($sValue)) {
- $sUri = $sValue;
- break;
- }
- $sUri = $sUri != "" ? uriGenerate($sUri, 'sys_objects_page', 'uri') : "";
- return array('eval' => $this->getPageJsObject() . '.onGetUri(oData)', 'content' => $sUri);
- }
- protected function getSettingsOptions($bInputsOnly = false) {
- $aForm = array(
- 'form_attrs' => array(
- 'id' => 'adm-bp-settings-seo',
- ),
- 'params' => array (
- 'remove_form' => '1',
- 'csrf' => array(
- 'disable' => true
- )
- ),
- 'inputs' => array (
- 'title_system' => array(
- 'type' => 'text_translatable',
- 'name' => 'title_system',
- 'caption' => _t('_adm_bp_txt_page_title_system'),
- 'info' => _t('_adm_bp_dsc_page_title_system'),
- 'value' => $this->aPageRebuild['title_system'],
- 'required' => '1',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- 'checker' => array (
- 'func' => 'length',
- 'params' => array(3,100),
- 'error' => _t('_adm_bp_err_page_title_system'),
- ),
- ),
- 'title' => array(
- 'type' => 'text_translatable',
- 'name' => 'title',
- 'caption' => _t('_adm_bp_txt_page_title'),
- 'info' => _t('_adm_bp_dsc_page_title'),
- 'value' => $this->aPageRebuild['title'],
- 'required' => '1',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- 'checker' => array (
- 'func' => 'length',
- 'params' => array(3,100),
- 'error' => _t('_adm_bp_err_page_title'),
- ),
- ),
- 'url' => array(
- 'type' => 'text',
- 'name' => 'url',
- 'caption' => _t('_adm_bp_txt_page_url'),
- 'info' => _t('_adm_bp_dsc_page_url'),
- 'value' => $this->aPageRebuild['url'],
- 'required' => '0',
- 'attrs' => array(
- 'disabled' => 'disabled'
- ),
- ),
- )
- );
- if($bInputsOnly)
- return $aForm['inputs'];
- $oForm = new BxTemplStudioFormView($aForm);
- return $oForm->getCode();
- }
- protected function getSettingsLayout($bInputsOnly = false) {
- $sJsObject = $this->getPageJsObject();
- $oTemplate = BxDolStudioTemplate::getInstance();
- $aLayouts = array();
- $this->oDb->getLayouts(array('type' => 'all'), $aLayouts, false);
- $aTmplParams = array(
- 'bx_repeat:layouts' => array(),
- 'form' => ''
- );
- foreach($aLayouts as $aLayout)
- $aTmplParams['bx_repeat:layouts'][] = array(
- 'id' => $aLayout['id'],
- 'html_id' => $this->aHtmlIds['layout_id'] . $aLayout['id'],
- 'js_object' => $sJsObject,
- 'bx_if:active' => array(
- 'condition' => (int)$this->aPageRebuild['layout_id'] == (int)$aLayout['id'],
- 'content' => array()
- ),
- 'icon' => $oTemplate->getImageUrl($aLayout['icon']),
- 'title' => _t($aLayout['title']),
- );
- $aForm = array(
- 'form_attrs' => array(
- 'id' => 'adm-bp-settings-seo',
- ),
- 'params' => array (
- 'remove_form' => '1',
- 'csrf' => array(
- 'disable' => true
- )
- ),
- 'inputs' => array (
- 'layout_id' => array(
- 'type' => 'hidden',
- 'name' => 'layout_id',
- 'value' => $this->aPageRebuild['layout_id'],
- 'db' => array (
- 'pass' => 'Int',
- ),
- )
- )
- );
- if($bInputsOnly)
- return $aForm['inputs'];
- $oForm = new BxTemplStudioFormView($aForm);
- $aTmplParams['form'] = $oForm->getCode();
- return $oTemplate->parseHtmlByName('bp_layouts.html', $aTmplParams);
- }
- protected function getSettingsVisibility($bInputsOnly = false) {
- if((int)$this->aPageRebuild['visible_for_levels_editable'] == 0)
- $aInputs = array(
- 'visible_for_levels' => array(
- 'type' => 'custom',
- 'name' => 'visible_for_levels',
- 'content' => MsgBox(_t('_adm_bp_err_page_visible_for_levels'))
- )
- );
- else
- $aInputs = array(
- 'visible_for' => array(
- 'type' => 'select',
- 'name' => 'visible_for',
- 'caption' => _t('_adm_bp_txt_block_visible_for'),
- 'info' => '',
- 'value' => $this->aPageRebuild['visible_for_levels'] == BX_DOL_INT_MAX ? BX_DOL_STUDIO_VISIBLE_ALL : BX_DOL_STUDIO_VISIBLE_SELECTED,
- 'values' => array(
- array('key' => BX_DOL_STUDIO_VISIBLE_ALL, 'value' => _t('_adm_bp_txt_block_visible_for_all')),
- array('key' => BX_DOL_STUDIO_VISIBLE_SELECTED, 'value' => _t('_adm_bp_txt_block_visible_for_selected')),
- ),
- 'required' => '0',
- 'attrs' => array(
- 'onchange' => $this->getPageJsObject() . '.onChangeVisibleFor(this)'
- ),
- 'db' => array (
- 'pass' => 'Xss',
- )
- ),
- 'visible_for_levels' => array(
- 'type' => 'checkbox_set',
- 'name' => 'visible_for_levels',
- 'caption' => _t('_adm_bp_txt_page_visible_for_levels'),
- 'info' => _t('_adm_bp_dsc_page_visible_for_levels'),
- 'value' => '',
- 'values' => array(),
- 'tr_attrs' => array(
- 'style' => $this->aPageRebuild['visible_for_levels'] == BX_DOL_INT_MAX ? 'display:none' : ''
- ),
- 'db' => array (
- 'pass' => 'Int',
- )
- )
- );
- $aForm = array(
- 'form_attrs' => array(
- 'id' => 'adm-bp-settings-visibility',
- ),
- 'params' => array (
- 'remove_form' => '1',
- 'csrf' => array(
- 'disable' => true
- )
- ),
- 'inputs' => $aInputs
- );
- if($bInputsOnly)
- return $aForm['inputs'];
- BxDolStudioUtils::getVisibilityValues($this->aPageRebuild['visible_for_levels'], $aForm['inputs']['visible_for_levels']['values'], $aForm['inputs']['visible_for_levels']['value']);
- $oForm = new BxTemplStudioFormView($aForm);
- return $oForm->getCode();
- }
- protected function getSettingsCache($bInputsOnly = false) {
- $aForm = array(
- 'form_attrs' => array(
- 'id' => 'adm-bp-settings-cache',
- ),
- 'params' => array (
- 'remove_form' => '1',
- 'csrf' => array(
- 'disable' => true
- )
- ),
- 'inputs' => array (
- 'cache_lifetime' => array(
- 'type' => 'text',
- 'name' => 'cache_lifetime',
- 'caption' => _t('_adm_bp_txt_page_cache_lifetime'),
- 'info' => _t('_adm_bp_dsc_page_cache_lifetime'),
- 'value' => $this->aPageRebuild['cache_lifetime'],
- 'required' => '',
- 'attrs' => array(
- 'disabled' => (int)$this->aPageRebuild['cache_editable'] == 0 ? 'disabled' : ''
- ),
- 'db' => array (
- 'pass' => 'Int',
- )
- ),
- )
- );
- if($bInputsOnly)
- return $aForm['inputs'];
- $oForm = new BxTemplStudioFormView($aForm);
- return $oForm->getCode();
- }
- protected function getSettingsSeo($bInputsOnly = false) {
- $aForm = array(
- 'form_attrs' => array(
- 'id' => 'adm-bp-settings-seo',
- ),
- 'params' => array (
- 'remove_form' => '1',
- 'csrf' => array(
- 'disable' => true
- )
- ),
- 'inputs' => array (
- 'meta_description' => array(
- 'type' => 'textarea',
- 'name' => 'meta_description',
- 'caption' => _t('_adm_bp_txt_page_meta_description'),
- 'info' => _t('_adm_bp_dsc_page_meta_description'),
- 'value' => $this->aPageRebuild['meta_description'],
- 'db' => array (
- 'pass' => 'Xss',
- ),
- ),
- 'meta_keywords' => array(
- 'type' => 'textarea',
- 'name' => 'meta_keywords',
- 'caption' => _t('_adm_bp_txt_page_meta_keywords'),
- 'info' => _t('_adm_bp_dsc_page_meta_keywords'),
- 'value' => $this->aPageRebuild['meta_keywords'],
- 'db' => array (
- 'pass' => 'Xss',
- ),
- ),
- 'meta_robots' => array(
- 'type' => 'text',
- 'name' => 'meta_robots',
- 'caption' => _t('_adm_bp_txt_page_meta_robots'),
- 'info' => _t('_adm_bp_dsc_page_meta_robots'),
- 'value' => $this->aPageRebuild['meta_robots'],
- 'required' => '0',
- 'db' => array (
- 'pass' => 'Xss',
- )
- )
- )
- );
- if($bInputsOnly)
- return $aForm['inputs'];
- $oForm = new BxTemplStudioFormView($aForm);
- return $oForm->getCode();
- }
- protected function getBlockIcon($aBlock) {
- $sImageUrl = "";
- switch($aBlock['type']) {
- case BX_DOL_STUDIO_BP_BLOCK_RAW:
- case BX_DOL_STUDIO_BP_BLOCK_HTML:
- case BX_DOL_STUDIO_BP_BLOCK_RSS:
- case BX_DOL_STUDIO_BP_BLOCK_IMAGE:
- case BX_DOL_STUDIO_BP_BLOCK_LANG:
- case BX_DOL_STUDIO_BP_BLOCK_MENU:
- $sImageUrl = BxDolStudioTemplate::getInstance()->getIconUrl('bi-bp-' . $aBlock['type'] . '.png');
- break;
- case BX_DOL_STUDIO_BP_BLOCK_SERVICE:
- $sImageUrl = $this->getModuleIcon($aBlock['module'], 'page');
- break;
- }
- return $sImageUrl;
- }
- protected function getBlockModule($aBlock) {
- return $aBlock['module'] != BX_DOL_STUDIO_BP_SKELETONS ? $aBlock['module'] : BX_DOL_STUDIO_MODULE_CUSTOM;
- }
- protected function getBlockContent($aBlock) {
- $aFields = array();
- switch($aBlock['type']) {
- case BX_DOL_STUDIO_BP_BLOCK_RAW:
- $aFields = array(
- 'content' => array(
- 'type' => 'textarea',
- 'name' => 'content',
- 'caption' => _t('_adm_bp_txt_block_content_raw'),
- 'info' => _t('_adm_bp_dsc_block_content_raw'),
- 'value' => $aBlock['content'],
- 'required' => '0',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- ),
- );
- break;
- case BX_DOL_STUDIO_BP_BLOCK_HTML:
- $aFields = array(
- 'content' => array(
- 'type' => 'textarea',
- 'name' => 'content',
- 'caption' => _t('_adm_bp_txt_block_content_raw'),
- 'info' => _t('_adm_bp_dsc_block_content_raw'),
- 'value' => $aBlock['content'],
- 'required' => '0',
- 'html' => 1,
- 'db' => array (
- 'pass' => 'XssHtml',
- ),
- ),
- );
- break;
- case BX_DOL_STUDIO_BP_BLOCK_LANG:
- $aFields = array(
- 'content' => array(
- 'type' => 'textarea',
- 'name' => 'content',
- 'caption' => _t('_adm_bp_txt_block_content_lang'),
- 'info' => _t('_adm_bp_dsc_block_content_lang'),
- 'value' => $aBlock['content'] != '' ? _t($aBlock['content']) : '',
- 'required' => '0',
- 'html' => 3,
- 'db' => array (
- 'pass' => 'XssHtml',
- ),
- ),
- );
- break;
- case BX_DOL_STUDIO_BP_BLOCK_IMAGE:
- $aForm['form_attrs']['enctype'] = 'multipart/form-data';
- $iImageId = $sImageAlign = '';
- if($aBlock['content'] != '')
- list($iImageId, $sImageAlign) = explode($this->sParamsDivider, $aBlock['content']);
- $aFields = array(
- 'content' => array(
- 'type' => 'hidden',
- 'name' => 'content',
- 'value' => '',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- ),
- 'image_file' => array(
- 'type' => 'image_uploader',
- 'name' => 'image_file',
- 'caption' => _t('_adm_bp_txt_block_content_image_file'),
- 'caption_preview' => _t('_adm_bp_txt_block_content_image_preview'),
- 'info' => _t('_adm_bp_dsc_block_content_image_file'),
- 'ajax_action_delete' => $this->getPageJsObject() . '.deleteBlockImage(' . $aBlock['id'] . ')',
- 'value' => (int)$iImageId
- ),
- 'image_align' => array(
- 'type' => 'select',
- 'name' => 'image_align',
- 'caption' => _t('_adm_bp_txt_block_content_image_align'),
- 'info' => '',
- 'value' => $sImageAlign,
- 'values' => array(
- array('key' => '', 'value' => _t('_adm_bp_txt_block_content_image_align_empty')),
- array('key' => 'left', 'value' => _t('_adm_bp_txt_block_content_image_align_left')),
- array('key' => 'center', 'value' => _t('_adm_bp_txt_block_content_image_align_center')),
- array('key' => 'right', 'value' => _t('_adm_bp_txt_block_content_image_align_right')),
- ),
- 'required' => '0',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- ),
- );
- break;
- case BX_DOL_STUDIO_BP_BLOCK_RSS:
- $sRssUrl = $sRssLength = '';
- if($aBlock['content'] != '')
- list($sRssUrl, $sRssLength) = explode($this->sParamsDivider, $aBlock['content']);
- $aFields = array(
- 'content' => array(
- 'type' => 'hidden',
- 'name' => 'content',
- 'value' => '',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- ),
- 'rss_url' => array(
- 'type' => 'text',
- 'name' => 'rss_url',
- 'caption' => _t('_adm_bp_txt_block_content_rss_url'),
- 'info' => _t('_adm_bp_dsc_block_content_rss_url'),
- 'value' => $sRssUrl,
- 'required' => '0',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- ),
- 'rss_length' => array(
- 'type' => 'text',
- 'name' => 'rss_length',
- 'caption' => _t('_adm_bp_txt_block_content_rss_length'),
- 'info' => _t('_adm_bp_dsc_block_content_rss_length'),
- 'value' => $sRssLength,
- 'required' => '0',
- 'db' => array (
- 'pass' => 'Int',
- ),
- ),
- );
- break;
- case BX_DOL_STUDIO_BP_BLOCK_MENU:
- $aFields = array(
- 'content' => array(
- 'type' => 'select',
- 'name' => 'content',
- 'caption' => _t('_adm_bp_txt_block_content_menu'),
- 'info' => '',
- 'value' => $aBlock['content'],
- 'values' => array(),
- 'required' => '0',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- )
- );
- $aMenus = $this->oDb->getMenus();
- foreach($aMenus as $sKey => $sValue)
- $aFields['content']['values'][$sKey] = _t($sValue);
- asort($aFields['content']['values']);
- $aFields['content']['values'] = array_merge(array('' => _t('_adm_bp_txt_block_content_menu_empty')), $aFields['content']['values']);
- break;
- case BX_DOL_STUDIO_BP_BLOCK_SERVICE:
- $aService = array('module' => '', 'method' => '');
- if($aBlock['content'] != '')
- $aService = unserialize($aBlock['content']);
- $aFields = array(
- 'service_module' => array(
- 'type' => 'value',
- 'name' => 'service_module',
- 'caption' => _t('_adm_bp_txt_block_content_service_module'),
- 'value' => $this->getModuleTitle($aService['module'])
- ),
- 'service_method' => array(
- 'type' => 'value',
- 'name' => 'service_method',
- 'caption' => _t('_adm_bp_txt_block_content_service_method'),
- 'value' => $aService['method']
- )
- );
- break;
- }
- return $aFields;
- }
- protected function getBlockList($sModule) {
- if(empty($sModule))
- return '';
- $sJsObject = $this->getPageJsObject();
- $oTemplate = BxDolStudioTemplate::getInstance();
- $oForm = new BxTemplStudioFormView(array());
- $aInputCheckbox = array(
- 'type' => 'checkbox',
- 'name' => 'blocks[]',
- 'attrs' => array(
- 'onChange' => 'javascript:' . $sJsObject . '.onSelectBlock(this);'
- ),
- 'value' => ''
- );
- $aTmplParams = array(
- 'html_block_list_id' => $this->aHtmlIds['block_list_id'] . $sModule,
- 'bx_repeat:blocks' => array()
- );
- $aBlocks = $this->getBlocks($sModule);
- foreach($aBlocks as $aBlock) {
- $aInputCheckbox['value'] = $aBlock['id'];
- $aTmplParams['bx_repeat:blocks'][] = array(
- 'js_object' => $sJsObject,
- 'html_id' => $this->aHtmlIds['block_id'] . $aBlock['id'],
- 'bx_if:show_link' => array(
- 'condition' => false,
- 'content' => array()
- ),
- 'bx_if:show_text' => array(
- 'condition' => true,
- 'content' => array(
- 'title' => _t($aBlock['title']),
- )
- ),
- 'icon' => $this->getBlockIcon($aBlock),
- 'module' => $this->getModuleTitle($aBlock['module']),
- 'visible_for' => _t('_adm_bp_txt_visible_for', BxDolStudioUtils::getVisibilityTitle($aBlock['visible_for_levels'])),
- 'bx_if:show_checkbox' => array(
- 'condition' => true,
- 'content' => array(
- 'content' => $oForm->genRow($aInputCheckbox)
- )
- ),
- 'bx_if:show_drag_handle' => array(
- 'condition' => false,
- 'content' => array()
- )
- );
- }
- return $oTemplate->parseHtmlByName('bp_blocks_list.html', $aTmplParams);
- }
- protected function onBlockDelete($aBlock) {
- bx_import('BxDolStudioLanguagesUtils');
- BxDolStudioLanguagesUtils::getInstance()->deleteLanguageString($aBlock['title']);
- //--- Process Lang block
- if($aBlock['type'] == BX_DOL_STUDIO_BP_BLOCK_LANG && $aBlock['content'] != '')
- BxDolStudioLanguagesUtils::getInstance()->deleteLanguageString($aBlock['content']);
- //--- Process Image block
- if($aBlock['type'] == BX_DOL_STUDIO_BP_BLOCK_IMAGE && $aBlock['content'] != '') {
- $iImageId = $sImageAlign = '';
- list($iImageId, $sImageAlign) = explode($this->sParamsDivider, $aBlock['content']);
- if(is_numeric($iImageId) && (int)$iImageId != 0) {
- bx_import('BxDolStorage');
- BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES)->deleteFile((int)$iImageId, 0);
- }
- }
- }
- protected function getBlocks($sModule) {
- $aBlocks = array();
- $this->oDb->getBlocks(array('type' => 'by_module_to_copy', 'value' => $sModule), $aBlocks, false);
- return $aBlocks;
- }
- }
- /** @} */
|