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


PHP Smarty::_realpath方法代码示例

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


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

示例1: getIncludePath

 /**
  * Return full file path from PHP include_path
  *
  * @param  string[] $dirs
  * @param  string   $file
  * @param \Smarty   $smarty
  *
  * @return bool|string full filepath or false
  *
  */
 public static function getIncludePath($dirs, $file, Smarty $smarty)
 {
     static $_include_path = null;
     static $_has_stream_include = null;
     if ($_include_path === null) {
         $_include_path = (array) explode(PATH_SEPARATOR, get_include_path());
         foreach ($_include_path as $key => $_path) {
             $_include_path[$key] = rtrim($_path, '/\\');
         }
         $_has_stream_include = function_exists('stream_resolve_include_path');
     }
     // try PHP include_path
     foreach ($dirs as $dir) {
         if ($dir[0] != '/' && $dir[1] != ':') {
             $_d_path = $dir . isset($file) ? $file : '';
             if ($_has_stream_include) {
                 // available since PHP 5.3.2
                 $path = stream_resolve_include_path($_d_path);
                 if ($path !== false && is_file($path)) {
                     return $smarty->_realpath($path);
                 }
             }
             foreach ($_include_path as $_i_path) {
                 if (is_file($_i_path . DS . $_d_path)) {
                     return $smarty->_realpath($_i_path . DS . $_d_path);
                 }
             }
         }
     }
     return false;
 }
开发者ID:RafaelFar,项目名称:CodeIgniter-HMVC-SMARTY-DOCTRINE-BOOTSTRAP,代码行数:41,代码来源:smarty_internal_get_include_path.php

示例2: isNewIncludePath

 /**
  * Check if include path was updated
  *
  * @param \Smarty $smarty
  *
  * @return bool
  */
 public function isNewIncludePath(Smarty $smarty)
 {
     $_i_path = get_include_path();
     if ($this->_include_path != $_i_path) {
         $this->_include_dirs = array();
         $this->_include_path = $_i_path;
         $_dirs = (array) explode(PATH_SEPARATOR, $_i_path);
         foreach ($_dirs as $_path) {
             if ($_path[0] != '/' && isset($dir[1]) && $dir[1] != ':') {
                 $_path = $smarty->_realpath($_path . DS, true);
             }
             if (is_dir($_path)) {
                 $this->_include_dirs[] = $smarty->_realpath($_path . DS, true);
             }
         }
         return true;
     }
     return false;
 }
开发者ID:firaga,项目名称:operation,代码行数:26,代码来源:smarty_internal_runtime_getincludepath.php

示例3: getIncludePath

 /**
  * Return full file path from PHP include_path
  *
  * @param  string[] $dirs
  * @param  string   $file
  * @param \Smarty   $smarty
  *
  * @return bool|string full filepath or false
  *
  */
 public static function getIncludePath($dirs, $file, Smarty $smarty)
 {
     static $_include_path = '';
     static $_include_dirs = array();
     static $_has_stream_include = null;
     $_i_path = get_include_path();
     if ($_include_path != $_i_path) {
         $_include_path = $_i_path;
         $_dirs = (array) explode(PATH_SEPARATOR, $_i_path);
         $_include_dirs = array();
         foreach ($_dirs as $_path) {
             $_include_dirs[] = rtrim($_path, '/\\');
         }
         $_has_stream_include = function_exists('stream_resolve_include_path');
     }
     // try PHP include_path
     foreach ($dirs as $dir) {
         if ($dir[0] == '/' || $dir[1] == ':') {
             $dir = $smarty->_realpath($dir, false);
         }
         if ($dir[0] != '/' && $dir[1] != ':') {
             $_d_path = $dir . (isset($file) ? $file : '');
             if ($_has_stream_include) {
                 // available since PHP 5.3.2
                 $path = stream_resolve_include_path($_d_path);
                 if ($path !== false && is_file($path)) {
                     return $smarty->_realpath($path, true);
                 }
             }
             foreach ($_include_dirs as $_i_path) {
                 if (is_file($_i_path . DS . $_d_path)) {
                     return $smarty->_realpath($_i_path . DS . $_d_path, true);
                 }
             }
         }
     }
     return false;
 }
开发者ID:sallency,项目名称:smarty,代码行数:48,代码来源:smarty_internal_get_include_path.php

示例4: isNewIncludePath

 /**
  * Check if include path was updated
  *
  * @return bool
  *
  */
 public static function isNewIncludePath(Smarty $smarty)
 {
     if (!isset(self::$_has_stream_include)) {
         self::$_has_stream_include = $smarty->use_include_path === 2 && function_exists('stream_resolve_include_path');
     }
     $_i_path = get_include_path();
     if (self::$_include_path != $_i_path) {
         self::$_include_dirs = array();
         self::$_include_path = $_i_path;
         $_dirs = (array) explode(PATH_SEPARATOR, $_i_path);
         foreach ($_dirs as $_path) {
             if ($_path[0] != '/' && isset($dir[1]) && $dir[1] != ':') {
                 $_path = $smarty->_realpath($_path . DS, true);
             }
             if (is_dir($_path)) {
                 self::$_include_dirs[] = $smarty->_realpath($_path . DS, true);
             }
         }
         return true;
     }
     return false;
 }
开发者ID:redaxle,项目名称:smarty,代码行数:28,代码来源:smarty_internal_get_include_path.php

示例5: loadPlugin

 /**
  * Takes unknown classes and loads plugin files for them
  * class name format: Smarty_PluginType_PluginName
  * plugin filename format: plugintype.pluginname.php
  *
  * @param \Smarty $smarty
  * @param  string $plugin_name class plugin name to load
  * @param  bool   $check       check if already loaded
  *
  * @return bool|string
  * @throws \SmartyException
  */
 public static function loadPlugin(Smarty $smarty, $plugin_name, $check)
 {
     // if function or class exists, exit silently (already loaded)
     if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false))) {
         return true;
     }
     if (!preg_match('#^smarty_((internal)|([^_]+))_(.+)$#i', $plugin_name, $match)) {
         throw new SmartyException("plugin {$plugin_name} is not a valid name format");
     }
     if (!empty($match[2])) {
         $file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php';
         if (isset($smarty->_is_file_cache[$file])) {
             if ($smarty->_is_file_cache[$file] !== false) {
                 return $smarty->_is_file_cache[$file];
             } else {
                 return false;
             }
         } else {
             if (is_file($file)) {
                 $smarty->_is_file_cache[$file] = $file;
                 require_once $file;
                 return $file;
             } else {
                 $smarty->_is_file_cache[$file] = false;
                 return false;
             }
         }
     }
     // plugin filename is expected to be: [type].[name].php
     $_plugin_filename = "{$match[1]}.{$match[4]}.php";
     $_lower_filename = strtolower($_plugin_filename);
     $_different = $_lower_filename != $_plugin_filename;
     // loop through plugin dirs and find the plugin
     $names = array();
     foreach ($smarty->getPluginsDir() as $_plugin_dir) {
         $names[] = $_plugin_dir . $_plugin_filename;
         if ($_different) {
             $names[] = $_plugin_dir . $_lower_filename;
         }
     }
     foreach ($names as $path) {
         $file = $smarty->use_include_path ? $smarty->_realpath($path, false) : $path;
         if (isset($smarty->_is_file_cache[$file])) {
             if ($smarty->_is_file_cache[$file] !== false) {
                 return $smarty->_is_file_cache[$file];
             }
         }
         if (is_file($file)) {
             $smarty->_is_file_cache[$file] = $file;
             require_once $file;
             return $file;
         }
         $smarty->_is_file_cache[$file] = false;
     }
     if ($smarty->use_include_path) {
         // try PHP include_path
         $path = Smarty_Internal_Get_Include_Path::getIncludePath($names, null, $smarty);
         if ($path !== false) {
             $smarty->_is_file_cache[$path] = $path;
             require_once $path;
             return $path;
         }
     }
     // no plugin loaded
     return false;
 }
开发者ID:sallency,项目名称:smarty,代码行数:78,代码来源:smarty_internal_extension_loadplugin.php


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