Exemple #1
0
 /**
  * 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);
     }
 }
Exemple #2
0
 /**
  * Returns a list of layouts available in the theme. 
  * This method is used by the form widget.
  * @return array Returns an array of strings.
  */
 public function getLayoutOptions()
 {
     if (!($theme = Theme::getEditTheme())) {
         throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found'));
     }
     $layouts = Layout::listInTheme($theme, true);
     $result = [];
     $result[null] = Lang::get('cms::lang.page.no_layout');
     foreach ($layouts as $layout) {
         $baseName = $layout->getBaseFileName();
         $result[$baseName] = strlen($layout->name) ? $layout->name : $baseName;
     }
     return $result;
 }
Exemple #3
0
 /**
  * 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');
 }
Exemple #4
0
 /**
  * Returns a list of layouts available in the theme. 
  * This method is used by the form widget.
  * @return array Returns an array of strings.
  */
 public function getLayoutOptions()
 {
     $result = [];
     $layouts = Layout::listInTheme($this->theme, true);
     foreach ($layouts as $layout) {
         if (!$layout->hasComponent('staticPage')) {
             continue;
         }
         $baseName = $layout->getBaseFileName();
         $result[$baseName] = strlen($layout->name) ? $layout->name : $baseName;
     }
     if (!$result) {
         $result[null] = Lang::get('rainlab.pages::lang.page.layouts_not_found');
     }
     return $result;
 }