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


PHP Page::header方法代码示例

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


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

示例1: 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

示例2: 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

示例3: __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

示例4: __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

示例5: addExtra

 /**
  * Add extra items to the shortcodes stream.
  *
  * @param string $group   The group name to add the extra items to.
  * @param any    $extra   The item to store.
  */
 public function addExtra($group, $method, $arguments = null)
 {
     $header = $this->page->header();
     $arguments = is_array($arguments) ? $arguments : [$arguments];
     // Modify page header
     $shortcodes = isset($header->shortcodes) ? $header->shortcodes : [];
     $shortcodes['extra'][$group][] = [$method, $arguments];
     // Temporally store Shortcode extras in page header
     $this->page->modifyHeader('shortcodes', $shortcodes);
     if ($this->page->id() == self::getGrav()['page']->id()) {
         $object = $group != 'page' ? self::getGrav()[$group] : $page;
         call_user_func_array([$object, $method], $arguments);
     }
 }
开发者ID:Sommerregen,项目名称:grav-plugin-shortcodes,代码行数:20,代码来源:Shortcodes.php

示例6: __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

示例7: processPage

 /**
  * Twig process that renders a page item. It supports two variations:
  * 1) Handles modular pages by rendering a specific page based on its modular twig template
  * 2) Renders individual page items for twig processing before the site rendering
  *
  * @param  Page   $item    The page item to render
  * @param  string $content Optional content override
  * @return string          The rendered output
  * @throws \Twig_Error_Loader
  */
 public function processPage(Page $item, $content = null)
 {
     $content = $content !== null ? $content : $item->content();
     // override the twig header vars for local resolution
     $this->grav->fireEvent('onTwigPageVariables');
     $twig_vars = $this->twig_vars;
     $twig_vars['page'] = $item;
     $twig_vars['media'] = $item->media();
     $twig_vars['header'] = $item->header();
     $local_twig = clone $this->twig;
     $modular_twig = $item->modularTwig();
     $process_twig = isset($item->header()->process['twig']) ? $item->header()->process['twig'] : false;
     try {
         // Process Modular Twig
         if ($modular_twig) {
             $twig_vars['content'] = $content;
             $template = $item->template() . TEMPLATE_EXT;
             $output = $content = $local_twig->render($template, $twig_vars);
         }
         // Process in-page Twig
         if (!$modular_twig || $modular_twig && $process_twig) {
             $name = '@Page:' . $item->path();
             $this->setTemplate($name, $content);
             $output = $local_twig->render($name, $twig_vars);
         }
     } catch (\Twig_Error_Loader $e) {
         throw new \RuntimeException($e->getRawMessage(), 404, $e);
     }
     return $output;
 }
开发者ID:sunilkgrao,项目名称:grav-test,代码行数:40,代码来源:Twig.php

示例8: preparePage

 /**
  * Prepare a page to be stored: update its folder, name, template, header and content
  *
  * @param \Grav\Common\Page\Page $page
  * @param bool                   $clean_header
  */
 protected function preparePage(\Grav\Common\Page\Page $page, $clean_header = false, $language = null)
 {
     $input = $this->post;
     if (isset($input['order'])) {
         $order = max(0, (int) isset($input['order']) ? $input['order'] : $page->value('order'));
         $ordering = $order ? sprintf('%02d.', $order) : '';
         $slug = empty($input['folder']) ? $page->value('folder') : (string) $input['folder'];
         $page->folder($ordering . $slug);
     }
     if (isset($input['name']) && !empty($input['name'])) {
         $type = (string) strtolower($input['name']);
         $name = preg_replace('|.*/|', '', $type);
         if ($language) {
             $name .= '.' . $language;
         } else {
             $language = $this->grav['language'];
             if ($language->enabled()) {
                 $name .= '.' . $language->getLanguage();
             }
         }
         $name .= '.md';
         $page->name($name);
         $page->template($type);
         // unset some header things, template for now as we've just set that
         if (isset($input['header']['template'])) {
             unset($input['header']['template']);
         }
     }
     // Special case for Expert mode: build the raw, unset content
     if (isset($input['frontmatter']) && isset($input['content'])) {
         $page->raw("---\n" . (string) $input['frontmatter'] . "\n---\n" . (string) $input['content']);
         unset($input['content']);
     }
     if (isset($input['header'])) {
         $header = $input['header'];
         foreach ($header as $key => $value) {
             if ($key == 'metadata') {
                 foreach ($header['metadata'] as $key2 => $value2) {
                     if (isset($input['toggleable_header']['metadata'][$key2]) && !$input['toggleable_header']['metadata'][$key2]) {
                         $header['metadata'][$key2] = '';
                     }
                 }
             } elseif ($key == 'taxonomy') {
                 foreach ($header[$key] as $taxkey => $taxonomy) {
                     if (is_array($taxonomy) && count($taxonomy) == 1 && trim($taxonomy[0]) == '') {
                         unset($header[$key][$taxkey]);
                     }
                 }
             } else {
                 if (isset($input['toggleable_header'][$key]) && !$input['toggleable_header'][$key]) {
                     $header[$key] = null;
                 }
             }
         }
         if ($clean_header) {
             $header = Utils::arrayFilterRecursive($header, function ($k, $v) {
                 return !(is_null($v) || $v === '');
             });
         }
         $page->header((object) $header);
         $page->frontmatter(Yaml::dump((array) $page->header()));
     }
     // Fill content last because it also renders the output.
     if (isset($input['content'])) {
         $page->rawMarkdown((string) $input['content']);
     }
 }
开发者ID:clee03,项目名称:metal,代码行数:73,代码来源:controller.php

示例9: taskSaveas

 /**
  * Save the current page in a different language. Automatically switches to that language.
  *
  * @return bool True if the action was performed.
  */
 protected function taskSaveas()
 {
     if (!$this->authorizeTask('save', $this->dataPermissions())) {
         return false;
     }
     $data = (array) $this->data;
     $language = $data['lang'];
     if ($language) {
         $this->grav['session']->admin_lang = $language ?: 'en';
     }
     $uri = $this->grav['uri'];
     $obj = $this->admin->page($uri->route());
     $this->preparePage($obj, false, $language);
     $file = $obj->file();
     if ($file) {
         $filename = $this->determineFilenameIncludingLanguage($obj->name(), $language);
         $path = $obj->path() . DS . $filename;
         $aFile = File::instance($path);
         $aFile->save();
         $aPage = new Page();
         $aPage->init(new \SplFileInfo($path), $language . '.md');
         $aPage->header($obj->header());
         $aPage->rawMarkdown($obj->rawMarkdown());
         $aPage->validate();
         $aPage->filter();
         $aPage->save();
         $this->grav->fireEvent('onAdminAfterSave', new Event(['page' => $obj]));
     }
     $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.SUCCESSFULLY_SWITCHED_LANGUAGE'), 'info');
     $this->setRedirect('/' . $language . $uri->route());
     return true;
 }
开发者ID:getgrav,项目名称:grav-plugin-admin,代码行数:37,代码来源:admincontroller.php

示例10: storeFiles

 /**
  * @param \Grav\Common\Page\Page|\Grav\Common\Data\Data $obj
  *
  * @return \Grav\Common\Page\Page|\Grav\Common\Data\Data
  */
 protected function storeFiles($obj)
 {
     // Process previously uploaded files for the current URI
     // and finally store them. Everything else will get discarded
     $queue = $this->admin->session()->getFlashObject('files-upload');
     $queue = $queue[base64_encode($this->grav['uri']->url())];
     if (is_array($queue)) {
         foreach ($queue as $key => $files) {
             foreach ($files as $destination => $file) {
                 if (!rename($file['tmp_name'], $destination)) {
                     throw new \RuntimeException(sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_UNABLE_TO_MOVE', null), '"' . $file['tmp_name'] . '"', $destination));
                 }
                 unset($files[$destination]['tmp_name']);
             }
             if ($this->view == 'pages') {
                 $keys = explode('.', preg_replace('/^header./', '', $key));
                 $init_key = array_shift($keys);
                 if (count($keys) > 0) {
                     $new_data = isset($obj->header()->{$init_key}) ? $obj->header()->{$init_key} : [];
                     Utils::setDotNotation($new_data, implode('.', $keys), $files, true);
                 } else {
                     $new_data = $files;
                 }
                 if (isset($data['header'][$init_key])) {
                     $obj->modifyHeader($init_key, array_replace_recursive([], $data['header'][$init_key], $new_data));
                 } else {
                     $obj->modifyHeader($init_key, $new_data);
                 }
             } else {
                 // TODO: [this is JS handled] if it's single file, remove existing and use set, if it's multiple, use join
                 $obj->join($key, $files);
                 // stores
             }
         }
     }
     return $obj;
 }
开发者ID:getgrav,项目名称:grav-plugin-admin,代码行数:42,代码来源:adminbasecontroller.php

示例11: translatedLanguages

 /**
  * Return an array with the routes of other translated languages
  * @return array the page translated languages
  */
 public function translatedLanguages()
 {
     $filename = substr($this->name, 0, -strlen($this->extension()));
     $config = self::getGrav()['config'];
     $languages = $config->get('system.languages.supported', []);
     $translatedLanguages = [];
     foreach ($languages as $language) {
         $path = $this->path . DS . $this->folder . DS . $filename . '.' . $language . '.md';
         if (file_exists($path)) {
             $aPage = new Page();
             $aPage->init(new \SplFileInfo($path), $language . '.md');
             $route = isset($aPage->header()->routes['default']) ? $aPage->header()->routes['default'] : $aPage->rawRoute();
             if (!$route) {
                 $route = $aPage->slug();
             }
             $translatedLanguages[$language] = $route;
         }
     }
     return $translatedLanguages;
 }
开发者ID:realitygaps,项目名称:grav_ynh,代码行数:24,代码来源:Page.php

示例12: addAssets

 /**
  * Add plugin specific assets
  * @param Page $page
  * @param Assets $assets
  */
 protected function addAssets(Page $page, Assets $assets)
 {
     $pluginAssets = [];
     if (!empty($page->header()->videoembed['assets'])) {
         $pluginAssets = (array) $page->header()->videoembed['assets'];
     }
     foreach ($pluginAssets as $asset) {
         $assets->add($asset);
     }
 }
开发者ID:biggtfish,项目名称:grav-plugin-videoembed,代码行数:15,代码来源:videoembed.php

示例13: mergeConfig

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

示例14: mergePluginConfig

 protected function mergePluginConfig(Page $page)
 {
     $defaults = (array) $this->grav['config']->get('plugins.recaptchacontact');
     if (isset($page->header()->recaptchacontact)) {
         if (is_array($page->header()->recaptchacontact)) {
             $this->grav['config']->set('plugins.recaptchacontact', array_replace_recursive($defaults, $page->header()->recaptchacontact));
         } else {
             $this->grav['config']->set('plugins.recaptchacontact.enabled', $page->header()->recaptchacontact);
         }
     } else {
         $this->grav['config']->set('plugins.recaptchacontact.enabled', false);
     }
     $this->enableCssLoading();
 }
开发者ID:aradianoff,项目名称:recaptchacontact,代码行数:14,代码来源:recaptchacontact.php

示例15: processPage

 /**
  * Twig process that renders a page item. It supports two variations:
  * 1) Handles modular pages by rendering a specific page based on its modular twig template
  * 2) Renders individual page items for twig processing before the site rendering
  *
  * @param  Page   $item    The page item to render
  * @param  string $content Optional content override
  * @return string          The rendered output
  * @throws \Twig_Error_Loader
  */
 public function processPage(Page $item, $content = null)
 {
     $content = $content !== null ? $content : $item->content();
     // override the twig header vars for local resolution
     $this->grav->fireEvent('onTwigPageVariables');
     $twig_vars = $this->twig_vars;
     $twig_vars['page'] = $item;
     $twig_vars['media'] = $item->media();
     $twig_vars['header'] = $item->header();
     $local_twig = clone $this->twig;
     // Get Twig template layout
     if ($item->modularTwig()) {
         $twig_vars['content'] = $content;
         $template = $item->template() . TEMPLATE_EXT;
         $output = $local_twig->render($template, $twig_vars);
     } else {
         $name = '@Page:' . $item->path();
         $this->setTemplate($name, $content);
         $output = $local_twig->render($name, $twig_vars);
     }
     return $output;
 }
开发者ID:qbi,项目名称:datenknoten.me,代码行数:32,代码来源:Twig.php


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