| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup UnaView UNA Studio Representation classes
- * @ingroup UnaStudio
- * @{
- */
- 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 $sStorage;
- protected $sTranscoder;
- protected $aUploaders;
-
- protected $sTranscoderCover;
- protected $aUploadersCover;
- protected $sBaseUrl;
- protected $sTypeUrl;
- protected $sPageUrl;
- protected $aHtmlIds = array(
- 'add_popup_id' => 'adm-bp-add-popup',
- 'edit_popup_id' => 'adm-bp-edit-popup',
- 'uri_field_id' => 'adm-bp-field-uri',
- 'url_field_id' => 'adm-bp-field-url',
- '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',
- 'edit_block_editor_id' => 'adm-bp-edit-block-editor',
- 'block_id' => 'adm-bpb-',
- 'block_list_id' => 'adm-bpl-',
- 'block_lists_id' => 'adm-bp-block-lists',
- 'layout_id' => 'adm-bpl-',
- );
- protected $aPageSettings = array(
- array('name' => 'options', 'title' => '_adm_bp_mi_page_options', 'active' => 1),
- array('name' => 'cover', 'title' => '_adm_bp_mi_page_cover', 'active' => 0),
- 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),
- array('name' => 'injections', 'title' => '_adm_bp_mi_page_injections', 'active' => 0)
- );
- function __construct($sType = '', $sPage = '')
- {
- parent::__construct($sType, $sPage);
- $this->sStorage = BX_DOL_STORAGE_OBJ_IMAGES;
- $this->sTranscoder = 'sys_builder_page_preview';
- $this->aUploaders = array('sys_builder_page_html5');
- $this->sTranscoderCover = 'sys_cover_preview';
- $this->aUploadersCover = array('sys_std_crop_cover');
- $this->sBaseUrl = BX_DOL_URL_STUDIO . 'builder_page.php';
- $this->sTypeUrl = $this->sBaseUrl . '?type=%s';
- $this->sPageUrl = $this->sTypeUrl . '&page=%s';
- }
- function getPageCss()
- {
- $oTemplate = BxDolStudioTemplate::getInstance();
- $aUploaders = array_merge($this->aUploaders, $this->aUploadersCover);
- foreach($aUploaders as $sUploader) {
- $oUploader = BxDolUploader::getObjectInstance($sUploader, $this->sStorage, '', $oTemplate);
- if($oUploader)
- $oUploader->addCssJs();
- }
- return array_merge(parent::getPageCss(), array(
- BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'codemirror/|codemirror.css',
- 'page_layouts.css',
- 'builder_page.css'
- ));
- }
- function getPageJs()
- {
- return array_merge(parent::getPageJs(), array(
- 'codemirror/codemirror.min.js',
- 'jquery-ui/jquery-ui.min.js',
- 'jquery.ui.touch-punch.min.js',
- 'jquery.easing.js',
- 'jquery.form.min.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' => 'cog',
- ),
- BX_DOL_STUDIO_MODULE_CUSTOM => array(
- 'name' => BX_DOL_STUDIO_MODULE_CUSTOM,
- 'icon' => 'wrench',
- 'title' => '_adm_bp_cpt_type_' . BX_DOL_STUDIO_MODULE_CUSTOM,
- )
- );
- $aModulesDb = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'type', 'value' => array(BX_DOL_MODULE_TYPE_MODULE, BX_DOL_MODULE_TYPE_TEMPLATE)));
- foreach($aModulesDb as $aModuleDb) {
- $sName = $aModuleDb['name'];
- if(!empty($aMenuItems[$sName]))
- $aMenuItems[$sName] = array_merge($aMenuItems[$sName], $aModuleDb);
- else
- $aMenuItems[$sName] = $aModuleDb;
- $aMenuItems[$sName]['title'] = BxDolStudioUtils::getModuleTitle($sName);
- if(empty($aMenuItems[$sName]['icon']))
- $aMenuItems[$sName]['icon'] = BxDolStudioUtils::getModuleIcon($aModuleDb, 'menu', false);
- }
- $aMenu = array();
- foreach($aMenuItems as $aMenuItem)
- $aMenu[] = array(
- 'name' => $aMenuItem['name'],
- 'icon' => $aMenuItem['icon'],
- 'link' => sprintf($this->sTypeUrl, $aMenuItem['name']),
- 'title' => $aMenuItem['title'],
- 'selected' => $aMenuItem['name'] == $this->sType
- );
- return parent::getPageMenu($aMenu);
- }
- function getPageCode($sPage = '', $bWrap = true)
- {
- $sResult = parent::getPageCode($sPage, $bWrap);
- if($sResult === false)
- return false;
- $oPage = BxTemplPage::getObjectInstance($this->sPage);
- $oTemplate = BxDolStudioTemplate::getInstance();
- $sJsObject = $this->getPageJsObject();
- $sTxtEmpty = _t('_sys_txt_empty');
- $sContent = "";
- if(($bPage = $this->sPage != '') === true) {
- /**
- * Reset (move to hidden sell) blocks which cannot be seen,
- * because of unsuitable cell number to currently selected layout.
- */
- $this->oDb->resetBlocksByPage($this->aPageRebuild['object'], $this->aPageRebuild['layout_cells_number']);
- $aTmplVars = array(
- 'page_id' => 'bx-page-' . $this->aPageRebuild['uri'],
- 'bx_if:show_layout_row_dump' => array(
- 'condition' => true,
- 'content' => array()
- )
- );
- for($i = 0; $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) {
- $sTitle = !empty($aBlock['title_system']) ? _t($aBlock['title_system']) : $oPage->getBlockTitle($aBlock);
- list($sIcon, $sIconUrl) = $this->getBlockIcon($aBlock);
- $aTmplVarsCell['bx_repeat:blocks'][] = array(
- 'html_id' => $this->aHtmlIds['block_id'] . $aBlock['id'],
- 'bx_if:is_inactive' => array(
- 'condition' => (int)$aBlock['active'] == 0,
- 'content' => array()
- ),
- 'bx_if:show_link' => array(
- 'condition' => true,
- 'content' => array(
- 'onclick' => $sJsObject . ".performAction('block_edit', {id: " . $aBlock['id'] . "})",
- 'title' => !empty($sTitle) ? $sTitle : $sTxtEmpty,
- )
- ),
- 'bx_if:show_text' => array(
- 'condition' => false,
- 'content' => array()
- ),
- 'bx_if:show_api' => [
- 'condition' => (int)$aBlock['active_api'] != 0,
- 'content' => []
- ],
- 'bx_if:image' => array (
- 'condition' => (bool)$sIconUrl,
- 'content' => array('icon_url' => $sIconUrl),
- ),
- 'bx_if:icon' => array (
- 'condition' => (bool)$sIcon,
- 'content' => array('icon' => $sIcon),
- ),
- '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()
- )
- );
- }
- $sCell = $oTemplate->parseHtmlByName('bp_cell.html', $aTmplVarsCell);
- if($i == 0)
- $aTmplVars['bx_if:show_layout_row_dump']['content']['cell_' . $i] = $sCell;
- else
- $aTmplVars['cell_' . $i] = $sCell;
- }
- $sContent = $oTemplate->parseHtmlByName($this->aPageRebuild['layout_template'], $aTmplVars);
- }
- $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' => json_encode($this->aHtmlIds),
- 'languahes' => json_encode($aLanguages),
- 'content' => $this->getBlockCode(array(
- 'items' => $sContent
- ))
- );
- $oTemplate->addJsTranslation(array(
- '_adm_bp_wrn_page_delete',
- '_adm_bp_wrn_page_block_delete'
- ));
- return $sResult . $oTemplate->parseHtmlByName('builder_page.html', $aTmplVars);
- }
- function getBlockPanelTop($aBlock)
- {
- return parent::getBlockPanelTop(
- array('panel_top' => BxDolStudioTemplate::getInstance()->parseHtmlByName('bp_block_panel_top.html', $this->_getTmplVarsBlockPanelTop()))
- );
- }
- protected function actionPageCreate()
- {
- $sJsObject = $this->getPageJsObject();
- $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',
- ),
- ),
- 'settings' => array(
- 'type' => 'custom',
- 'name' => 'settings',
- 'content' => $oTemplate->parseHtmlByName('bp_edit_page_form.html', $this->_getTmplVarsPageSettings()),
- ),
- )
- );
- $oForm = new BxTemplStudioFormView($aForm);
- $oForm->initChecker();
- if($oForm->isSubmittedAndValid()) {
- unset($oForm->aInputs['settings']);
- foreach($this->aPageSettings as $aSetting)
- $oForm->aInputs = array_merge($oForm->aInputs, $this->{'getSettings' . $this->getClassName($aSetting['name']) . 'Fields'}());
- $sLanguage = BxDolStudioLanguagesUtils::getInstance()->getCurrentLangName(false);
- $sObject = BxDolForm::getSubmittedValue('title-' . $sLanguage, $aForm['form_attrs']['method']);
- $sObject = uriGenerate($sObject, 'sys_objects_page', 'object', ['empty' => 'object']);
- $sUri = $oForm->getCleanValue('uri');
-
- $aPage = $this->oDb->getPages(array('type' => 'by_uri', 'value' => $sUri));
- if(!empty($aPage) && is_array($aPage))
- return array('msg' => _t('_adm_bp_err_page_uri'));
- $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']);
- $iId = (int)$oForm->insert(array('author' => bx_get_logged_profile_id(), 'added' => time(), 'object' => $sObject, 'url' => $this->sPageBaseUrl . $sUri));
- if($iId != 0)
- return array('eval' => $sJsObject . '.onCreatePage(\'' . $sModule . '\', \'' . $sObject . '\')');
- else
- return array('msg' => _t('_adm_bp_err_page_create'));
- }
- $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['add_popup_id'], _t('_adm_bp_txt_create_popup'), $oTemplate->parseHtmlByName('bp_add_page.html', array(
- 'js_object' => $sJsObject,
- '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' => $oTemplate->parseHtmlByName('bp_edit_page_form.html', $this->_getTmplVarsPageSettings($this->aPageRebuild, false)),
- ),
- )
- );
- $oForm = new BxTemplStudioFormView($aForm);
- $oForm->initChecker();
- if($oForm->isSubmittedAndValid()) {
- unset($oForm->aInputs['settings']);
- foreach($this->aPageSettings as $aSetting)
- $oForm->aInputs = array_merge($oForm->aInputs, $this->{'getSettings' . $this->getClassName($aSetting['name']) . 'Fields'}($this->aPageRebuild, false));
- $mixedVisibleFor = $oForm->getCleanValue('visible_for');
- $mixedVisibleForLevels = $oForm->getCleanValue('visible_for_levels');
- if($mixedVisibleFor !== false && $mixedVisibleForLevels !== false) {
- $iVisibleFor = BxDolStudioUtils::getVisibilityValue($mixedVisibleFor, $mixedVisibleForLevels);
- 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 . '.onSaveSettingsLayout()');
- }
- return array();
- }
- else
- return array('msg' => _t('_adm_bp_err_save'));
- }
- $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['edit_popup_id'], _t('_adm_bp_txt_settings_popup'), $oTemplate->parseHtmlByName('bp_edit_page.html', array(
- 'js_object' => $sJsObject,
- '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'));
- $oLangauge = BxDolStudioLanguagesUtils::getInstance();
- $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 = "' . sprintf($this->sTypeUrl, $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' => 'qrcode',
- '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' => 'cog',
- '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' => 'wrench',
- 'title' => '_sys_block_types_custom',
- 'selected' => $sSelected == BX_DOL_STUDIO_MODULE_CUSTOM,
- )
- );
- $aModules = BxDolModuleQuery::getInstance()->getModulesBy(['type' => 'type', 'value' => [BX_DOL_MODULE_TYPE_MODULE, BX_DOL_MODULE_TYPE_TEMPLATE]]);
- $aModulesWithBlocks = $this->oDb->getModulesWithCopyableBlocks();
- foreach($aModules as $aModule) {
- $sName = $aModule['name'];
- if(!in_array($sName, $aModulesWithBlocks))
- continue;
- if(!empty($aMenu[$sName]))
- $aMenu[$sName] = array_merge($aMenu[$sName], $aModule);
- else
- $aMenu[$sName] = $aModule;
- if(empty($aMenu[$sName]['icon']))
- $aMenu[$sName]['icon'] = BxDolStudioUtils::getModuleIcon($aModule, 'menu', false);
- }
- foreach($aMenu as $sKey => $aItem)
- $aMenu[$sKey]['onclick'] = $sJsObject . '.onChangeModule(\'' . $aItem['name'] . '\', this);';
- $oMenu = new BxTemplStudioMenu(array('template' => 'menu_side.html', 'menu_items' => $aMenu));
- $oMenu->setInlineIcons(false);
- $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);
- $oLanguage = BxDolStudioLanguagesUtils::getInstance();
- $oStorege = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
- $bResult = true;
- foreach($aBlocks as $aBlock) {
- $sModule = $aBlock['module'];
- $sTitleKey = $this->getSystemName($aBlock['title'] . '_' . time());
- $aTitleValues = $oLanguage->getLanguageString($aBlock['title']);
- unset($aBlock['id']);
- $aBlock['object'] = $this->sPage;
- $aBlock['cell_id'] = 1;
- $aBlock['module'] = $this->getBlockModule($aBlock);
- $aBlock['title'] = $sTitleKey;
- $aBlock['copyable'] = $sModule == BX_DOL_STUDIO_BP_SKELETONS ? 1 : 0;
- $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));
- }
- // add indexing data
- $aBlock = array_merge($aBlock, $this->getIndexingDataForBlock($aBlock['type'], $aBlock['content']));
- if(!$this->oDb->insertBlock($aBlock)) {
- if($sContentKey != "")
- $oLanguage->deleteLanguageString($sContentKey);
- if($iImageId != "")
- $oStorege->deleteFile((int)$iImageId, 0);
- $bResult = false;
- break;
- }
- //--- Process Title copy
- foreach($aTitleValues as $iLangId => $aTitleValue)
- $oLanguage->addLanguageString($sTitleKey, $aTitleValue['string'], $iLangId);
- }
- if($bResult)
- return array('eval' => $sJsObject . '.onCreateBlock(oData)');
- else
- return array('msg' => _t('_adm_bp_err_block_added'));
- }
- $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['create_block_popup_id'], _t('_adm_bp_txt_new_block_popup'), $oTemplate->parseHtmlByName('bp_add_block.html', array(
- 'action' => 'create',
- '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'));
- bx_import('BxDolStudioUtils');
- $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' => 'LengthTranslatable',
- 'params' => array(3, 100, 'title'),
- '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'),
- ),
- ),
- 'async' => array(
- 'type' => 'select',
- 'name' => 'async',
- 'caption' => _t('_adm_bp_txt_block_async'),
- 'info' => '',
- 'value' => isset($aBlock['async']) ? $aBlock['async'] : 0,
- 'required' => '0',
- 'db' => array (
- 'pass' => 'Int',
- ),
- ),
- 'submenu' => array(
- 'type' => 'select',
- 'name' => 'submenu',
- 'caption' => _t('_adm_bp_txt_block_submenu'),
- 'info' => '',
- 'value' => isset($aBlock['submenu']) ? $aBlock['submenu'] : '',
- 'required' => '0',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- ),
- 'tabs' => array(
- 'type' => 'switcher',
- 'name' => 'tabs',
- 'caption' => _t('_adm_bp_txt_block_tabs'),
- 'info' => '',
- 'value' => '1',
- 'checked' => $aBlock['tabs'] == '1',
- 'db' => array (
- 'pass' => 'Int',
- )
- ),
- 'hidden_on' => array(
- 'type' => 'select_multiple',
- 'name' => 'hidden_on',
- 'caption' => _t('_adm_bp_txt_block_hidden_on'),
- 'info' => '',
- 'value' => (int)$aBlock['hidden_on'],
- 'values' => array(
- BX_DB_HIDDEN_PHONE => _t('_adm_bp_txt_block_hidden_on_phone'),
- BX_DB_HIDDEN_TABLET => _t('_adm_bp_txt_block_hidden_on_tablet'),
- BX_DB_HIDDEN_DESKTOP => _t('_adm_bp_txt_block_hidden_on_desktop'),
- BX_DB_HIDDEN_MOBILE => _t('_adm_bp_txt_block_hidden_on_mobile')
- ),
- 'db' => array (
- 'pass' => 'Set',
- )
- ),
- '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' => $sJsObject . '.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',
- )
- ),
- 'content_empty' => array(
- 'type' => 'text_translatable',
- 'name' => 'content_empty',
- 'caption' => _t('_adm_bp_txt_block_content_empty'),
- 'info' => _t('_adm_bp_dsc_block_content_empty'),
- 'value' => $aBlock['content_empty'],
- 'db' => array (
- 'pass' => 'Xss',
- ),
- ),
- 'help' => array(
- 'type' => 'textarea_translatable',
- 'name' => 'help',
- 'caption' => _t('_adm_bp_txt_block_help'),
- 'info' => '',
- 'value' => $aBlock['help'],
- 'required' => '0',
- 'html' => 2,
- 'db' => array (
- 'pass' => 'Xss',
- ),
- ),
- 'class' => array(
- 'type' => 'text',
- 'name' => 'class',
- 'caption' => _t('_adm_bp_txt_block_class'),
- 'info' => '',
- 'value' => $aBlock['class'],
- 'required' => '0',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- ),
- 'cache_lifetime' => array(
- 'type' => 'text',
- 'name' => 'cache_lifetime',
- 'caption' => _t('_adm_bp_txt_block_cache_lifetime'),
- 'info' => '',
- 'value' => isset($aBlock['cache_lifetime']) ? $aBlock['cache_lifetime'] : 0,
- 'required' => '0',
- 'db' => array (
- 'pass' => 'Int',
- ),
- ),
- 'active' => array(
- 'type' => 'switcher',
- 'name' => 'active',
- 'caption' => _t('_adm_bp_txt_block_active'),
- 'info' => '',
- 'value' => '1',
- 'checked' => $aBlock['active'] == '1',
- 'db' => array (
- 'pass' => 'Int',
- )
- ),
- 'active_api' => array(
- 'type' => 'switcher',
- 'name' => 'active_api',
- 'caption' => _t('_adm_bp_txt_block_active_api'),
- 'info' => '',
- 'value' => '1',
- 'checked' => $aBlock['active_api'] == '1',
- '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' => $sJsObject . '.onEditBlockCancel(this)',
- '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']));
- $aContentPlaceholders = $this->oDb->getContentPlaceholders();
- $aForm['inputs']['async']['values'][] = array('key' => 0, 'value' => _t('_sys_no_async'));
- foreach ($aContentPlaceholders as $iKey => $sTitle)
- $aForm['inputs']['async']['values'][] = array('key' => $iKey, 'value' => _t($sTitle));
- $aSubmenus = $this->oDb->getBlockSubmenus();
- $aForm['inputs']['submenu']['values'][] = array('key' => '', 'value' => _t('_sys_menu_item_title_inherited'));
- $aForm['inputs']['submenu']['values'][] = array('key' => 'disabled', 'value' => _t('_sys_menu_item_title_disabled'));
- foreach ($aSubmenus as $sObject => $sTitle)
- $aForm['inputs']['submenu']['values'][] = array('key' => $sObject, 'value' => _t($sTitle));
- 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));
- if((int)$aBlock['deletable'] != 0)
- $aForm['inputs']['controls'][] = array (
- 'type' => 'reset',
- 'name' => 'close',
- 'value' => _t('_adm_bp_btn_block_delete'),
- 'attrs' => array(
- 'onclick' => $sJsObject . '.deleteBlock(' . $aBlock['id'] . ')',
- 'class' => 'bx-def-margin-sec-left',
- ),
- );
- $oForm = new BxTemplStudioFormView($aForm);
- $oForm->initChecker();
- if($oForm->isSubmittedAndValid()) {
- $this->onSaveBlock($oForm, $aBlock);
- // add indexing data
- $aBlockAddon = $this->getIndexingDataForBlock($aBlock['type'], $oForm->getCleanValue('content'));
- if($oForm->update($iId, $aBlockAddon) !== false)
- return array('eval' => $sJsObject . '.onEditBlock(oData)');
- else
- return array('msg' => _t('_adm_bp_err_block_edit'));
- }
- $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(
- 'action' => 'edit',
- 'form_id' => $aForm['form_attrs']['id'],
- 'form' => $oForm->getCode(true)
- )));
- return array('popup' => array('html' => $sContent, 'options' => array('onBeforeShow' => $sJsObject . '.onEditBlockBeforeShow($el)')));
- }
- 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((int)$aBlock['deletable'] == 0)
- return array('msg' => _t('_adm_bp_err_block_not_deletable'));
- 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 actionUriGet()
- {
- $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(($mixedValue = bx_get('uri')) !== false)
- $sUri = bx_process_input($mixedValue);
- else 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') : "";
- $sUrl = BxDolPermalinks::getInstance()->permalink($this->sPageBaseUrl . $sUri);
- return array('eval' => $this->getPageJsObject() . '.onGetUri(oData)', 'uri' => $sUri, 'url' => $sUrl);
- }
- protected function getSettingsOptions($aPage = array(), $bCreate = true, $bInputsOnly = false)
- {
- $aForm = array(
- 'form_attrs' => array(
- 'id' => 'adm-bp-settings-options',
- ),
- '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' => isset($aPage['title_system']) ? $aPage['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' => isset($aPage['title']) ? $aPage['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' => isset($aPage['url']) ? BxDolPermalinks::getInstance()->permalink($aPage['url']) : '',
- 'required' => '0',
- 'attrs' => array(
- 'id' => $this->aHtmlIds['url_field_id'],
- 'disabled' => 'disabled'
- ),
- ),
- 'type_id' => array(
- 'type' => 'select',
- 'name' => 'type_id',
- 'caption' => _t('_adm_bp_txt_page_type_id'),
- 'info' => _t('_adm_bp_dsc_page_type_id'),
- 'value' => isset($aPage['type_id']) ? $aPage['type_id'] : '',
- 'required' => '1',
- 'db' => array (
- 'pass' => 'Int',
- ),
- ),
- 'submenu' => array(
- 'type' => 'select',
- 'name' => 'submenu',
- 'caption' => _t('_adm_bp_txt_page_submenu'),
- 'info' => _t('_adm_bp_dsc_page_submenu'),
- 'value' => isset($aPage['submenu']) ? $aPage['submenu'] : '',
- 'required' => '0',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- ),
- 'sticky_columns' => array(
- 'type' => 'switcher',
- 'name' => 'sticky_columns',
- 'caption' => _t('_adm_bp_txt_page_sticky_columns'),
- 'info' => '',
- 'value' => '1',
- 'checked' => isset($aPage['sticky_columns']) && $aPage['sticky_columns'] == 1,
- 'db' => array (
- 'pass' => 'Int',
- )
- )
- )
- );
-
- $aTypes = array();
- $this->oDb->getTypes(array('type' => 'all'), $aTypes, false);
- foreach($aTypes as $aType)
- $aForm['inputs']['type_id']['values'][] = array('key' => $aType['id'], 'value' => _t($aType['title']));
- $aSubmenus = $this->oDb->getSubmenus();
- $aForm['inputs']['submenu']['values'][] = array('key' => '', 'value' => _t('_sys_menu_item_title_inherited'));
- $aForm['inputs']['submenu']['values'][] = array('key' => 'disabled', 'value' => _t('_sys_menu_item_title_disabled'));
- foreach ($aSubmenus as $sObject => $sTitle)
- $aForm['inputs']['submenu']['values'][] = array('key' => $sObject, 'value' => _t($sTitle));
- if($bCreate) {
- $sJsObject = $this->getPageJsObject();
- $aForm['inputs']['title']['attrs']['onblur'] = $sJsObject . '.getUri(this);';
- $aForm['inputs'] = bx_array_insert_before(array(
- 'uri' => array(
- 'type' => 'text',
- 'name' => 'uri',
- 'caption' => _t('_adm_bp_txt_page_uri'),
- 'info' => _t('_adm_bp_dsc_page_uri'),
- 'value' => '',
- 'required' => '1',
- 'attrs' => array(
- 'id' => $this->aHtmlIds['uri_field_id'],
- 'onblur' => $sJsObject . '.getUri(this);'
- ),
- 'db' => array (
- 'pass' => 'Xss',
- ),
- 'checker' => array (
- 'func' => 'length',
- 'params' => array(3,100),
- 'error' => _t('_adm_bp_err_page_uri'),
- ),
- )
- ), $aForm['inputs'], 'url');
- }
- if($bInputsOnly)
- return $aForm['inputs'];
- $oForm = new BxTemplStudioFormView($aForm);
- return $oForm->getCode();
- }
- protected function getSettingsOptionsFields($aPage = array(), $bCreate = true)
- {
- return $this->getSettingsOptions($aPage, $bCreate, true);
- }
- protected function getSettingsCover($aPage = array(), $bCreate = true, $bInputsOnly = false)
- {
- $aForm = array(
- 'form_attrs' => array(
- 'id' => 'adm-bp-settings-cover',
- ),
- 'params' => array (
- 'remove_form' => '1',
- 'csrf' => array(
- 'disable' => true
- )
- ),
- 'inputs' => array (
- 'cover' => array(
- 'type' => 'select',
- 'name' => 'cover',
- 'caption' => _t('_adm_bp_txt_page_cover'),
- 'info' => '',
- 'value' => isset($aPage['cover']) ? (int)$aPage['cover'] : '1',
- 'values' => array(
- array('key' => 0, 'value' => _t('_adm_bp_txt_page_cover_0')),
- array('key' => 1, 'value' => _t('_adm_bp_txt_page_cover_1')),
- array('key' => 2, 'value' => _t('_adm_bp_txt_page_cover_2')),
- array('key' => 3, 'value' => _t('_adm_bp_txt_page_cover_3'))
- ),
- 'db' => array (
- 'pass' => 'Int',
- )
- ),
- 'cover_image' => array(
- 'type' => 'files',
- 'name' => 'cover_image',
- 'storage_object' => $this->sStorage,
- 'images_transcoder' => $this->sTranscoderCover,
- 'uploaders' => $this->aUploadersCover,
- 'multiple' => false,
- 'content_id' => isset($aPage['id']) ? $aPage['id'] : 0,
- 'ghost_template' => BxTemplStudioFunctions::getInstance()->getDefaultGhostTemplate('cover_image'),
- 'caption' => _t('_adm_bp_txt_page_cover_image'),
- 'db' => array (
- 'pass' => 'Int',
- )
- ),
- 'cover_title' => array(
- 'type' => 'text_translatable',
- 'name' => 'cover_title',
- 'caption' => _t('_adm_bp_txt_page_cover_title'),
- 'info' => '',
- 'value' => isset($aPage['cover_title']) ? $aPage['cover_title'] : '',
- 'db' => array (
- 'pass' => 'Xss',
- )
- ),
- )
- );
- if($bInputsOnly)
- return $aForm['inputs'];
- $oForm = new BxTemplStudioFormView($aForm);
- return $oForm->getCode();
- }
- protected function getSettingsCoverFields($aPage = array(), $bCreate = true)
- {
- return $this->getSettingsCover($aPage, $bCreate, true);
- }
- protected function getSettingsLayout($aPage = array(), $bCreate = true, $bInputsOnly = false)
- {
- $sJsObject = $this->getPageJsObject();
- $oTemplate = BxDolStudioTemplate::getInstance();
- $iLayout = isset($aPage['layout_id']) ? (int)$aPage['layout_id'] : 5;
- $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)$aLayout['id'] == $iLayout,
- 'content' => array()
- ),
- 'icon' => $oTemplate->getImageUrl($aLayout['icon']),
- 'title' => _t($aLayout['title']),
- );
- $aForm = array(
- 'form_attrs' => array(
- 'id' => 'adm-bp-settings-layout',
- ),
- 'params' => array (
- 'remove_form' => '1',
- 'csrf' => array(
- 'disable' => true
- )
- ),
- 'inputs' => array (
- 'layout_id' => array(
- 'type' => 'hidden',
- 'name' => 'layout_id',
- 'value' => $iLayout,
- '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 getSettingsLayoutFields($aPage = array(), $bCreate = true)
- {
- return $this->getSettingsLayout($aPage, $bCreate, true);
- }
- protected function getSettingsVisibility($aPage = array(), $bCreate = true, $bInputsOnly = false)
- {
- $iVisibleForLevels = isset($aPage['visible_for_levels']) ? (int)$aPage['visible_for_levels'] : BX_DOL_INT_MAX;
- if(isset($aPage['visible_for_levels_editable']) && (int)$aPage['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 {
- bx_import('BxDolStudioUtils');
- $aInputs = array(
- 'visible_for' => array(
- 'type' => 'select',
- 'name' => 'visible_for',
- 'caption' => _t('_adm_bp_txt_block_visible_for'),
- 'info' => '',
- 'value' => $iVisibleForLevels == 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' => array(),
- 'values' => array(),
- 'tr_attrs' => array(
- 'style' => $iVisibleForLevels == 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
- );
- BxDolStudioUtils::getVisibilityValues($iVisibleForLevels, $aForm['inputs']['visible_for_levels']['values'], $aForm['inputs']['visible_for_levels']['value']);
- if($bInputsOnly)
- return $aForm['inputs'];
- $oForm = new BxTemplStudioFormView($aForm);
- return $oForm->getCode();
- }
- protected function getSettingsVisibilityFields($aPage = array(), $bCreate = true)
- {
- return $this->getSettingsVisibility($aPage, $bCreate, true);
- }
- protected function getSettingsCache($aPage = array(), $bCreate = true, $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' => isset($aPage['cache_lifetime']) ? $aPage['cache_lifetime'] : 0,
- 'required' => '',
- 'attrs' => array(
- 'disabled' => isset($aPage['cache_editable']) && (int)$aPage['cache_editable'] == 0 ? 'disabled' : ''
- ),
- 'db' => array (
- 'pass' => 'Int',
- )
- ),
- )
- );
- if($bInputsOnly)
- return $aForm['inputs'];
- $oForm = new BxTemplStudioFormView($aForm);
- return $oForm->getCode();
- }
- protected function getSettingsCacheFields($aPage = array(), $bCreate = true)
- {
- return $this->getSettingsCache($aPage, $bCreate, true);
- }
- protected function getSettingsSeo($aPage = array(), $bCreate = true, $bInputsOnly = false)
- {
- $aForm = array(
- 'form_attrs' => array(
- 'id' => 'adm-bp-settings-seo',
- ),
- 'params' => array (
- 'remove_form' => '1',
- 'csrf' => array(
- 'disable' => true
- )
- ),
- 'inputs' => array (
- 'meta_title' => array(
- 'type' => 'textarea',
- 'name' => 'meta_title',
- 'caption' => _t('_adm_bp_txt_page_meta_title'),
- 'value' => isset($aPage['meta_title']) ? $aPage['meta_title'] : '',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- ),
- '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' => isset($aPage['meta_description']) ? $aPage['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' => isset($aPage['meta_keywords']) ? $aPage['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' => isset($aPage['meta_robots']) ? $aPage['meta_robots'] : '',
- 'required' => '0',
- 'db' => array (
- 'pass' => 'Xss',
- )
- )
- )
- );
- if($bInputsOnly)
- return $aForm['inputs'];
- $oForm = new BxTemplStudioFormView($aForm);
- return $oForm->getCode();
- }
- protected function getSettingsSeoFields($aPage = array(), $bCreate = true)
- {
- return $this->getSettingsSeo($aPage, $bCreate, true);
- }
- protected function getSettingsInjections($aPage = array(), $bCreate = true, $bInputsOnly = false)
- {
- $aForm = array(
- 'form_attrs' => array(
- 'id' => 'adm-bp-injections-seo',
- ),
- 'params' => array (
- 'remove_form' => '1',
- 'csrf' => array(
- 'disable' => true
- )
- ),
- 'inputs' => array (
- 'inj_head' => array(
- 'type' => 'textarea',
- 'name' => 'inj_head',
- 'caption' => _t('_adm_bp_txt_page_inj_head'),
- 'info' => _t('_adm_bp_dsc_page_inj_head'),
- 'value' => isset($aPage['inj_head']) ? $aPage['inj_head'] : '',
- 'code' => 1,
- 'db' => array (
- 'pass' => 'XssHtml',
- ),
- ),
- 'inj_footer' => array(
- 'type' => 'textarea',
- 'name' => 'inj_footer',
- 'caption' => _t('_adm_bp_txt_page_inj_footer'),
- 'info' => _t('_adm_bp_dsc_page_inj_footer'),
- 'value' => isset($aPage['inj_footer']) ? $aPage['inj_footer'] : '',
- 'code' => 1,
- 'db' => array (
- 'pass' => 'XssHtml',
- ),
- )
- )
- );
- if($bInputsOnly)
- return $aForm['inputs'];
- $oForm = new BxTemplStudioFormView($aForm);
- return $oForm->getCode();
- }
- protected function getSettingsInjectionsFields($aPage = array(), $bCreate = true)
- {
- return $this->getSettingsInjections($aPage, $bCreate, true);
- }
- protected function getBlockIcon($aBlock)
- {
- $sIcon = $sIconUrl = "";
- $sResult = '';
- switch($aBlock['type']) {
- case BX_DOL_STUDIO_BP_BLOCK_RAW:
- $sResult = 'far file-alt';
- break;
- case BX_DOL_STUDIO_BP_BLOCK_HTML:
- $sResult = 'code';
- break;
- case BX_DOL_STUDIO_BP_BLOCK_RSS:
- $sResult = 'rss';
- break;
- case BX_DOL_STUDIO_BP_BLOCK_IMAGE:
- $sResult = 'far image';
- break;
- case BX_DOL_STUDIO_BP_BLOCK_LANG:
- $sResult = 'globe';
- break;
- case BX_DOL_STUDIO_BP_BLOCK_MENU:
- $sResult = 'list-alt';
- break;
- case BX_DOL_STUDIO_BP_BLOCK_WIKI:
- $sResult = 'file-word';
- break;
- case BX_DOL_STUDIO_BP_BLOCK_CUSTOM:
- $sResult = 'file';
- break;
- case BX_DOL_STUDIO_BP_BLOCK_SERVICE:
- $sResult = $this->getModuleIcon($aBlock['module'], 'page');
- break;
- }
- if(strpos($sResult, '.') === false)
- $sIcon = $sResult;
- else
- $sIconUrl = $sResult;
- return array($sIcon, $sIconUrl);
- }
- 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_CUSTOM:
- case BX_DOL_STUDIO_BP_BLOCK_RAW:
- $aFields = [
- 'content' => [
- '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',
- 'code' => 1,
- 'attrs' => [
- 'class' => 'bx-form-input-textarea-codemirror'
- ],
- 'db' => [
- 'pass' => 'XssHtml',
- ],
- ],
- ];
- break;
- case BX_DOL_STUDIO_BP_BLOCK_HTML:
- $aFields = [
- 'content' => [
- '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' => 2,
- 'attrs' => [
- 'id' => $this->aHtmlIds['edit_block_editor_id']
- ],
- 'db' => [
- 'pass' => 'XssHtml',
- ],
- ],
- 'attachments' => [
- 'type' => 'files',
- 'name' => 'attachments',
- 'storage_object' => $this->sStorage,
- 'images_transcoder' => $this->sTranscoder,
- 'uploaders' => $this->aUploaders,
- 'multiple' => true,
- 'content_id' => $aBlock['id'],
- 'ghost_template' => BxDolStudioTemplate::getInstance()->parseHtmlByName('bp_fgt_attachments.html', [
- 'js_object' => $this->getPageJsObject(),
- 'name' => 'attachments',
- 'editor_id' => $this->aHtmlIds['edit_block_editor_id'],
- ]),
- 'caption' => _t('_adm_bp_txt_block_content_attachments_html')
- ]
- ];
- break;
- case BX_DOL_STUDIO_BP_BLOCK_LANG:
- $aFields = [
- 'content' => [
- 'type' => 'textarea_translatable',
- 'name' => 'content',
- 'caption' => _t('_adm_bp_txt_block_content_lang'),
- 'info' => _t('_adm_bp_dsc_block_content_lang'),
- 'value' => $aBlock['content'],
- 'required' => '0',
- 'html' => 2,
- 'db' => [
- 'pass' => 'XssHtml',
- ],
- ],
- ];
- break;
- case BX_DOL_STUDIO_BP_BLOCK_IMAGE:
- $iImageId = $sImageAlign = '';
- if($aBlock['content'] != '')
- list($iImageId, $sImageAlign) = explode($this->sParamsDivider, $aBlock['content']);
- $aFields = [
- 'content' => [
- 'type' => 'hidden',
- 'name' => 'content',
- 'value' => '',
- 'db' => [
- 'pass' => 'Xss',
- ],
- ],
- 'image_file' => [
- 'type' => 'files',
- 'name' => 'image_file',
- 'storage_object' => BX_DOL_STORAGE_OBJ_IMAGES,
- 'images_transcoder' => 'sys_image_resize',
- 'uploaders' => ['sys_html5'],
- 'multiple' => false,
- 'content_id' => $aBlock['id'],
- 'ghost_template' => BxTemplStudioFunctions::getInstance()->getDefaultGhostTemplate('image_file'),
- 'caption' => _t('_adm_bp_txt_block_content_image_file'),
- ],
- 'image_align' => [
- 'type' => 'select',
- 'name' => 'image_align',
- 'caption' => _t('_adm_bp_txt_block_content_image_align'),
- 'info' => '',
- 'value' => $sImageAlign,
- 'values' => [
- ['key' => '', 'value' => _t('_adm_bp_txt_block_content_image_align_empty')],
- ['key' => 'left', 'value' => _t('_adm_bp_txt_block_content_image_align_left')],
- ['key' => 'center', 'value' => _t('_adm_bp_txt_block_content_image_align_center')],
- ['key' => 'right', 'value' => _t('_adm_bp_txt_block_content_image_align_right')],
- ],
- 'required' => '0',
- 'db' => [
- 'pass' => 'Xss',
- ],
- ],
- ];
- break;
- case BX_DOL_STUDIO_BP_BLOCK_RSS:
- $sRssUrl = $sRssLength = '';
- if($aBlock['content'] != '')
- list($sRssUrl, $sRssLength) = explode($this->sParamsDivider, $aBlock['content']);
- $aFields = [
- 'content' => [
- 'type' => 'hidden',
- 'name' => 'content',
- 'value' => '',
- 'db' => [
- 'pass' => 'Xss',
- ],
- ],
- 'rss_url' => [
- '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' => [
- 'pass' => 'Xss',
- ],
- ],
- 'rss_length' => [
- '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' => [
- 'pass' => 'Int',
- ],
- ],
- ];
- break;
- case BX_DOL_STUDIO_BP_BLOCK_MENU:
- $aFields = [
- 'content' => [
- 'type' => 'select',
- 'name' => 'content',
- 'caption' => _t('_adm_bp_txt_block_content_menu'),
- 'info' => '',
- 'value' => $aBlock['content'],
- 'values' => [],
- 'required' => '0',
- 'db' => [
- 'pass' => 'Xss',
- ],
- ]
- ];
- $sGroup = '';
- $aMenus = $this->oDb->getMenus(true);
- foreach($aMenus as $sKey => $aMenu) {
- if($sGroup != $aMenu['module']) {
- if(!empty($sGroup))
- $aFields['content']['values'][$sGroup . '_end'] = ['type' => 'group_end'];
- $sGroup = $aMenu['module'];
- $aFields['content']['values'][$sGroup . '_beg'] = ['type' => 'group_header', 'value' => BxDolStudioUtils::getModuleTitle($sGroup)];
- }
- $aFields['content']['values'][$sKey] = _t($aMenu['title']);
- }
- $aFields['content']['values'] = array_merge(['' => _t('_adm_bp_txt_block_content_menu_empty')], $aFields['content']['values']);
- break;
- case BX_DOL_STUDIO_BP_BLOCK_SERVICE:
- $aService = ['module' => '', 'method' => ''];
- if($aBlock['content'] != '')
- $aService = unserialize($aBlock['content']);
- $aFields = [
- 'service_module' => [
- 'type' => 'value',
- 'name' => 'service_module',
- 'caption' => _t('_adm_bp_txt_block_content_service_module'),
- 'value' => $this->getModuleTitle($aService['module'])
- ],
- 'service_method' => [
- '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) {
- list($sIcon, $sIconUrl) = $this->getBlockIcon($aBlock);
- $aInputCheckbox['value'] = $aBlock['id'];
- $aTmplParams['bx_repeat:blocks'][] = array(
- 'js_object' => $sJsObject,
- 'html_id' => $this->aHtmlIds['block_id'] . $aBlock['id'],
- 'bx_if:is_inactive' => array(
- 'condition' => false,
- 'content' => array()
- ),
- 'bx_if:show_link' => array(
- 'condition' => false,
- 'content' => array()
- ),
- 'bx_if:show_text' => array(
- 'condition' => true,
- 'content' => array(
- 'title' => _t(!empty($aBlock['title_system']) ? $aBlock['title_system'] : $aBlock['title']),
- )
- ),
- 'bx_if:image' => array (
- 'condition' => (bool)$sIconUrl,
- 'content' => array('icon_url' => $sIconUrl),
- ),
- 'bx_if:icon' => array (
- 'condition' => (bool)$sIcon,
- 'content' => array('icon' => $sIcon),
- ),
- '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)
- {
- if($aBlock['module'] != BX_DOL_STUDIO_MODULE_CUSTOM)
- return;
- 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)
- 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;
- }
- protected function _getTmplVarsBlockPanelTop()
- {
- $sJsObject = $this->getPageJsObject();
- $oForm = new BxTemplStudioFormView(array());
- $aPages = $this->oDb->getPages(array('type' => 'by_module', 'value' => $this->sType));
- $aCounter = array();
- $this->oDb->getBlocks(array('type' => 'counter_by_pages'), $aCounter, false);
-
- $aInputPagesValues = [];
- foreach($aPages as $aPage) {
- $sTitle = _t($aPage['title_system']);
- if(empty($sTitle))
- $sTitle = _t($aPage['title']);
- $aInputPagesValues[] = array(
- 'key' => $aPage['object'],
- 'value' => $sTitle . " (" . (isset($aCounter[$aPage['object']]) ? $aCounter[$aPage['object']] : "0") . ")"
- );
- }
- usort($aInputPagesValues, function($aV1, $aV2) {
- return strcmp($aV1['value'], $aV2['value']);
- });
- $aInputPages = array(
- 'type' => 'select',
- 'name' => 'page',
- 'attrs' => array(
- 'onChange' => 'javascript:' . $this->getPageJsObject() . '.onChangePage(this)'
- ),
- 'value' => $this->sPage,
- 'values' => array_merge([[
- 'key' => '',
- 'value' => _t('_adm_bp_txt_select_page')]
- ], $aInputPagesValues)
- );
- $aTmplVarsActions = array();
- if(($this->sPage != '' && !empty($this->aPageRebuild)) !== false)
- $aTmplVarsActions = $this->_getTmplVarsBlockPanelTopActions();
- return array(
- 'js_object' => $this->getPageJsObject(),
- 'selector' => $oForm->genRow($aInputPages),
- 'action_page_create' => $this->sActionPageCreate,
- 'bx_if:show_actions' => array(
- 'condition' => $this->sPage != '',
- 'content' => $aTmplVarsActions
- )
- );
- }
- protected function _getTmplVarsBlockPanelTopActions()
- {
- $sJsObject = $this->getPageJsObject();
- $oPermalinks = BxDolPermalinks::getInstance();
- return [
- 'js_object' => $sJsObject,
- 'bx_if:can_view' => [
- 'condition' => !empty($this->aPageRebuild['url']),
- 'content' => [
- 'url_view' => bx_absolute_url($oPermalinks->permalink($this->aPageRebuild['url'])),
- ]
- ],
- 'action_page_edit' => $this->sActionPageEdit,
- 'bx_if:can_delete' => [
- 'condition' => (int)$this->aPageRebuild['deletable'] == 1,
- 'content' => [
- 'js_object' => $sJsObject
- ]
- ],
- 'action_block_create' => $this->sActionBlockCreate,
- ];
- }
- protected function _getTmplVarsPageSettings($aPage = array(), $bCreate = true)
- {
- $sJsObject = $this->getPageJsObject();
- $aTmplParams = array(
- 'js_object' => $sJsObject,
- 'menu' => array(),
- 'html_settings_groups_id' => $this->aHtmlIds['settings_groups_id'],
- 'bx_repeat:settings_groups' => array(),
- 'submit' => _t($bCreate ? '_adm_bp_btn_page_create' : '_adm_bp_btn_page_apply')
- );
- foreach($this->aPageSettings 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'])}($aPage, $bCreate)
- );
- }
- $oMenu = new BxTemplStudioMenu(array('template' => 'menu_side.html', 'menu_items' => $aTmplParams['menu']));
- $aTmplParams['menu'] = $oMenu->getCode();
- return $aTmplParams;
- }
- protected function getIndexingDataForBlock($sType, $sContent)
- {
- $aBlock = array();
- switch($sType) {
- case BX_DOL_STUDIO_BP_BLOCK_HTML:
- case BX_DOL_STUDIO_BP_BLOCK_RAW:
- $aBlock['text'] = trim(strip_tags($sContent));
- $aBlock['text_updated'] = time();
- break;
- }
- return $aBlock;
- }
- }
- /** @} */
|