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


PHP Page::filePath方法代码示例

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


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

示例1: getPage

 /**
  * Returns the page creating it if it does not exist.
  *
  * @param $path
  *
  * @return Page
  */
 public function getPage($path)
 {
     /** @var Pages $pages */
     $pages = $this->grav['pages'];
     if ($path && $path[0] != '/') {
         $path = "/{$path}";
     }
     $page = $path ? $pages->dispatch($path, true) : $pages->root();
     if (!$page) {
         $slug = basename($path);
         if ($slug == '') {
             return null;
         }
         $ppath = str_replace('\\', '/', dirname($path));
         // Find or create parent(s).
         $parent = $this->getPage($ppath != '/' ? $ppath : '');
         // Create page.
         $page = new Page();
         $page->parent($parent);
         $page->filePath($parent->path() . '/' . $slug . '/' . $page->name());
         // Add routing information.
         $pages->addPage($page, $path);
         // Set if Modular
         $page->modularTwig($slug[0] == '_');
         // Determine page type.
         if (isset($this->session->{$page->route()})) {
             // Found the type and header from the session.
             $data = $this->session->{$page->route()};
             // Set the key header value
             $header = ['title' => $data['title']];
             if (isset($data['visible'])) {
                 if ($data['visible'] == '' || $data['visible']) {
                     // if auto (ie '')
                     $children = $page->parent()->children();
                     foreach ($children as $child) {
                         if ($child->order()) {
                             // set page order
                             $page->order(1000);
                             break;
                         }
                     }
                 }
                 if ($data['visible'] == 1 && !$page->order()) {
                     $header['visible'] = $data['visible'];
                 }
             }
             if ($data['name'] == 'modular') {
                 $header['body_classes'] = 'modular';
             }
             $name = $page->modular() ? str_replace('modular/', '', $data['name']) : $data['name'];
             $page->name($name . '.md');
             // Fire new event to allow plugins to manipulate page frontmatter
             $this->grav->fireEvent('onAdminCreatePageFrontmatter', new Event(['header' => &$header]));
             $page->header($header);
             $page->frontmatter(Yaml::dump((array) $page->header(), 10, 2, false));
         } else {
             // Find out the type by looking at the parent.
             $type = $parent->childType() ? $parent->childType() : $parent->blueprints()->get('child_type', 'default');
             $page->name($type . CONTENT_EXT);
             $page->header();
         }
         $page->modularTwig($slug[0] == '_');
     }
     return $page;
 }
开发者ID:getgrav,项目名称:grav-plugin-admin,代码行数:72,代码来源:admin.php

示例2: getPage

 /**
  * Returns the page creating it if it does not exist.
  *
  * @param $path
  * @return Page
  */
 protected function getPage($path)
 {
     /** @var Pages $pages */
     $pages = $this->grav['pages'];
     if ($path && $path[0] != '/') {
         $path = "/{$path}";
     }
     $page = $path ? $pages->dispatch($path, true) : $pages->root();
     if (!$page) {
         $slug = basename($path);
         $ppath = dirname($path);
         // Find or create parent(s).
         $parent = $this->getPage($ppath != '/' ? $ppath : '');
         // Create page.
         $page = new Page();
         $page->parent($parent);
         $page->filePath($parent->path() . '/' . $slug . '/' . $page->name());
         // Add routing information.
         $pages->addPage($page, $path);
         // Determine page type.
         if (isset($this->session->{$page->route()})) {
             // Found the type and header from the session.
             $data = $this->session->{$page->route()};
             $page->name($data['type'] . '.md');
             $page->header(['title' => $data['title']]);
             $page->frontmatter(Yaml::dump((array) $page->header()));
         } else {
             // Find out the type by looking at the parent.
             $type = $parent->childType() ? $parent->childType() : $parent->blueprints()->get('child_type', 'default');
             $page->name($type . CONTENT_EXT);
             $page->header();
         }
         $page->modularTwig($slug[0] == '_');
     }
     return $page;
 }
开发者ID:symac,项目名称:grav-plugin-admin,代码行数:42,代码来源:admin.php

示例3: getPage

 /**
  * Returns the page creating it if it does not exist.
  *
  * @param $path
  *
  * @return Page
  */
 protected function getPage($path)
 {
     /** @var Pages $pages */
     $pages = $this->grav['pages'];
     if ($path && $path[0] != '/') {
         $path = "/{$path}";
     }
     $page = $path ? $pages->dispatch($path, true) : $pages->root();
     if (!$page) {
         $slug = basename($path);
         if ($slug == '') {
             return null;
         }
         $ppath = dirname($path);
         // Find or create parent(s).
         $parent = $this->getPage($ppath != '/' ? $ppath : '');
         // Create page.
         $page = new Page();
         $page->parent($parent);
         $page->filePath($parent->path() . '/' . $slug . '/' . $page->name());
         // Add routing information.
         $pages->addPage($page, $path);
         // Set if Modular
         $page->modularTwig($slug[0] == '_');
         // Determine page type.
         if (isset($this->session->{$page->route()})) {
             // Found the type and header from the session.
             $data = $this->session->{$page->route()};
             $visible = isset($data['visible']) && $data['visible'] != '' ? (bool) $data['visible'] : $this->guessVisibility($page);
             $header = ['title' => $data['title'], 'visible' => $visible];
             if ($data['type'] == 'modular') {
                 $header['body_classes'] = 'modular';
             }
             $name = $page->modular() ? str_replace('modular/', '', $data['type']) : $data['type'];
             $page->name($name . '.md');
             $page->header($header);
             $page->frontmatter(Yaml::dump((array) $page->header()));
         } else {
             // Find out the type by looking at the parent.
             $type = $parent->childType() ? $parent->childType() : $parent->blueprints()->get('child_type', 'default');
             $page->name($type . CONTENT_EXT);
             $page->header();
         }
         $page->modularTwig($slug[0] == '_');
     }
     return $page;
 }
开发者ID:kevinkub,项目名称:grav-plugin-admin,代码行数:54,代码来源:admin.php


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