public function testLists()
 {
     // Default theme: test
     $pages = Page::lists('baseFileName');
     sort($pages);
     $this->assertEquals(["404", "a/a-page", "ajax-test", "authors", "b/b-page", "blog-archive", "blog-post", "code-namespaces", "component-custom-render", "component-partial", "component-partial-nesting", "component-partial-override", "cycle-test", "index", "no-component", "no-component-class", "no-layout", "no-partial", "optional-full-php-tags", "optional-short-php-tags", "throw-php", "with-component", "with-components", "with-content", "with-layout", "with-partials", "with-placeholder"], $pages);
     $layouts = Layout::lists('baseFileName');
     sort($layouts);
     $this->assertEquals(["a/a-layout", "ajax-test", "content", "cycle-test", "no-php", "partials", "php-parser-test", "placeholder", "sidebar"], $layouts);
     $pages = Page::inTheme('NON_EXISTENT_THEME')->lists('baseFileName');
     $this->assertEmpty($pages);
 }
Example #2
0
 /**
  * Creates a CMS page from a static page and configures it.
  * @param string $url Specifies the static page URL.
  * @return \Cms\Classes\Page Returns the CMS page object or NULL of the requested page was not found.
  */
 public function initCmsPage($url)
 {
     $router = new Router($this->theme);
     $page = $router->findByUrl($url);
     if (!$page) {
         return null;
     }
     $viewBag = $page->viewBag;
     $cmsPage = CmsPage::inTheme($this->theme);
     $cmsPage->url = $url;
     $cmsPage->apiBag['staticPage'] = $page;
     /*
      * Transfer specific values from the content view bag to the page settings object.
      */
     $viewBagToSettings = ['title', 'layout', 'meta_title', 'meta_description', 'is_hidden'];
     foreach ($viewBagToSettings as $property) {
         $cmsPage->settings[$property] = array_get($viewBag, $property);
     }
     return $cmsPage;
 }
Example #3
0
 public function onGetTemplateList()
 {
     $this->validateRequestTheme();
     $page = Page::inTheme($this->theme);
     return ['layouts' => $page->getLayoutOptions()];
 }
 public function testListsNonExistentTheme()
 {
     $pages = Page::inTheme('NON_EXISTENT_THEME')->lists('baseFileName');
     $this->assertEmpty($pages);
 }