/** * Constructor. */ public function __construct() { parent::__construct(); BackendMenu::setContext('October.Cms', 'cms', true); try { if (!($theme = Theme::getEditTheme())) { throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found')); } $this->theme = $theme; new TemplateList($this, 'pageList', function () use($theme) { return Page::listInTheme($theme, true); }); new TemplateList($this, 'partialList', function () use($theme) { return Partial::listInTheme($theme, true); }); new TemplateList($this, 'layoutList', function () use($theme) { return Layout::listInTheme($theme, true); }); new TemplateList($this, 'contentList', function () use($theme) { return Content::listInTheme($theme, true); }); new ComponentList($this, 'componentList'); new AssetList($this, 'assetList'); } catch (Exception $ex) { $this->handleError($ex); } }
public function partials() { if (!$this->partials) { $theme = Theme::getEditTheme(); $partials = Prtl::listInTheme($theme, true); $options = []; foreach ($partials as $partial) { $options[$partial->baseFileName] = $partial->baseFileName; } asort($options); $this->partials = $options; } return $this->partials; }
/** * Constructor. */ public function __construct() { parent::__construct(); BackendMenu::setContext('October.Cms', 'cms', 'pages'); try { if (!($theme = Theme::getEditTheme())) { throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found')); } $this->theme = $theme; new TemplateList($this, 'pageList', function () use($theme) { return Page::listInTheme($theme, true); }); new TemplateList($this, 'partialList', function () use($theme) { return Partial::listInTheme($theme, true); }); new TemplateList($this, 'layoutList', function () use($theme) { return Layout::listInTheme($theme, true); }); new TemplateList($this, 'contentList', function () use($theme) { return Content::listInTheme($theme, true); }); new ComponentList($this, 'componentList'); new AssetList($this, 'assetList'); } catch (Exception $ex) { $this->handleError($ex); } $this->addJs('/modules/cms/assets/js/october.cmspage.js', 'core'); $this->addJs('/modules/cms/assets/js/october.dragcomponents.js', 'core'); $this->addCss('/modules/cms/assets/css/october.components.css', 'core'); // Preload Ace editor modes explicitly, because they could be changed dynamically // depending on a content block type $this->addJs('/modules/backend/formwidgets/codeeditor/assets/vendor/ace/ace.js', 'core'); $aceModes = ['markdown', 'plain_text', 'html', 'less', 'css', 'scss', 'sass', 'javascript']; foreach ($aceModes as $mode) { $this->addJs('/modules/backend/formwidgets/codeeditor/assets/vendor/ace/mode-' . $mode . '.js', 'core'); } $this->bodyClass = 'compact-container side-panel-not-fixed'; $this->pageTitle = Lang::get('cms::lang.cms.menu_label'); }
/** * Returns a list of snippets in the specified theme. * @param \Cms\Classes\Theme $theme Specifies a parent theme. * @return array Returns an array of Snippet objects. */ protected function listThemeSnippets($theme) { $result = []; $partials = Partial::listInTheme($theme, true); foreach ($partials as $partial) { $viewBag = $partial->getViewBag(); if (strlen($viewBag->property('snippetCode'))) { $snippet = new Snippet(); $snippet->initFromPartial($partial); $result[] = $snippet; } } return $result; }