当前位置: 首页>>代码示例>>PHP>>正文


PHP Page\Page类代码示例

本文整理汇总了PHP中Grav\Common\Page\Page的典型用法代码示例。如果您正苦于以下问题:PHP Page类的具体用法?PHP Page怎么用?PHP Page使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Page类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onPageInitialized

 /**
  * Initialize a maintenance page
  */
 public function onPageInitialized()
 {
     $user = $this->grav['user'];
     $user->authorise($this->maintenance['login_access']);
     if ($this->maintenance['active']) {
         if (!$user->authenticated) {
             /** @var $page */
             $page = null;
             /** @var Pages $pages */
             $pages = $this->grav['pages'];
             // Get the custom page route if specified
             $custom_page_route = $this->config->get('plugins.maintenance.maintenance_page_route');
             if ($custom_page_route) {
                 // Try to load user error page.
                 $page = $pages->dispatch($custom_page_route, true);
             }
             // If no page found yet, use the built-in one...
             if (!$page) {
                 $page = new Page();
                 $page->init(new \SplFileInfo(__DIR__ . "/pages/maintenance.md"));
             }
             // unset the old page, and use the new one
             unset($this->grav['page']);
             $this->grav['page'] = $page;
         }
     }
 }
开发者ID:fbardel,项目名称:grav-plugin-maintenance,代码行数:30,代码来源:maintenance.php

示例2: __construct

 /**
  * Create form for the given page.
  *
  * @param Page $page
  * @param null $name
  * @param null $form
  */
 public function __construct(Page $page, $name = null, $form = null)
 {
     parent::__construct();
     $this->page = $page->route();
     $header = $page->header();
     $this->rules = isset($header->rules) ? $header->rules : [];
     $this->header_data = isset($header->data) ? $header->data : [];
     if ($form) {
         $this->items = $form;
     } else {
         if (isset($header->form)) {
             $this->items = $header->form;
             // for backwards compatibility
         }
     }
     // Add form specific rules.
     if (!empty($this->items['rules']) && is_array($this->items['rules'])) {
         $this->rules += $this->items['rules'];
     }
     // Set form name if not set.
     if ($name && !is_int($name)) {
         $this->items['name'] = $name;
     } elseif (empty($this->items['name'])) {
         $this->items['name'] = $page->slug();
     }
     // Set form id if not set.
     if (empty($this->items['id'])) {
         $inflector = new Inflector();
         $this->items['id'] = $inflector->hyphenize($this->items['name']);
     }
     // Reset and initialize the form
     $this->reset();
 }
开发者ID:getgrav,项目名称:grav-plugin-form,代码行数:40,代码来源:form.php

示例3: onPagesInitialized

 /**
  * Replaces page object with admin one.
  */
 public function onPagesInitialized()
 {
     // Create admin page.
     $page = new Page();
     $page->init(new \SplFileInfo(__DIR__ . "/pages/gantry5.md"));
     $page->slug($this->template);
     $this->grav['page'] = $page;
 }
开发者ID:nmsde,项目名称:gantry5,代码行数:11,代码来源:gantry5.php

示例4: mergeConfig

 private function mergeConfig(Page $page)
 {
     $defaults = (array) $this->grav['config']->get('plugins.jscomments');
     if (isset($page->header()->jscomments)) {
         if (is_array($page->header()->jscomments)) {
             $this->grav['config']->set('plugins.jscomments', array_replace_recursive($defaults, $page->header()->jscomments));
         }
     }
 }
开发者ID:aradianoff,项目名称:grav-plugin-jscomments,代码行数:9,代码来源:jscomments.php

示例5: onPageInitialized

 /**
  * Create search result page.
  */
 public function onPageInitialized()
 {
     $page = new Page();
     $page->init(new \SplFileInfo(__DIR__ . '/pages/simplesearch.md'));
     // override the template is set in the config
     $template_override = $this->config->get('plugins.simplesearch.template');
     if ($template_override) {
         $page->template($template_override);
     }
     $this->grav['page'] = $page;
 }
开发者ID:shahriyarahmed31,项目名称:docs,代码行数:14,代码来源:simplesearch.php

示例6: testAddPage

 public function testAddPage()
 {
     /** @var UniformResourceLocator $locator */
     $locator = $this->grav['locator'];
     $path = $locator->findResource('tests://') . '/fake/single-pages/01.simple-page/default.md';
     $aPage = new Page();
     $aPage->init(new \SplFileInfo($path));
     $this->pages->addPage($aPage, '/new-page');
     $this->assertTrue(in_array('/new-page', array_keys($this->pages->routes())));
     $this->assertSame($locator->findResource('tests://') . '/fake/single-pages/01.simple-page', $this->pages->routes()['/new-page']);
 }
开发者ID:getgrav,项目名称:grav,代码行数:11,代码来源:PagesTest.php

示例7: mergeConfig

 private function mergeConfig(Page $page, $params = [])
 {
     $this->config = new Data((array) $this->grav['config']->get('plugins.simple_form'));
     if (isset($page->header()->simple_form)) {
         if (is_array($page->header()->simple_form)) {
             $this->config = new Data(array_replace_recursive($this->config->toArray(), $page->header()->simple_form));
         } else {
             $this->config->set('enabled', $page->header()->simple_form);
         }
     }
     $this->config = new Data(array_replace_recursive($this->config->toArray(), $params));
 }
开发者ID:hexplor,项目名称:grav-plugin-simple_form,代码行数:12,代码来源:simple_form.php

示例8: __construct

 /**
  * Create form for the given page.
  *
  * @param Page $page
  */
 public function __construct(Page $page)
 {
     $this->page = $page;
     $header = $page->header();
     $this->rules = isset($header->rules) ? $header->rules : array();
     $this->data = isset($header->data) ? $header->data : array();
     $this->items = $header->form;
     // Set form name if not set.
     if (empty($this->items['name'])) {
         $this->items['name'] = $page->slug();
     }
 }
开发者ID:Rokys,项目名称:grav-bvb,代码行数:17,代码来源:form.php

示例9: onPageNotFound

 /**
  * Display error page if no page was found for the current route.
  *
  * @param Event $event
  */
 public function onPageNotFound(Event $event)
 {
     /** @var Pages $pages */
     $pages = $this->grav['pages'];
     // Try to load user error page.
     $page = $pages->dispatch($this->config->get('plugins.error.routes.404', '/error'), true);
     if (!$page) {
         // If none provided use built in error page.
         $page = new Page();
         $page->init(new \SplFileInfo(__DIR__ . '/pages/error.md'));
     }
     $event->page = $page;
     $event->stopPropagation();
 }
开发者ID:indigo423,项目名称:blog.no42.org,代码行数:19,代码来源:error.php

示例10: __construct

 /**
  * Create form for the given page.
  *
  * @param Page $page
  */
 public function __construct(Page $page)
 {
     $this->page = $page;
     $header = $page->header();
     $this->rules = isset($header->rules) ? $header->rules : array();
     $this->data = isset($header->data) ? $header->data : array();
     $this->items = $header->form;
     // Set form name if not set.
     if (empty($this->items['name'])) {
         $this->items['name'] = $page->slug();
     }
     $this->reset();
     // Fire event
     self::getGrav()->fireEvent('onFormInitialized', new Event(['form' => $this]));
 }
开发者ID:tuxknight,项目名称:daocloud-docs,代码行数:20,代码来源:form.php

示例11: addTaxonomy

 /**
  * Takes an individual page and processes the taxonomies configured in its header. It
  * then adds those taxonomies to the map
  *
  * @param Page $page the page to process
  * @param array $page_taxonomy
  */
 public function addTaxonomy(Page $page, $page_taxonomy = null)
 {
     if (!$page_taxonomy) {
         $page_taxonomy = $page->taxonomy();
     }
     /** @var Config $config */
     $config = $this->grav['config'];
     if ($config->get('site.taxonomies') && count($page_taxonomy) > 0) {
         foreach ((array) $config->get('site.taxonomies') as $taxonomy) {
             if (isset($page_taxonomy[$taxonomy])) {
                 foreach ((array) $page_taxonomy[$taxonomy] as $item) {
                     // TODO: move to pages class?
                     $this->taxonomy_map[$taxonomy][(string) $item][$page->path()] = array('slug' => $page->slug());
                 }
             }
         }
     }
 }
开发者ID:qbi,项目名称:datenknoten.me,代码行数:25,代码来源:Taxonomy.php

示例12: addTaxonomy

 /**
  * Takes an individual page and processes the taxonomies configured in its header. It
  * then adds those taxonomies to the map
  *
  * @param Page  $page the page to process
  * @param array $page_taxonomy
  */
 public function addTaxonomy(Page $page, $page_taxonomy = null)
 {
     if (!$page_taxonomy) {
         $page_taxonomy = $page->taxonomy();
     }
     if (!$page->published() || empty($page_taxonomy)) {
         return;
     }
     /** @var Config $config */
     $config = $this->grav['config'];
     if ($config->get('site.taxonomies')) {
         foreach ((array) $config->get('site.taxonomies') as $taxonomy) {
             if (isset($page_taxonomy[$taxonomy])) {
                 foreach ((array) $page_taxonomy[$taxonomy] as $item) {
                     $this->taxonomy_map[$taxonomy][(string) $item][$page->path()] = ['slug' => $page->slug()];
                 }
             }
         }
     }
 }
开发者ID:jeremycherfas,项目名称:grav-blog,代码行数:27,代码来源:Taxonomy.php

示例13: addDropdown

 private function addDropdown(Page $page, array $configuration)
 {
     $dropdownItems = array();
     $children = $page->children();
     foreach ($children as $child) {
         if (!$child->published()) {
             continue;
         }
         $dropdownItems[] = $this->addLink($child, $configuration);
     }
     $dropdown = $this->addLink($page, $configuration, 'dropdown');
     $dropdown['items'] = $dropdownItems;
     return $dropdown;
 }
开发者ID:jamisonjudd,项目名称:Literature-Review,代码行数:14,代码来源:Navbar.php

示例14: savePage

 /**
  * Get Page informations 
  * update content
  * save page
  * 
  * @param Page Page that has to be saved
  * @return void - calls ajaxoutput
  */
 public function savePage(\Grav\Common\Page\Page $page)
 {
     // get local names for some objects
     $input = $this->post;
     $user = $this->grav['user'];
     // Check Permissions for Save
     if ($user->authenticated && $user->authorize("site.editor")) {
         var_dump($input);
         // Fill content last because it also renders the output.
         if (isset($input['content'])) {
             $page->rawMarkdown((string) $input['content']);
         }
     } else {
         $this->json_response = ['status' => 'unauthorized', 'message' => 'You have insufficient permissions for editing. Make sure you logged in.'];
         return;
     }
 }
开发者ID:gitter-badger,项目名称:fred,代码行数:25,代码来源:fred.php

示例15: parent

 /**
  * Gets and Sets the parent object for this page
  *
  * @param  Page $var the parent page object
  * @return Page|null the parent page object if it exists.
  */
 public function parent(Page $var = null)
 {
     if ($var) {
         $this->parent = $var->path();
         return $var;
     }
     /** @var Pages $pages */
     $pages = self::getGrav()['pages'];
     return $pages->get($this->parent);
 }
开发者ID:realitygaps,项目名称:grav_ynh,代码行数:16,代码来源:Page.php


注:本文中的Grav\Common\Page\Page类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。