Example #1
0
 /**
  * Handler for the pages.menuitem.getTypeInfo event.
  * Returns a menu item type information. The type information is returned as array
  * with the following elements:
  * - references - a list of the item type reference options. The options are returned in the
  *   ["key"] => "title" format for options that don't have sub-options, and in the format
  *   ["key"] => ["title"=>"Option title", "items"=>[...]] for options that have sub-options. Optional,
  *   required only if the menu item type requires references.
  * - nesting - Boolean value indicating whether the item type supports nested items. Optional,
  *   false if omitted.
  * - dynamicItems - Boolean value indicating whether the item type could generate new menu items.
  *   Optional, false if omitted.
  * - cmsPages - a list of CMS pages (objects of the Cms\Classes\Page class), if the item type requires a CMS page reference to 
  *   resolve the item URL.
  * @param string $type Specifies the menu item type
  * @return array Returns an array
  */
 public static function getMenuTypeInfo($type)
 {
     $result = [];
     if ($type == 'blog-category') {
         $references = [];
         $categories = self::orderBy('name')->get();
         foreach ($categories as $category) {
             $references[$category->id] = $category->name;
         }
         $result = ['references' => $references, 'nesting' => false, 'dynamicItems' => false];
     }
     if ($type == 'all-blog-categories') {
         $result = ['dynamicItems' => true];
     }
     if ($result) {
         $theme = Theme::getActiveTheme();
         $pages = CmsPage::listInTheme($theme, true);
         $cmsPages = [];
         foreach ($pages as $page) {
             if (!$page->hasComponent('blogPosts')) {
                 continue;
             }
             $properties = $page->getComponentProperties('blogPosts');
             if (!isset($properties['categoryFilter']) || substr($properties['categoryFilter'], 0, 1) !== ':') {
                 continue;
             }
             $cmsPages[] = $page;
         }
         $result['cmsPages'] = $cmsPages;
     }
     return $result;
 }
Example #2
0
 /**
  * Handler for the pages.menuitem.getTypeInfo event.
  * Returns a menu item type information. The type information is returned as array
  * with the following elements:
  * - references - a list of the item type reference options. The options are returned in the
  *   ["key"] => "title" format for options that don't have sub-options, and in the format
  *   ["key"] => ["title"=>"Option title", "items"=>[...]] for options that have sub-options. Optional,
  *   required only if the menu item type requires references.
  * - nesting - Boolean value indicating whether the item type supports nested items. Optional,
  *   false if omitted.
  * - dynamicItems - Boolean value indicating whether the item type could generate new menu items.
  *   Optional, false if omitted.
  * - cmsPages - a list of CMS pages (objects of the Cms\Classes\Page class), if the item type requires a CMS page reference to 
  *   resolve the item URL.
  * @param string $type Specifies the menu item type
  * @return array Returns an array
  */
 public static function getMenuTypeInfo($type)
 {
     $result = [];
     if ($type == 'blog-category') {
         $result = ['references' => self::listSubCategoryOptions(), 'nesting' => true, 'dynamicItems' => true];
     }
     if ($type == 'all-blog-categories') {
         $result = ['dynamicItems' => true];
     }
     if ($result) {
         $theme = Theme::getActiveTheme();
         $pages = CmsPage::listInTheme($theme, true);
         $cmsPages = [];
         foreach ($pages as $page) {
             if (!$page->hasComponent('blogPosts')) {
                 continue;
             }
             /*
              * Component must use a category filter with a routing parameter
              * eg: categoryFilter = "{{ :somevalue }}"
              */
             $properties = $page->getComponentProperties('blogPosts');
             if (!isset($properties['categoryFilter']) || !preg_match('/{{\\s*:/', $properties['categoryFilter'])) {
                 continue;
             }
             $cmsPages[] = $page;
         }
         $result['cmsPages'] = $cmsPages;
     }
     return $result;
 }
 public function getCmsPageOptions()
 {
     if (!($theme = Theme::getEditTheme())) {
         throw new ApplicationException('Unable to find the active theme.');
     }
     return Page::listInTheme($theme)->lists('fileName', 'fileName');
 }
Example #4
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);
     }
 }
Example #5
0
 /**
  *
  * Returns an array of info about menu item type
  *
  * @param string $type item name
  * @return array
  */
 public static function getMenuTypeInfo($type)
 {
     $result = [];
     if ($type != 'all-archive-years') {
         return $result;
     }
     $result['dynamicItems'] = true;
     $theme = Theme::getActiveTheme();
     $result['cmsPages'] = CmsPage::listInTheme($theme, true);
     return $result;
 }
Example #6
0
 public function getPagesDropDown()
 {
     if (!$this->pages) {
         $theme = Theme::getEditTheme();
         $pages = Page::listInTheme($theme, true);
         $this->pages = [];
         foreach ($pages as $page) {
             $this->pages[$page->baseFileName] = $page->title . ' (' . $page->url . ')';
         }
     }
     return $this->pages;
 }
Example #7
0
 public function pages()
 {
     if (!$this->pages) {
         $theme = Theme::getEditTheme();
         $pages = Pg::listInTheme($theme, true);
         $options = [];
         foreach ($pages as $page) {
             $options[$page->baseFileName] = $page->title . ' (' . $page->url . ')';
         }
         asort($options);
         $this->pages = $options;
     }
     return $this->pages;
 }
Example #8
0
 public function onRun()
 {
     if (!($theme = Theme::getEditTheme())) {
         throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found'));
     }
     $currentPage = $this->page->baseFileName;
     $pages = Page::listInTheme($theme, true);
     $this->pagesList = $this->buildPagesList($pages);
     $breadcrumbList = $this->buildCrumbTrail($currentPage);
     $currentCrumb = array_slice($breadcrumbList, -1, 1, true);
     $currentCrumb = array_shift($currentCrumb);
     $this->page['breadcrumbs'] = $breadcrumbList;
     $this->page['currentCrumb'] = $currentCrumb;
     return;
 }
Example #9
0
 private static function listPages()
 {
     if (!($theme = Theme::getEditTheme())) {
         throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found'));
     }
     $pages = Page::listInTheme($theme, true);
     $result = [];
     foreach ($pages as $page) {
         if ($page->show_menu == "1") {
             $result[$page->menu_order] = ['text' => $page->menu_text, 'path' => $page->getBaseFileName(), 'order' => $page->menu_order];
         }
     }
     ksort($result);
     return $result;
 }
Example #10
0
 public function getPageUrlOptions()
 {
     $currentTheme = Theme::getEditTheme();
     $allThemePages = Page::listInTheme($currentTheme, true);
     $options = [];
     foreach ($allThemePages as $p) {
         $options['url=' . $p->url . '&type=cms_pages'] = $p->title;
     }
     $tree = StaticPageClass::buildMenuTree($currentTheme);
     foreach ($tree as $key => $page) {
         if (isset($page['title']) && isset($page['url'])) {
             $options['url=' . $page['url'] . '&type=pages_plugin'] = $page['title'];
         }
     }
     return $options;
 }
Example #11
0
 private static function listPages()
 {
     if (!($theme = Theme::getEditTheme())) {
         throw new ApplicationException(Lang::get('cms::lang.theme.edit.not_found'));
     }
     $pages = Page::listInTheme($theme, true);
     $result = [];
     foreach ($pages as $page) {
         $page->fill(['menu_text']);
         $page->fill(['menu_order']);
         if ($page->not_show_menu != "1" && !empty($page->menu_order)) {
             $result[$page->menu_order] = ['text' => $page->menu_text != '' ? $page->menu_text : $page->title, 'path' => $page->getBaseFileName(), 'order' => $page->menu_order != '' ? $page->menu_order : 1];
         }
     }
     ksort($result);
     return $result;
 }
Example #12
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');
 }
 /**
  * @param null|callable $map
  * The unique param it receives id an array with page informations
  *
  * @throws \ApplicationException
  * @throws \SystemException
  */
 public function map($map = null)
 {
     $theme = \Cms\Classes\Theme::getActiveTheme();
     $pages = \Cms\Classes\Page::listInTheme($theme, true);
     if (class_exists('\\RainLab\\Pages\\Classes\\Controller')) {
         // hack RainlabPage's Controller to avoid class name collision
         $classPath = \App::pluginsPath() . '/rainlab/pages/classes/Controller.php';
         file_put_contents($classPath, str_replace('use Cms\\Classes\\Page;', 'use Cms\\Classes\\Page as BasePage;', file_get_contents($classPath)));
         file_put_contents($classPath, str_replace('new Page(', 'new BasePage(', file_get_contents($classPath)));
         // end of hack
         $pages = array_merge($pages, \RainLab\Pages\Classes\Page::listInTheme($theme, true));
     }
     foreach ($pages as $i => $page) {
         if (!isset($this->pageInfos[$page->url])) {
             $this->pageInfos[$page->url] = ['url' => $page->url, 'content' => function () use($page) {
                 return $this->getPageContents($page->url);
             }, 'pageType' => $this->getPageTypeByUrl($page->url), 'urlParameters' => $this->getDynamicParameters($page->url)];
         }
         if (is_callable($map)) {
             $map($this->pageInfos[$page->url]);
         }
     }
 }
 /**
  * Handler for the pages.menuitem.getTypeInfo event.
  * @param string $type Specifies the menu item type
  * @return array Returns an array
  */
 public static function getMenuTypeInfo($type)
 {
     $result = [];
     if ($type == 'repertoire') {
         // Сюда все возможные ссылки (категории или scoupe)
         $references = [];
         $categories = self::getCategories();
         foreach ($categories as $category) {
             $references[$category->slug] = $category->title;
         }
         $result = ['references' => $references, 'nesting' => false, 'dynamicItems' => false];
     }
     if ($result) {
         $theme = Theme::getActiveTheme();
         $pages = CmsPage::listInTheme($theme, true);
         $cmsPages = [];
         foreach ($pages as $page) {
             if (!$page->hasComponent('theater')) {
                 continue;
             }
             $cmsPages[] = $page;
         }
         $result['cmsPages'] = $cmsPages;
     }
     return $result;
 }
Example #15
0
 /**
  * Returns a list of pages in the theme.
  * This method is used internally in the routing process and in the back-end UI.
  * @param boolean $skipCache Indicates if the pages should be reloaded from the disk bypassing the cache.
  * @return array Returns an array of \Cms\Classes\Page objects.
  */
 public function listPages($skipCache = false)
 {
     return Page::listInTheme($this, $skipCache);
 }
 private static function getCategoryRenderPages()
 {
     $result = [];
     $theme = Theme::getActiveTheme();
     $pages = CmsPage::listInTheme($theme, true);
     $cmsPages = [];
     foreach ($pages as $page) {
         if (!$page->hasComponent('proBlogList')) {
             continue;
         }
         $cmsPages[] = $page;
     }
     $cmsPages;
     return $cmsPages;
 }
 /**
  * Get all cms pages.
  *
  * @return Collection
  */
 protected function pages()
 {
     return Page::listInTheme(Theme::getActiveTheme(), true);
 }
Example #18
0
 /**
  * Handler for the pages.menuitem.getTypeInfo event.
  * Returns a menu item type information. The type information is returned as array
  * with the following elements:
  * - references - a list of the item type reference options. The options are returned in the
  *   ["key"] => "title" format for options that don't have sub-options, and in the format
  *   ["key"] => ["title"=>"Option title", "items"=>[...]] for options that have sub-options. Optional,
  *   required only if the menu item type requires references.
  * - nesting - Boolean value indicating whether the item type supports nested items. Optional,
  *   false if omitted.
  * - dynamicItems - Boolean value indicating whether the item type could generate new menu items.
  *   Optional, false if omitted.
  * - cmsPages - a list of CMS pages (objects of the Cms\Classes\Page class), if the item type requires a CMS page reference to
  *   resolve the item URL.
  * @param string $type Specifies the menu item type
  * @return array Returns an array
  */
 public static function getMenuTypeInfo($type)
 {
     $result = [];
     if ($type == 'blog-post') {
         $references = [];
         $posts = self::orderBy('title')->get();
         foreach ($posts as $post) {
             $references[$post->id] = $post->title;
         }
         $result = ['references' => $references, 'nesting' => false, 'dynamicItems' => false];
     }
     if ($type == 'all-blog-posts') {
         $result = ['dynamicItems' => true];
     }
     if ($result) {
         $theme = Theme::getActiveTheme();
         $pages = CmsPage::listInTheme($theme, true);
         $cmsPages = [];
         foreach ($pages as $page) {
             if (!$page->hasComponent('blogPost')) {
                 continue;
             }
             /*
              * Component must use a categoryPage filter with a routing parameter and post slug
              * eg: categoryPage = "{{ :somevalue }}", slug = "{{ :somevalue }}"
              */
             $properties = $page->getComponentProperties('blogPost');
             if (!isset($properties['categoryPage']) || !preg_match('/{{\\s*:/', $properties['slug'])) {
                 continue;
             }
             $cmsPages[] = $page;
         }
         $result['cmsPages'] = $cmsPages;
     }
     return $result;
 }
Example #19
0
 /**
  * Handler for the pages.menuitem.getTypeInfo event.
  * @param string $type Specifies the menu item type
  * @return array Returns an array
  */
 public static function getMenuTypeInfo($type)
 {
     $result = [];
     if ($type == 'playbill') {
         $result = ['dynamicItems' => true];
     }
     if ($result) {
         $theme = Theme::getActiveTheme();
         $pages = CmsPage::listInTheme($theme, true);
         $cmsPages = [];
         foreach ($pages as $page) {
             if (!$page->hasComponent('theaterEvents')) {
                 continue;
             }
             /*
              * Component must use a category filter with a routing parameter
              * eg: categoryFilter = "{{ :somevalue }}"
              */
             $properties = $page->getComponentProperties('theaterEvents');
             if (!isset($properties['date']) || !preg_match('/{{\\s*:/', $properties['date'])) {
                 continue;
             }
             $cmsPages[] = $page;
         }
         $result['cmsPages'] = $cmsPages;
     }
     return $result;
 }