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


PHP Helpers::relative_root_path方法代码示例

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


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

示例1: create_textfile_vars

 static function create_textfile_vars($page, $content = false)
 {
     # store contents of content file (if it exists, otherwise, pass back an empty string)
     if ($content) {
         $vars = sfYaml::load($content);
     } else {
         $content_file = sprintf('%s/%s', $page->file_path, $page->template_name);
         $content_file_path = file_exists($content_file . '.yml') ? $content_file . '.yml' : $content_file . '.txt';
         if (!file_exists($content_file_path)) {
             return;
         }
         # Correct formatting of fenced content
         $content = file_get_contents($content_file_path);
         $content = self::preparse_text($content);
         $vars = sfYaml::load($content);
     }
     # include shared variables for each page
     $vars = array_merge(self::get_shared_data(), $vars ? $vars : array());
     if (empty($vars)) {
         return;
     }
     global $current_page_template_file;
     if (!$current_page_template_file) {
         $current_page_template_file = $page->template_file;
     }
     $markdown_compatible = preg_match('/\\.(xml|html?|rss|rdf|atom|js|json)$/', $current_page_template_file);
     $relative_path = preg_replace('/^\\.\\//', Helpers::relative_root_path(), $page->file_path);
     $vars = self::parse_vars($vars, $markdown_compatible, $relative_path);
     foreach ($vars as $key => $value) {
         # set a variable with a name of 'key' on the page with a value of 'value'
         $page->{$key} = $value;
     }
 }
开发者ID:puleddu,项目名称:italocalvino.it,代码行数:33,代码来源:page-data.inc.php

示例2: create_textfile_vars

 static function create_textfile_vars($page)
 {
     # store contents of content file (if it exists, otherwise, pass back an empty string)
     $content_file_path = $page->file_path . '/' . $page->template_name . '.txt';
     $text = file_exists($content_file_path) ? file_get_contents($content_file_path) : '';
     # include shared variables for each page
     $shared = file_exists('./content/_shared.txt') ? file_get_contents('./content/_shared.txt') : '';
     # strip any $n matches from the text, as this will mess with any preg_replaces
     # they get put back in after the template has finished being parsed
     $text = preg_replace('/\\$(\\d+)/', "\$1", $text);
     # remove UTF-8 BOM and marker character in input, if present
     $merged_text = preg_replace('/^\\xEF\\xBB\\xBF|\\x1A/', '', array($shared, $text));
     # merge shared content into text
     $shared = preg_replace('/\\n\\s*?-\\s*?\\n?$/', '', $merged_text[0]);
     $content = preg_replace('/\\n\\s*?-\\s*?\\n?$/', '', $merged_text[1]);
     $text = $shared . "\n-\n" . $content;
     # standardize line endings
     $text = preg_replace('/\\r\\n?/', "\n", $text);
     # pull out each key/value pair from the content file
     $matches = preg_split("/\n\\s*?-\\s*?\n/", $text);
     foreach ($matches as $match) {
         # split the string by the first colon
         $colon_split = explode(':', $match, 2);
         # replace the only var in your content - @path for your inline html with images and stuff
         $relative_path = preg_replace('/^\\.\\//', Helpers::relative_root_path(), $page->file_path);
         $colon_split[1] = preg_replace('/\\@path/', $relative_path . '/', $colon_split[1]);
         # get template file type as $split_path[1]
         global $current_page_template_file;
         if (!$current_page_template_file) {
             $current_page_template_file = $page->template_file;
         }
         preg_match('/\\.([\\w\\d]+?)$/', $current_page_template_file, $split_path);
         # set a variable with a name of 'key' on the page with a value of 'value'
         # if the template type is xml or html & the 'value' contains a newline character, parse it as markdown
         if (strpos($colon_split[1], "\n") !== false && preg_match('/xml|htm|html|rss|rdf|atom/', $split_path[1])) {
             $page->{$colon_split}[0] = Markdown(trim($colon_split[1]));
         } else {
             $page->{$colon_split}[0] = trim($colon_split[1]);
         }
     }
 }
开发者ID:bschlagel,项目名称:caseyagollan.com,代码行数:41,代码来源:page-data.inc.php

示例3: create_textfile_vars

 static function create_textfile_vars($page)
 {
     # store contents of content file (if it exists, otherwise, pass back an empty string)
     $content_file_path = $page->file_path . '/' . $page->template_name . '.txt';
     $text = file_exists($content_file_path) ? file_get_contents($content_file_path) : '';
     # include shared variables for each page
     $shared = file_exists('./content/_shared.txt') ? file_get_contents('./content/_shared.txt') : '';
     # remove UTF-8 BOM and marker character in input, if present
     $merged_text = preg_replace('/^\\xEF\\xBB\\xBF|\\x1A/', '', array($shared, $text));
     # merge shared content into text
     $text = "\n" . $merged_text[0] . "\n-\n" . $merged_text[1] . "\n-\n";
     # standardize line endings
     $text = preg_replace('/\\r\\n?/', "\n", $text);
     # pull out each key/value pair from the content file
     preg_match_all('/(?<=\\n)([a-z\\d_\\-]+?:[\\S\\s]*?)\\n\\s*?-\\s*?\\n/', $text, $matches);
     foreach ($matches[1] as $match) {
         # split the string by the first colon
         $colon_split = explode(':', $match, 2);
         # replace the only var in your content - @path for your inline html with images and stuff
         $relative_path = preg_replace('/^\\.\\//', Helpers::relative_root_path(), $page->file_path);
         $colon_split[1] = preg_replace('/\\@path/', $relative_path . '/', $colon_split[1]);
         # set a variable with a name of 'key' on the page with a value of 'value'
         $page->{$colon_split}[0] = strpos($colon_split[1], "\n") === false ? trim($colon_split[1]) : Markdown(trim($colon_split[1]));
     }
 }
开发者ID:jcsiegrist,项目名称:stacey,代码行数:25,代码来源:page-data.inc.php

示例4: construct_link_path

 function construct_link_path($file_path)
 {
     return preg_replace('/^\\.\\//', Helpers::relative_root_path(), $file_path);
 }
开发者ID:jgillman,项目名称:LindseyTestolin.com,代码行数:4,代码来源:asset.inc.php

示例5: create_vars

 static function create_vars($page)
 {
     # @url
     $page->url = Helpers::relative_root_path() . $page->url_path . '/';
     # @permalink
     $page->permalink = $page->url_path;
     # @slug
     $split_url = explode("/", $page->url_path);
     $page->slug = $split_url[count($split_url) - 1];
     # @page_name
     $page->page_name = ucfirst(preg_replace('/[-_](.)/e', "' '.strtoupper('\\1')", $page->data['@slug']));
     # @root_path
     $page->root_path = Helpers::relative_root_path();
     # @thumb
     $page->thumb = self::get_thumbnail($page->file_path);
     # @current_year
     $page->current_year = date('Y');
     # @stacey_version
     $page->stacey_version = Stacey::$version;
     # @domain_name
     $page->domain_name = $_SERVER['HTTP_HOST'];
     # @base_url
     $page->base_url = $_SERVER['HTTP_HOST'] . str_replace('/index.php', '', $_SERVER['PHP_SELF']);
     # @site_updated
     $page->site_updated = strval(date('c'));
     # @updated
     $page->updated = strval(date('c', Helpers::last_modified($page->file_path)));
     # @is_current_page
     $page->is_current_page = self::is_current_page($page->data['@base_url'], $page->data['@permalink']);
     # @siblings_count
     $page->siblings_count = strval(count($page->data['$siblings']));
     # @index
     $page->index = self::get_index($page->data['$siblings'], $page->file_path);
 }
开发者ID:byee01,项目名称:Brian-Stacey,代码行数:34,代码来源:page-data.inc.php

示例6: create_textfile_vars

 static function create_textfile_vars($page, $content = false)
 {
     # store contents of content file (if it exists, otherwise, pass back an empty string)
     if ($content) {
         $vars = sfYaml::load($content);
     } else {
         $content_file = sprintf('%s/%s', $page->file_path, $page->template_name);
         $content_file_path = file_exists($content_file . '.yml') ? $content_file . '.yml' : $content_file . '.txt';
         if (!file_exists($content_file_path)) {
             return;
         }
         $vars = sfYaml::load($content_file_path);
     }
     # include shared variables for each page
     $vars = array_merge(self::get_shared_data(), $vars ? $vars : array());
     if (empty($vars)) {
         return;
     }
     global $current_page_template_file;
     if (!$current_page_template_file) {
         $current_page_template_file = $page->template_file;
     }
     $markdown_compatible = preg_match('/\\.(xml|html?|rss|rdf|atom)$/', $current_page_template_file);
     $relative_path = preg_replace('/^\\.\\//', Helpers::relative_root_path(), $page->file_path);
     foreach ($vars as $key => $value) {
         # replace the only var in your content - page.path for your inline html with images and stuff
         if (is_string($value)) {
             $value = preg_replace('/{{\\s*path\\s*}}/', $relative_path . '/', $value);
         }
         # set a variable with a name of 'key' on the page with a value of 'value'
         # if the template type is xml or html & the 'value' contains a newline character, parse it as markdown
         if (!is_string($value)) {
             $page->{$key} = $value;
         } else {
             if ($markdown_compatible && strpos($value, "\n") !== false) {
                 $page->{$key} = Markdown(trim($value));
             } else {
                 $page->{$key} = trim($value);
             }
         }
     }
 }
开发者ID:nnennajohn,项目名称:stacey,代码行数:42,代码来源:page-data.inc.php


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