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


PHP Helpers::url_to_file_path方法代码示例

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


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

示例1: parse_get

 static function parse_get(&$data, $template)
 {
     # match any gets
     preg_match('/([\\S\\s]*?)get[\\s]+?["\']\\/?(.*?)\\/?["\']\\s+?do\\s+?([\\S\\s]+?)end\\b([\\S\\s]*)$/', $template, $template_parts);
     # run the replacements on the pre-"get" part of the partial
     $template = self::parse($data, $template_parts[1]);
     # turn route into file path
     $file_path = Helpers::url_to_file_path($template_parts[2]);
     # store current data
     $current_data = $data;
     # if the route exists...
     if (file_exists($file_path)) {
         # check for any nested matches
         $template_parts = self::test_nested_matches($template_parts, 'get[\\s]+?["\']\\/?.*?\\/?["\']\\s+?do', 'end\\b');
         # set data object to match file path
         $data = AssetFactory::get($file_path);
         # run the replacements on the inner-"get" part of the partial
         $template .= self::parse($data, $template_parts[3]);
     }
     # revert context back to original
     $data = $current_data;
     # run the replacements on the post-"get" part of the partial
     $template .= self::parse($data, $template_parts[4]);
     return $template;
 }
开发者ID:jcsiegrist,项目名称:stacey,代码行数:25,代码来源:template-parser.inc.php

示例2: __construct

 function __construct($url, $content = false)
 {
     # store url and converted file path
     $this->file_path = Helpers::url_to_file_path($url);
     $this->url_path = $url;
     $this->template_name = self::template_name($this->file_path);
     $this->template_file = self::template_file($this->template_name);
     $this->template_type = self::template_type($this->template_file);
     # create/set all content variables
     PageData::create($this, $content);
 }
开发者ID:afonsoduarte,项目名称:europa,代码行数:11,代码来源:page.inc.php

示例3: __construct

 function __construct($url)
 {
     # store url and converted file path
     $this->url_path = $url;
     $this->file_path = Helpers::url_to_file_path($this->url_path);
     $this->template_name = $this->template_name();
     $this->template_file = $this->template_file();
     # create/set all content variables
     PageData::create($this);
     # sort data array by key length
     #
     # this ensures that something like '@title' doesn't turn '@page_title'
     # into '@page_Contents of @title variable' in the final rendered template
     #
     uksort($this->data, array('Helpers', 'sort_by_length'));
 }
开发者ID:kolber,项目名称:aesthetically-loyal-website,代码行数:16,代码来源:page.inc.php

示例4: get

 function get($url, $current_url = '')
 {
     # strip leading & trailing slashes from $url
     $url = preg_replace(array('/^\\//', '/\\/$/'), '', $url);
     # if the current url is passed, then we use it to build up a relative context
     $url = $current_url . $url;
     # strip leading '../'s from the url if any exists
     $url = preg_replace('/^((\\.+)*\\/)*/', '', $url);
     # turn route into file path
     $file_path = Helpers::url_to_file_path($url);
     # check for children of the index page
     if (!$file_path) {
         return $file_path = Helpers::url_to_file_path('index/' . $url);
     }
     # create & return the new page object
     return AssetFactory::get($file_path);
 }
开发者ID:robertDpi,项目名称:platycms,代码行数:17,代码来源:twig-extensions.inc.php

示例5: __construct

 function __construct($get)
 {
     # sometimes when PHP release a new version, they do silly things - this
     # function is here to fix them
     $this->php_fixes();
     # it's easier to handle some redirection through php rather than relying on
     # a more complex .htaccess file to do all the work
     if ($this->handle_redirects()) {
         return;
     }
     # strip any leading or trailing slashes from the passed url
     $key = preg_replace(array('/\\/$/', '/^\\//'), '', key($get));
     # store file path for this current page
     $this->route = isset($key) ? $key : 'index';
     $file_path = Helpers::url_to_file_path($this->route);
     try {
         # create and render the current page
         $this->create_page($file_path);
     } catch (Exception $e) {
         if ($e->getMessage() == "404") {
             # return 404 headers
             header('HTTP/1.0 404 Not Found');
             if (file_exists('./content/404')) {
                 $this->create_page('./content/404', '404');
             } else {
                 if (file_exists('./public/404.html')) {
                     echo file_get_contents('./public/404.html');
                 } else {
                     echo '<h1>404</h1><h2>Page could not be found.</h2><p>Unfortunately, the page you were looking for does not exist here.</p>';
                 }
             }
         } else {
             echo '<h3>' . $e->getMessage() . '</h3>';
         }
     }
 }
开发者ID:hpuit,项目名称:stacey,代码行数:36,代码来源:stacey.inc.php

示例6: __construct

 function __construct($get)
 {
     # sometimes when PHP release a new version, they do silly things - this function is here to fix them
     $this->php_fixes();
     # it's easier to handle some redirection through php rather than relying on a more complex .htaccess file to do all the work
     if ($this->handle_redirects()) {
         return;
     }
     # strip any leading or trailing slashes from the passed url
     $key = key($get);
     # if the key isn't a URL path, then ignore it
     if (!preg_match('/\\//', $key)) {
         $key = false;
     }
     $key = preg_replace(array('/\\/$/', '/^\\//'), '', $key);
     # store file path for this current page
     $this->route = isset($key) ? $key : 'index';
     # TODO: Relative root path is set incorrectly (missing an extra ../)
     # strip any trailing extensions from the url
     $this->route = preg_replace('/[\\.][\\w\\d]+?$/', '', $this->route);
     $file_path = Helpers::url_to_file_path($this->route);
     try {
         # create and render the current page
         $this->create_page($file_path);
     } catch (Exception $e) {
         if ($e->getMessage() == "404") {
             # return 404 headers
             header('HTTP/1.0 404 Not Found');
             if (file_exists(Config::$content_folder . '/404')) {
                 $this->route = '404';
                 $this->create_page(Config::$content_folder . '/404');
             } else {
                 if (file_exists(Config::$root_folder . 'public/404.html')) {
                     echo file_get_contents(Config::$root_folder . 'public/404.html');
                 } else {
                     echo '<h1>404</h1><h2>Page could not be found.</h2><p>Unfortunately, the page you were looking for does not exist here.</p>';
                 }
             }
         } else {
             echo '<h3>' . $e->getMessage() . '</h3>';
         }
     }
 }
开发者ID:robertbrook,项目名称:stacey,代码行数:43,代码来源:stacey.inc.php


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