| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
- * CC-BY License - http://creativecommons.org/licenses/by/3.0/
- *
- * @defgroup TridentView Trident Studio Representation classes
- * @ingroup TridentStudio
- * @{
- */
- class BxBaseStudioDesigner extends BxDolStudioDesigner
- {
- protected $sLogoFormId = 'adm-dsg-logo-form';
- protected $sLogoIframeId = 'adm-dsg-logo-iframe';
- protected $sIconFormId = 'adm-dsg-icon-form';
- protected $sIconIframeId = 'adm-dsg-icon-iframe';
- protected $sCoverFormId = 'adm-dsg-cover-form';
- protected $sCoverIframeId = 'adm-dsg-cover-iframe';
- protected $sSplashFormId = 'adm-dsg-splash-form';
- protected $sSplashIframeId = 'adm-dsg-splash-iframe';
- protected $sSplashEditorId = 'adm-dsg-splash-editor';
- protected $sInjectionsFormId = 'adm-dsg-injections-form';
- protected $sInjectionsIframeId = 'adm-dsg-injections-iframe';
- protected $sInjectionsEditorId = 'adm-dsg-injections-editor';
- protected $aPageCss;
- protected $aPageJs;
- function __construct($sPage = '')
- {
- parent::__construct($sPage);
- $this->aPageCss = array('forms.css', 'designer.css');
- $this->aPageJs = array('settings.js', 'designer.js');
- }
- function getPageCss()
- {
- return array_merge(parent::getPageCss(), $this->aPageCss);
- }
- function getPageJs()
- {
- return array_merge(parent::getPageJs(), $this->aPageJs);
- }
- function getPageJsObject()
- {
- return 'oBxDolStudioDesigner';
- }
- function getPageJsClass()
- {
- return 'BxDolStudioDesigner';
- }
- public function getPageJsCode($aOptions = array(), $bWrap = true)
- {
- $aOptions = array_merge(array(
- 'sActionUrl' => $this->sManageUrl
- ), $aOptions);
- return parent::getPageJsCode($aOptions, $bWrap);
- }
- function getPageMenu($aMenu = array(), $aMarkers = array())
- {
- $sJsObject = $this->getPageJsObject();
- $aMenu = array();
- $aMenuItems = array(
- BX_DOL_STUDIO_DSG_TYPE_GENERAL => array('icon' => 'globe'),
- BX_DOL_STUDIO_DSG_TYPE_LOGO => array('icon' => 'pencil'),
- BX_DOL_STUDIO_DSG_TYPE_ICON => array('icon' => 'picture-o'),
- BX_DOL_STUDIO_DSG_TYPE_COVER => array('icon' => 'file-image-o'),
- BX_DOL_STUDIO_DSG_TYPE_SPLASH => array('icon' => 'file-image-o'),
- BX_DOL_STUDIO_DSG_TYPE_INJECTIONS => array('icon' => 'object-group'),
- BX_DOL_STUDIO_DSG_TYPE_SETTINGS => array('icon' => 'cogs'),
- );
- foreach($aMenuItems as $sMenuItem => $aItem)
- $aMenu[] = array(
- 'name' => $sMenuItem,
- 'icon' => $aItem['icon'],
- 'link' => BX_DOL_URL_STUDIO . 'designer.php?page=' . $sMenuItem,
- 'title' => _t('_adm_lmi_cpt_' . $sMenuItem),
- 'selected' => $sMenuItem == $this->sPage
- );
- return parent::getPageMenu($aMenu);
- }
- function getPageCode($bHidden = false)
- {
- $sMethod = 'get' . ucfirst($this->sPage);
- if(!method_exists($this, $sMethod))
- return '';
- return $this->$sMethod();
- }
- protected function getGeneral()
- {
- $sJsObject = $this->getPageJsObject();
- $oTemplate = BxDolStudioTemplate::getInstance();
- $sResult = '';
- $sTemplate = getParam('template');
- $aTemplates = get_templates_array(true, false);
- $aTmplVarsTemplates = array ();
- foreach($aTemplates as $sUri => $aTemplate) {
- $sIcon = $this->getModuleIcon($aTemplate, 'store');
- $bIcon = strpos($sIcon, '.') === false;
- $aTmplVarsTemplates[] = array(
- 'uri' => $sUri,
- 'title' => htmlspecialchars_adv($aTemplate['title']),
- 'version' => htmlspecialchars_adv($aTemplate['version']),
- 'vendor' => htmlspecialchars_adv($aTemplate['vendor']),
- 'bx_if:icon' => array (
- 'condition' => $bIcon,
- 'content' => array('icon' => $sIcon),
- ),
- 'bx_if:image' => array (
- 'condition' => !$bIcon,
- 'content' => array('icon_url' => $sIcon),
- ),
- 'bx_if:default' => array (
- 'condition' => $sUri == $sTemplate,
- 'content' => array (),
- ),
- 'bx_if:make_default' => array (
- 'condition' => $sUri != $sTemplate,
- 'content' => array(
- 'js_object' => $sJsObject,
- 'uri' => $sUri
- ),
- )
- );
- }
- $sContent = $sResult ? MsgBox($sResult, 10) : '';
- $sContent .= $oTemplate->parseHtmlByName('templates.html', array(
- 'bx_repeat:templates' => $aTmplVarsTemplates,
- ));
- return $oTemplate->parseHtmlByName('designer.html', array(
- 'content' => $sContent,
- 'js_content' => $this->getPageJsCode()
- ));
- }
- protected function getLogo()
- {
- $oTemplate = BxDolStudioTemplate::getInstance();
- $aForm = array(
- 'form_attrs' => array(
- 'id' => $this->sLogoFormId,
- 'name' => $this->sLogoFormId,
- 'action' => $this->sManageUrl,
- 'method' => 'post',
- 'enctype' => 'multipart/form-data',
- 'target' => $this->sLogoIframeId
- ),
- 'params' => array(
- 'db' => array(
- 'table' => '',
- 'key' => '',
- 'uri' => '',
- 'uri_title' => '',
- 'submit_name' => 'save'
- ),
- ),
- 'inputs' => array(
- 'page' => array(
- 'type' => 'hidden',
- 'name' => 'page',
- 'value' => $this->sPage
- ),
- 'image' => array(
- 'type' => 'image_uploader',
- 'name' => 'image',
- 'caption' => _t('_adm_dsg_txt_upload_image'),
- 'caption_preview' => _t('_adm_dsg_txt_upload_image_preview'),
- 'ajax_action_delete' => $this->getPageJsObject() . '.deleteLogo()',
- 'storage_object' => 'sys_images_custom',
- 'transcoder_object' => 'sys_custom_images',
- 'transcoder_image_width' => (int)getParam($this->sParamLogoWidth),
- 'transcoder_image_height' => (int)getParam($this->sParamLogoHeight),
- 'value' => (int)getParam($this->sParamLogo),
- ),
- 'width' => array(
- 'type' => 'text',
- 'name' => 'width',
- 'caption' => _t('_adm_stg_cpt_option_sys_site_logo_width'),
- 'value' => (int)getParam($this->sParamLogoWidth),
- 'db' => array (
- 'pass' => 'Int',
- ),
- ),
- 'height' => array(
- 'type' => 'text',
- 'name' => 'height',
- 'caption' => _t('_adm_stg_cpt_option_sys_site_logo_height'),
- 'value' => (int)getParam($this->sParamLogoHeight),
- 'db' => array (
- 'pass' => 'Int',
- ),
- ),
- 'alt' => array(
- 'type' => 'text',
- 'name' => 'alt',
- 'caption' => _t('_adm_dsg_txt_alt_text'),
- 'info' => _t('_adm_dsg_dsc_alt_text'),
- 'value' => getParam($this->sParamLogoAlt),
- 'checker' => array(
- 'func' => '',
- 'params' => array(),
- 'error' => ''
- ),
- 'db' => array (
- 'pass' => 'Xss',
- ),
- ),
- 'save' => array(
- 'type' => 'submit',
- 'name' => 'save',
- 'value' => _t('_adm_btn_designer_submit'),
- )
- )
- );
- $oForm = new BxTemplStudioFormView($aForm);
- $oForm->initChecker();
- if($oForm->isSubmittedAndValid()) {
- echo $this->submitLogo($oForm);
- exit;
- }
- return $oTemplate->parseHtmlByName('designer.html', array(
- 'content' => $this->getBlockCode(array(
- 'items' => $oTemplate->parseHtmlByName('dsr_logo.html', array('logo_iframe_id' => $this->sLogoIframeId, 'form' => $oForm->getCode())),
- )),
- 'js_content' => $this->getPageJsCode()
- ));
- }
- protected function getIcon()
- {
- $oTemplate = BxDolStudioTemplate::getInstance();
- $sPreview = "";
- $aTmplVars = array('bx_repeat:images' => array());
- if(($iId = (int)getParam('sys_site_icon')) != 0) {
- $aTranscoders = array(
- BX_DOL_TRANSCODER_OBJ_ICON_APPLE => '_adm_dsg_txt_icon_apple',
- BX_DOL_TRANSCODER_OBJ_ICON_FACEBOOK => '_adm_dsg_txt_icon_facebook',
- BX_DOL_TRANSCODER_OBJ_ICON_FAVICON => '_adm_dsg_txt_icon_favicon'
- );
- foreach($aTranscoders as $sTranscoder => $sTitle) {
- $oTranscoder = BxDolTranscoderImage::getObjectInstance($sTranscoder);
- $sImageUrl = $oTranscoder->getFileUrl($iId);
- if($sImageUrl === false) {
- setParam('sys_site_icon', 0);
- break;
- }
- $aFilterParams = $oTranscoder->getFilterParams('Resize');
- $bFilterWidth = !empty($aFilterParams['w']);
- $bFilterHeight = !empty($aFilterParams['h']);
- $aTmplVars['bx_repeat:images'][] = array(
- 'caption' => _t($sTitle),
- 'url' => $sImageUrl,
- 'bx_if:show_width' => array(
- 'condition' => $bFilterWidth,
- 'content' => array(
- 'width' => $bFilterWidth ? (int)$aFilterParams['w'] : 0
- )
- ),
- 'bx_if:show_height' => array(
- 'condition' => $bFilterHeight,
- 'content' => array(
- 'height' => $bFilterHeight ? (int)$aFilterParams['h'] : 0
- )
- ),
- );
- }
- $sPreview = $oTemplate->parseHtmlByName('dsr_icon_preview.html', $aTmplVars);
- }
- $aForm = array(
- 'form_attrs' => array(
- 'id' => $this->sIconFormId,
- 'name' => $this->sIconFormId,
- 'action' => BX_DOL_URL_STUDIO . 'designer.php',
- 'method' => 'post',
- 'enctype' => 'multipart/form-data',
- 'target' => $this->sIconIframeId
- ),
- 'params' => array(
- 'db' => array(
- 'table' => '',
- 'key' => '',
- 'uri' => '',
- 'uri_title' => '',
- 'submit_name' => 'save'
- ),
- ),
- 'inputs' => array(
- 'page' => array(
- 'type' => 'hidden',
- 'name' => 'page',
- 'value' => $this->sPage
- ),
- 'preview' => array(
- 'type' => 'custom',
- 'name' => 'preview',
- 'content' => $sPreview
- ),
- 'image' => array(
- 'type' => 'file',
- 'name' => 'image',
- 'caption' => _t('_adm_dsg_txt_upload_icon')
- ),
- 'save' => array(
- 'type' => 'submit',
- 'name' => 'save',
- 'value' => _t('_adm_btn_designer_submit'),
- )
- )
- );
- $oForm = new BxTemplStudioFormView($aForm);
- $oForm->initChecker();
- if($oForm->isSubmittedAndValid()) {
- echo $this->submitIcon($oForm);
- exit;
- }
- return $oTemplate->parseHtmlByName('designer.html', array(
- 'content' => $this->getBlockCode(array(
- 'items' => $oTemplate->parseHtmlByName('dsr_icon.html', array('icon_iframe_id' => $this->sIconIframeId, 'form' => $oForm->getCode())),
- )),
- 'js_content' => $this->getPageJsCode()
- ));
- }
- protected function getCover()
- {
- $sJsObject = $this->getPageJsObject();
- $oTemplate = BxDolStudioTemplate::getInstance();
- $aFormInputs = array();
- $aTmplVarsCovers = array();
- foreach($this->aCovers as $sCover => $aCover) {
- $aFormInputs[$sCover] = array(
- 'type' => 'file',
- 'name' => $sCover,
- 'caption' => _t('_adm_dsg_txt_upload_' . $sCover)
- );
- if(($iImageId = (int)getParam($aCover['setting'])) == 0)
- continue;
- $sImageUrl = BxDolTranscoderImage::getObjectInstance(BX_DOL_TRANSCODER_OBJ_COVER)->getFileUrl($iImageId);
- if($sImageUrl === false) {
- setParam($aCover['setting'], 0);
- continue;
- }
- $aTmplVarsCovers[] = array(
- 'js_object' => $sJsObject,
- 'type' => $sCover,
- 'caption' => _t($aCover['title']),
- 'image_id' => $iImageId,
- 'bx_if:show_bg' => array(
- 'condition' => !empty($sImageUrl),
- 'content' => array(
- 'image_url' => $sImageUrl
- )
- ),
- );
- }
- $aForm = array(
- 'form_attrs' => array(
- 'id' => $this->sCoverFormId,
- 'name' => $this->sCoverFormId,
- 'action' => BX_DOL_URL_STUDIO . 'designer.php',
- 'method' => 'post',
- 'enctype' => 'multipart/form-data',
- 'target' => $this->sCoverIframeId
- ),
- 'params' => array(
- 'db' => array(
- 'table' => '',
- 'key' => '',
- 'uri' => '',
- 'uri_title' => '',
- 'submit_name' => 'save'
- ),
- ),
- 'inputs' => array(
- 'page' => array(
- 'type' => 'hidden',
- 'name' => 'page',
- 'value' => $this->sPage
- ),
- 'preview' => array(
- 'type' => 'custom',
- 'name' => 'preview',
- 'content' => $oTemplate->parseHtmlByName('dsr_cover_preview.html', array(
- 'bx_repeat:covers' => $aTmplVarsCovers
- ))
- ),
- 'save' => array(
- 'type' => 'submit',
- 'name' => 'save',
- 'value' => _t('_adm_btn_designer_submit'),
- )
- )
- );
- $aForm['inputs'] = bx_array_insert_after($aFormInputs, $aForm['inputs'], 'preview');
- $oForm = new BxTemplStudioFormView($aForm);
- $oForm->initChecker();
- if($oForm->isSubmittedAndValid()) {
- echo $this->submitCover($oForm);
- exit;
- }
- $this->aPageCss[] = 'cover.css';
- return $oTemplate->parseHtmlByName('designer.html', array(
- 'content' => $this->getBlockCode(array(
- 'items' => $oTemplate->parseHtmlByName('dsr_cover.html', array('iframe_id' => $this->sCoverIframeId, 'form' => $oForm->getCode())),
- )),
- 'js_content' => $this->getPageJsCode()
- ));
- }
- protected function getSplash()
- {
- $oTemplate = BxDolStudioTemplate::getInstance();
- $aForm = array(
- 'form_attrs' => array(
- 'id' => $this->sSplashFormId,
- 'name' => $this->sSplashFormId,
- 'action' => BX_DOL_URL_STUDIO . 'designer.php',
- 'method' => 'post',
- 'enctype' => 'multipart/form-data',
- 'target' => $this->sSplashIframeId
- ),
- 'params' => array(
- 'db' => array(
- 'table' => '',
- 'key' => '',
- 'uri' => '',
- 'uri_title' => '',
- 'submit_name' => 'save'
- ),
- ),
- 'inputs' => array(
- 'page' => array(
- 'type' => 'hidden',
- 'name' => 'page',
- 'value' => $this->sPage
- ),
- 'enabled' => array(
- 'type' => 'checkbox',
- 'name' => 'enabled',
- 'caption' => _t('_adm_dsg_txt_splash_enabled'),
- 'value' => 'on',
- 'checked' => getParam('sys_site_splash_enabled') == 'on',
- 'db' => array (
- 'pass' => 'Xss',
- ),
- ),
- 'code' => array(
- 'type' => 'textarea',
- 'code' => true,
- 'name' => 'code',
- 'caption' => '',
- 'value' => getParam('sys_site_splash_code'),
- ),
- 'save' => array(
- 'type' => 'submit',
- 'name' => 'save',
- 'value' => _t('_adm_btn_designer_submit'),
- )
- )
- );
- $oForm = new BxTemplStudioFormView($aForm, $oTemplate);
- $oForm->initChecker();
- if($oForm->isSubmittedAndValid()) {
- echo $this->submitSplash($oForm);
- exit;
- }
- $oTemplate->addJs(array('codemirror/codemirror.min.js'));
- $oTemplate->addCss(BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'codemirror/|codemirror.css');
- return $oTemplate->parseHtmlByName('designer.html', array(
- 'content' => $this->getBlockCode(array(
- 'items' => $oTemplate->parseHtmlByName('dsr_splash.html', array(
- 'warning' => MsgBox(_t('_adm_dsg_dsc_splash_warning')),
- 'splash_iframe_id' => $this->sSplashIframeId,
- 'form' => $oForm->getCode()
- )),
- )),
- 'js_content' => $this->getPageJsCode(array(
- 'sCodeMirror' => 'textarea[name=code]'
- ))
- ));
- }
- protected function getInjections()
- {
- $oTemplate = BxDolStudioTemplate::getInstance();
- $aForm = array(
- 'form_attrs' => array(
- 'id' => $this->sInjectionsFormId,
- 'name' => $this->sInjectionsFormId,
- 'action' => BX_DOL_URL_STUDIO . 'designer.php',
- 'method' => 'post',
- 'enctype' => 'multipart/form-data',
- 'target' => $this->sInjectionsIframeId
- ),
- 'params' => array(
- 'db' => array(
- 'table' => '',
- 'key' => '',
- 'uri' => '',
- 'uri_title' => '',
- 'submit_name' => 'save'
- ),
- ),
- 'inputs' => array(
- 'page' => array(
- 'type' => 'hidden',
- 'name' => 'page',
- 'value' => $this->sPage
- ),
- 'code' => array(
- 'type' => 'textarea',
- 'code' => true,
- 'name' => 'code',
- 'caption' => '',
- 'value' => BxDolTemplate::getInstance()->getHtml('_header.html', BX_DOL_TEMPLATE_CHECK_IN_BASE),
- ),
- 'save' => array(
- 'type' => 'submit',
- 'name' => 'save',
- 'value' => _t('_adm_btn_designer_submit'),
- )
- )
- );
- $oForm = new BxTemplStudioFormView($aForm, $oTemplate);
- $oForm->initChecker();
- if($oForm->isSubmittedAndValid()) {
- echo $this->submitInjections($oForm);
- exit;
- }
- $oTemplate->addJs(array('codemirror/codemirror.min.js'));
- $oTemplate->addCss(BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'codemirror/|codemirror.css');
- return $oTemplate->parseHtmlByName('designer.html', array(
- 'content' => $this->getBlockCode(array(
- 'items' => $oTemplate->parseHtmlByName('dsr_injections.html', array(
- 'warning' => MsgBox(_t('_adm_dsg_dsc_splash_warning')),
- 'splash_iframe_id' => $this->sInjectionsIframeId,
- 'form' => $oForm->getCode()
- )),
- )),
- 'js_content' => $this->getPageJsCode(array(
- 'sCodeMirror' => 'textarea[name=code]'
- ))
- ));
- }
- protected function getSettings()
- {
- $oPage = new BxTemplStudioSettings(BX_DOL_STUDIO_STG_TYPE_SYSTEM, BX_DOL_STUDIO_STG_CATEGORY_TEMPLATES);
- return BxDolStudioTemplate::getInstance()->parseHtmlByName('designer.html', array(
- 'content' => $oPage->getPageCode(),
- 'js_content' => $this->getPageJsCode()
- ));
- }
- }
- /** @} */
|