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


PHP Smarty_Internal_Get_Include_Path::getIncludePath方法代码示例

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


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

示例1: 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;
     }
     // Plugin name is expected to be: Smarty_[Type]_[Name]
     $_name_parts = explode('_', $plugin_name, 3);
     // class name must have three parts to be valid plugin
     // count($_name_parts) < 3 === !isset($_name_parts[2])
     if (!isset($_name_parts[2]) || strtolower($_name_parts[0]) !== 'smarty') {
         throw new SmartyException("plugin {$plugin_name} is not a valid name format");
     }
     // if type is "internal", get plugin from sysplugins
     if (strtolower($_name_parts[1]) == 'internal') {
         $file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php';
         if (isset($smarty->_is_file_cache[$file]) ? $smarty->_is_file_cache[$file] : ($smarty->_is_file_cache[$file] = is_file($file))) {
             require_once $file;
             return $file;
         } else {
             return false;
         }
     }
     // plugin filename is expected to be: [type].[name].php
     $_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php";
     // loop through plugin dirs and find the plugin
     foreach ($smarty->getPluginsDir() as $_plugin_dir) {
         $names = array($_plugin_dir . $_plugin_filename, $_plugin_dir . strtolower($_plugin_filename));
         foreach ($names as $file) {
             if (isset($smarty->_is_file_cache[$file]) ? $smarty->_is_file_cache[$file] : ($smarty->_is_file_cache[$file] = is_file($file))) {
                 require_once $file;
                 return $file;
             }
             if ($smarty->use_include_path && !preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $_plugin_dir)) {
                 // try PHP include_path
                 $file = Smarty_Internal_Get_Include_Path::getIncludePath($file);
                 if ($file !== false) {
                     require_once $file;
                     return $file;
                 }
             }
         }
     }
     // no plugin loaded
     return false;
 }
开发者ID:Roosso,项目名称:smarty,代码行数:58,代码来源:smarty_internal_extension_loadplugin.php

示例2: buildFilepath

 /**
  * build template filepath by traversing the template_dir array
  *
  * @param Smarty_Template_Source    $source    source object
  * @param  Smarty_Internal_Template $_template template object
  *
  * @return string fully qualified filepath
  * @throws SmartyException
  */
 protected function buildFilepath(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
 {
     $file = $source->name;
     // absolute file ?
     if ($file[0] == '/' || $file[1] == ':') {
         $file = $source->smarty->_realpath($file);
         return is_file($file) ? $file : false;
     }
     // go relative to a given template?
     if ($file[0] == '.' && $_template && $_template->parent instanceof Smarty_Internal_Template && preg_match('#^[.]{1,2}[\\\\/]#', $file)) {
         if ($_template->parent->source->type != 'file' && $_template->parent->source->type != 'extends' && !$_template->parent->allow_relative_path) {
             throw new SmartyException("Template '{$file}' cannot be relative to template of resource type '{$_template->parent->source->type}'");
         }
         $path = dirname($_template->parent->source->filepath) . DS . $file;
         // normalize path
         $path = $source->smarty->_realpath($path);
         // files relative to a template only get one shot
         return is_file($path) ? $path : false;
     }
     $_directories = $source->smarty->getTemplateDir(null, $source->isConfig);
     // template_dir index?
     if ($file[0] == '[' && preg_match('#^\\[([^\\]]+)\\](.+)$#', $file, $fileMatch)) {
         $index = $fileMatch[1];
         $_directory = null;
         // try string indexes
         if (isset($_directories[$index])) {
             $_directory = $_directories[$index];
         } elseif (is_numeric($index)) {
             // try numeric index
             $index = (int) $index;
             if (isset($_directories[$index])) {
                 $_directory = $_directories[$index];
             } else {
                 // try at location index
                 $keys = array_keys($_directories);
                 $_directory = $_directories[$keys[$index]];
             }
         }
         if ($_directory) {
             $path = $_directory . $fileMatch[2];
             $path = $source->smarty->_realpath($path);
             if (is_file($path)) {
                 return $path;
             }
         } else {
             // index not found
             return false;
         }
     }
     // relative file name?
     foreach ($_directories as $_directory) {
         $path = $_directory . $file;
         if (is_file($path)) {
             return $source->smarty->_realpath($path);
         }
     }
     // Could be relative to cwd
     $path = $source->smarty->_realpath($file);
     if (is_file($path)) {
         return $path;
     }
     // Use include path ?
     if ($source->smarty->use_include_path) {
         return Smarty_Internal_Get_Include_Path::getIncludePath($_directories, $file, $source->smarty);
     }
     return false;
 }
开发者ID:RafaelFar,项目名称:CodeIgniter-HMVC-SMARTY-DOCTRINE-BOOTSTRAP,代码行数:76,代码来源:smarty_internal_resource_file.php

示例3: buildFilepath


//.........这里部分代码省略.........
         // don't we all just love windows?
         $_path = str_replace('\\', '/', $file);
     }
     $_path = $this->normalizePath($_path, false);
     if (DS != '/') {
         // don't we all just love windows?
         $_path = str_replace('/', '\\', $_path);
     }
     // revert to relative
     if (isset($_was_relative)) {
         if (isset($_was_relative_prefix)) {
             $_path = $_was_relative_prefix . $_path;
         } else {
             $_path = substr($_path, 1);
         }
     }
     // this is only required for directories
     $file = rtrim($_path, '/\\');
     // files relative to a template only get one shot
     if (isset($_file_exact_match)) {
         return $this->fileExists($source, $file) ? $file : false;
     }
     // template_dir index?
     if (preg_match('#^\\[(?P<key>[^\\]]+)\\](?P<file>.+)$#', $file, $match)) {
         $_directory = null;
         // try string indexes
         if (isset($_directories[$match['key']])) {
             $_directory = $_directories[$match['key']];
         } else {
             if (is_numeric($match['key'])) {
                 // try numeric index
                 $match['key'] = (int) $match['key'];
                 if (isset($_directories[$match['key']])) {
                     $_directory = $_directories[$match['key']];
                 } else {
                     // try at location index
                     $keys = array_keys($_directories);
                     $_directory = $_directories[$keys[$match['key']]];
                 }
             }
         }
         if ($_directory) {
             $_file = substr($file, strpos($file, ']') + 1);
             $_filepath = $_directory . $_file;
             if ($this->fileExists($source, $_filepath)) {
                 return $_filepath;
             }
         }
     }
     $_stream_resolve_include_path = function_exists('stream_resolve_include_path');
     // relative file name?
     if (!preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $file)) {
         foreach ($_directories as $_directory) {
             $_filepath = $_directory . $file;
             if ($this->fileExists($source, $_filepath)) {
                 return $this->normalizePath($_filepath);
             }
             if ($source->smarty->use_include_path && !preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $_directory)) {
                 // try PHP include_path
                 if ($_stream_resolve_include_path) {
                     $_filepath = stream_resolve_include_path($_filepath);
                 } else {
                     $_filepath = Smarty_Internal_Get_Include_Path::getIncludePath($_filepath);
                 }
                 if ($_filepath !== false) {
                     if ($this->fileExists($source, $_filepath)) {
                         return $this->normalizePath($_filepath);
                     }
                 }
             }
         }
     }
     // try absolute filepath
     if ($this->fileExists($source, $file)) {
         return $file;
     }
     // no tpl file found
     if ($_default_handler) {
         if (!is_callable($_default_handler)) {
             if ($source instanceof Smarty_Config_Source) {
                 throw new SmartyException("Default config handler not callable");
             } else {
                 throw new SmartyException("Default template handler not callable");
             }
         }
         $_return = call_user_func_array($_default_handler, array($source->type, $source->name, &$_content, &$_timestamp, $source->smarty));
         if (is_string($_return)) {
             $source->timestamp = @filemtime($_return);
             $source->exists = !!$source->timestamp;
             return $_return;
         } elseif ($_return === true) {
             $source->content = $_content;
             $source->timestamp = $_timestamp;
             $source->exists = true;
             return $_filepath;
         }
     }
     // give up
     return false;
 }
开发者ID:shaoyi88,项目名称:admin_template,代码行数:101,代码来源:smarty_resource.php

示例4: testInstall

 /**
  * diagnose Smarty setup
  * If $errors is secified, the diagnostic report will be appended to the array, rather than being output.
  *
  * @param  Smarty $smarty Smarty instance to test
  * @param  array  $errors array to push results into rather than outputting them
  *
  * @return bool   status, true if everything is fine, false else
  */
 public static function testInstall(Smarty $smarty, &$errors = null)
 {
     $status = true;
     if ($errors === null) {
         echo "<PRE>\n";
         echo "Smarty Installation test...\n";
         echo "Testing template directory...\n";
     }
     $_stream_resolve_include_path = function_exists('stream_resolve_include_path');
     // test if all registered template_dir are accessible
     foreach ($smarty->getTemplateDir() as $template_dir) {
         $_template_dir = $template_dir;
         $template_dir = realpath($template_dir);
         // resolve include_path or fail existence
         if (!$template_dir) {
             if ($smarty->use_include_path && !preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $_template_dir)) {
                 // try PHP include_path
                 if ($_stream_resolve_include_path) {
                     $template_dir = stream_resolve_include_path($_template_dir);
                 } else {
                     $template_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_template_dir);
                 }
                 if ($template_dir !== false) {
                     if ($errors === null) {
                         echo "{$template_dir} is OK.\n";
                     }
                     continue;
                 } else {
                     $status = false;
                     $message = "FAILED: {$_template_dir} does not exist (and couldn't be found in include_path either)";
                     if ($errors === null) {
                         echo $message . ".\n";
                     } else {
                         $errors['template_dir'] = $message;
                     }
                     continue;
                 }
             } else {
                 $status = false;
                 $message = "FAILED: {$_template_dir} does not exist";
                 if ($errors === null) {
                     echo $message . ".\n";
                 } else {
                     $errors['template_dir'] = $message;
                 }
                 continue;
             }
         }
         if (!is_dir($template_dir)) {
             $status = false;
             $message = "FAILED: {$template_dir} is not a directory";
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['template_dir'] = $message;
             }
         } elseif (!is_readable($template_dir)) {
             $status = false;
             $message = "FAILED: {$template_dir} is not readable";
             if ($errors === null) {
                 echo $message . ".\n";
             } else {
                 $errors['template_dir'] = $message;
             }
         } else {
             if ($errors === null) {
                 echo "{$template_dir} is OK.\n";
             }
         }
     }
     if ($errors === null) {
         echo "Testing compile directory...\n";
     }
     // test if registered compile_dir is accessible
     $__compile_dir = $smarty->getCompileDir();
     $_compile_dir = realpath($__compile_dir);
     if (!$_compile_dir) {
         $status = false;
         $message = "FAILED: {$__compile_dir} does not exist";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['compile_dir'] = $message;
         }
     } elseif (!is_dir($_compile_dir)) {
         $status = false;
         $message = "FAILED: {$_compile_dir} is not a directory";
         if ($errors === null) {
             echo $message . ".\n";
         } else {
             $errors['compile_dir'] = $message;
//.........这里部分代码省略.........
开发者ID:Geo-Developers,项目名称:geo-developers-site,代码行数:101,代码来源:smarty_internal_utility.php

示例5: buildTemplateFilepath

 /**
  * get system filepath to template
  */
 public function buildTemplateFilepath($file = null)
 {
     if ($file == null) {
         $file = $this->resource_name;
     }
     // relative file name?
     if (!preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $file)) {
         foreach ((array) $this->smarty->template_dir as $_template_dir) {
             if (strpos('/\\', substr($_template_dir, -1)) === false) {
                 $_template_dir .= DS;
             }
             $_filepath = $_template_dir . $file;
             if (file_exists($_filepath)) {
                 return $_filepath;
             }
             if (!preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $_template_dir)) {
                 // try PHP include_path
                 if (($_filepath = Smarty_Internal_Get_Include_Path::getIncludePath($_filepath)) !== false) {
                     return $_filepath;
                 }
             }
         }
     }
     // try absolute filepath
     if (file_exists($file)) {
         return $file;
     }
     // no tpl file found
     if (!empty($this->smarty->default_template_handler_func)) {
         if (!is_callable($this->smarty->default_template_handler_func)) {
             throw new SmartyException("Default template handler not callable");
         } else {
             $_return = call_user_func_array($this->smarty->default_template_handler_func, array($this->resource_type, $this->resource_name, &$this->template_source, &$this->template_timestamp, $this));
             if (is_string($_return)) {
                 return $_return;
             } elseif ($_return === true) {
                 return $file;
             }
         }
     }
     return false;
 }
开发者ID:pawelzielak,项目名称:opencaching-pl,代码行数:45,代码来源:smarty_internal_template.php

示例6: buildFilepath

 /**
  * build template filepath by traversing the template_dir array
  *
  * @param Smarty_Template_Source    $source    source object
  * @param  Smarty_Internal_Template $_template template object
  *
  * @return UTF8String fully qualified filepath
  * @throws SmartyException
  */
 protected function buildFilepath(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
 {
     $file = $source->name;
     preg_match('#^(?P<absolute>[\\\\/]|[a-zA-Z]:[\\\\/])|(\\[(?P<index>[^\\]]+)\\])|(?P<rel>\\.[\\\\/])#', $file, $fileMatch);
     // save basename
     if (!empty($fileMatch['absolute'])) {
         $file = $this->normalizePath($file);
         return is_file($file) ? $file : false;
     }
     // go relative to a given template?
     if (!empty($fileMatch['rel']) && $_template && $_template->parent instanceof Smarty_Internal_Template) {
         if ($_template->parent->source->type != 'file' && $_template->parent->source->type != 'extends' && !$_template->parent->allow_relative_path) {
             throw new SmartyException("Template '{$file}' cannot be relative to template of resource type '{$_template->parent->source->type}'");
         }
         $path = dirname($_template->parent->source->filepath) . DS . $file;
         // normalize path
         $path = $this->normalizePath($path);
         // files relative to a template only get one shot
         return is_file($path) ? $path : false;
     }
     if ($source->isConfig) {
         $_directories = $source->smarty->getConfigDir();
     } else {
         $_directories = $source->smarty->getTemplateDir();
     }
     // template_dir index?
     if (!empty($fileMatch['index'])) {
         $index = $fileMatch['index'];
         $_directory = null;
         // try string indexes
         if (isset($_directories[$index])) {
             $_directory = $_directories[$index];
         } elseif (is_numeric($index)) {
             // try numeric index
             $index = (int) $index;
             if (isset($_directories[$index])) {
                 $_directory = $_directories[$index];
             } else {
                 // try at location index
                 $keys = array_keys($_directories);
                 $_directory = $_directories[$keys[$index]];
             }
         }
         if ($_directory) {
             preg_match('#\\](.+)$#', $file, $fileMatch);
             $path = $_directory . $fileMatch[1];
             $path = $this->normalizePath($path);
             if (is_file($path)) {
                 return $path;
             }
         } else {
             // index not found
             return false;
         }
     }
     // relative file name?
     foreach ($_directories as $_directory) {
         $_filepath = $_directory . $file;
         $path = $this->normalizePath($_filepath);
         if (is_file($path)) {
             return $path;
         }
         if ($source->smarty->use_include_path && !preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $_directory)) {
             // try PHP include_path
             if (function_exists('stream_resolve_include_path')) {
                 $_filepath = stream_resolve_include_path($_filepath);
             } else {
                 $_filepath = Smarty_Internal_Get_Include_Path::getIncludePath($_filepath);
             }
             if ($_filepath !== false) {
                 $path = $this->normalizePath($_filepath);
                 if (is_file($path)) {
                     return $path;
                 }
             }
         }
     }
     // Could be relative to cwd
     $path = $this->normalizePath(getcwd() . DS . $file);
     return is_file($path) ? $path : false;
 }
开发者ID:pixelproduction,项目名称:PixelManagerCMS,代码行数:90,代码来源:smarty_internal_resource_file.php

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

示例8: buildFilepath

 protected function buildFilepath(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
 {
     $file = $source->name;
     if ($source instanceof Smarty_Config_Source) {
         $_directories = $source->smarty->getConfigDir();
         $_default_handler = $source->smarty->default_config_handler_func;
     } else {
         $_directories = $source->smarty->getTemplateDir();
         $_default_handler = $source->smarty->default_template_handler_func;
     }
     $_file_is_dotted = $file[0] == '.' && ($file[1] == '.' || $file[1] == '/' || $file[1] == "\\");
     if ($_template && $_template->parent instanceof Smarty_Internal_Template && $_file_is_dotted) {
         if ($_template->parent->source->type != 'file' && $_template->parent->source->type != 'extends' && !$_template->parent->allow_relative_path) {
             throw new SmartyException("Template '{$file}' cannot be relative to template of resource type '{$_template->parent->source->type}'");
         }
         $file = dirname($_template->parent->source->filepath) . DS . $file;
         $_file_exact_match = true;
         if (!preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $file)) {
             $file = getcwd() . DS . $file;
         }
     }
     if (!preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $file)) {
         $_path = DS . trim($file, '/');
         $_was_relative = true;
     } else {
         $_path = str_replace('\\', '/', $file);
     }
     $_path = $this->normalizePath($_path, false);
     if (DS != '/') {
         $_path = str_replace('/', '\\', $_path);
     }
     if (isset($_was_relative)) {
         $_path = substr($_path, 1);
     }
     $file = rtrim($_path, '/\\');
     if (isset($_file_exact_match)) {
         return $this->fileExists($source, $file) ? $file : false;
     }
     if (preg_match('#^\\[(?P<key>[^\\]]+)\\](?P<file>.+)$#', $file, $match)) {
         $_directory = null;
         if (isset($_directories[$match['key']])) {
             $_directory = $_directories[$match['key']];
         } elseif (is_numeric($match['key'])) {
             $match['key'] = (int) $match['key'];
             if (isset($_directories[$match['key']])) {
                 $_directory = $_directories[$match['key']];
             } else {
                 $keys = array_keys($_directories);
                 $_directory = $_directories[$keys[$match['key']]];
             }
         }
         if ($_directory) {
             $_file = substr($file, strpos($file, ']') + 1);
             $_filepath = $_directory . $_file;
             if ($this->fileExists($source, $_filepath)) {
                 return $_filepath;
             }
         }
     }
     $_stream_resolve_include_path = function_exists('stream_resolve_include_path');
     if (!preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $file)) {
         foreach ($_directories as $_directory) {
             $_filepath = $_directory . $file;
             if ($this->fileExists($source, $_filepath)) {
                 return $this->normalizePath($_filepath);
             }
             if ($source->smarty->use_include_path && !preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $_directory)) {
                 if ($_stream_resolve_include_path) {
                     $_filepath = stream_resolve_include_path($_filepath);
                 } else {
                     $_filepath = Smarty_Internal_Get_Include_Path::getIncludePath($_filepath);
                 }
                 if ($_filepath !== false) {
                     if ($this->fileExists($source, $_filepath)) {
                         return $this->normalizePath($_filepath);
                     }
                 }
             }
         }
     }
     if ($this->fileExists($source, $file)) {
         return $file;
     }
     if ($_default_handler) {
         if (!is_callable($_default_handler)) {
             if ($source instanceof Smarty_Config_Source) {
                 throw new SmartyException("Default config handler not callable");
             } else {
                 throw new SmartyException("Default template handler not callable");
             }
         }
         $_return = call_user_func_array($_default_handler, array($source->type, $source->name, &$_content, &$_timestamp, $source->smarty));
         if (is_string($_return)) {
             $source->timestamp = file_exists($_return) ? filemtime($_return) : 0;
             $source->exists = !!$source->timestamp;
             return $_return;
         } elseif ($_return === true) {
             $source->content = $_content;
             $source->timestamp = $_timestamp;
             $source->exists = true;
//.........这里部分代码省略.........
开发者ID:admpub,项目名称:MicroPHP,代码行数:101,代码来源:~Runtime.php

示例9: buildFilepath

 /**
  * build template filepath by traversing the template_dir array
  *
  * @param Smarty_Template_Source    $source    source object
  * @param  Smarty_Internal_Template $_template template object
  *
  * @return string fully qualified filepath
  * @throws SmartyException
  */
 protected function buildFilepath(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
 {
     $file = str_replace(array('\\', '/./'), '/', $source->name);
     if ($source->isConfig) {
         $_directories = $source->smarty->getConfigDir();
     } else {
         $_directories = $source->smarty->getTemplateDir();
     }
     preg_match('#^((?P<absolute>[\\/]|[a-zA-Z]:[\\/])|(\\[(?P<index>[^\\]]+)\\])|((?P<rel1>\\.[\\/])?(?P<rel2>(\\.\\.[\\/])*))|(?P<skip>[\\/]))?(?P<file>.+)$#', $file, $fileMatch);
     // save basename
     if (!empty($fileMatch['absolute'])) {
         return is_file($file) ? $file : false;
     }
     // go relative to a given template?
     if ($_template && $_template->parent instanceof Smarty_Internal_Template && (!empty($fileMatch['rel1']) || !empty($fileMatch['rel2']))) {
         if ($_template->parent->source->type != 'file' && $_template->parent->source->type != 'extends' && !$_template->parent->allow_relative_path) {
             throw new SmartyException("Template '{$file}' cannot be relative to template of resource type '{$_template->parent->source->type}'");
         }
         $path = dirname($_template->parent->source->filepath);
         if (!preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $path)) {
             // the path gained from the parent template is relative to the current working directory
             // as expansions (like include_path) have already been done
             $path = str_replace('\\', '/', getcwd()) . '/' . $path;
         }
         // normalize path
         $path = str_replace(array('\\', './'), array('/', ''), $path);
         // simple relative
         if (!empty($fileMatch['rel1'])) {
             $file = $path . '/' . $fileMatch['file'];
         } else {
             for ($i = 1; $i <= substr_count($fileMatch['rel2'], '../'); $i++) {
                 $path = substr($path, 0, strrpos($path, '/'));
             }
             $file = $path . '/' . $fileMatch['file'];
         }
         // files relative to a template only get one shot
         return is_file($file) ? $file : false;
     }
     $_filepath = null;
     // template_dir index?
     if (!empty($fileMatch['index'])) {
         $index = $fileMatch['index'];
         $_directory = null;
         // try string indexes
         if (isset($_directories[$index])) {
             $_directory = $_directories[$index];
         } elseif (is_numeric($index)) {
             // try numeric index
             $index = (int) $index;
             if (isset($_directories[$index])) {
                 $_directory = $_directories[$index];
             } else {
                 // try at location index
                 $keys = array_keys($_directories);
                 $_directory = $_directories[$keys[$index]];
             }
         }
         if ($_directory) {
             $_filepath = $_directory . $fileMatch['file'];
             if (is_file($_filepath)) {
                 return $_filepath;
             }
         }
     }
     // relative file name?
     foreach ($_directories as $_directory) {
         if (empty($fileMatch['rel2'])) {
             $_filepath = $_directory . $fileMatch['file'];
         } else {
             if (false === strpos($_directory, '..')) {
                 for ($i = 1; $i <= substr_count($fileMatch['rel2'], '../') + 1; $i++) {
                     $_directory = substr($_directory, 0, strrpos($_directory, '/'));
                 }
                 $_filepath = $_directory . '/' . $fileMatch['file'];
             } else {
                 $_filepath = $_directory . $file;
             }
         }
         if (is_file($_filepath)) {
             return $_filepath;
         }
         if ($source->smarty->use_include_path && !preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $_directory)) {
             // try PHP include_path
             if (function_exists('stream_resolve_include_path')) {
                 $_filepath = stream_resolve_include_path($_filepath);
             } else {
                 $_filepath = Smarty_Internal_Get_Include_Path::getIncludePath($_filepath);
             }
             if ($_filepath !== false) {
                 if (is_file($_filepath)) {
                     return $_filepath;
//.........这里部分代码省略.........
开发者ID:uwetews,项目名称:smarty-hhvm,代码行数:101,代码来源:smarty_internal_resource_file.php

示例10: buildFilepath


//.........这里部分代码省略.........
         $_parent = strpos($_path, '/../');
         if ($_parent === false) {
             break;
         } else {
             if ($_parent === 0) {
                 $_path = substr($_path, 3);
                 break;
             }
         }
         $_pos = strrpos($_path, '/', $_parent - strlen($_path) - 1);
         if ($_pos === false) {
             // don't we all just love windows?
             $_pos = $_parent;
         }
         $_path = substr_replace($_path, '', $_pos, $_parent + 3 - $_pos);
     }
     if (DS != '/') {
         // don't we all just love windows?
         $_path = str_replace('/', '\\', $_path);
     }
     // revert to relative
     if (isset($_was_relative)) {
         $_path = substr($_path, 1);
     }
     // this is only required for directories
     $file = rtrim($_path, '/\\');
     // files relative to a template only get one shot
     if (isset($_file_exact_match)) {
         return file_exists($file) ? $file : false;
     }
     // template_dir index?
     if (preg_match('#^\\[(?<key>[^\\]]+)\\](?<file>.+)$#', $file, $match)) {
         if ($match['file'][0] == '.' && ($match['file'][1] == '.' || $match['file'][1] == '/' || $match['file'][1] == "\\")) {
             throw new SmartyException("Template '{$match['file']}' may not start with ../ or ./'");
         }
         $_directory = null;
         // try string indexes
         if (isset($_directories[$match['key']])) {
             $_directory = $_directories[$match['key']];
         } else {
             if (is_numeric($match['key'])) {
                 // try numeric index
                 $match['key'] = (int) $match['key'];
                 if (isset($_directories[$match['key']])) {
                     $_directory = $_directories[$match['key']];
                 } else {
                     // try at location index
                     $keys = array_keys($_directories);
                     $_directory = $_directories[$keys[$match['key']]];
                 }
             }
         }
         if ($_directory) {
             $_file = substr($file, strpos($file, ']') + 1);
             $_filepath = $_directory . $_file;
             if (file_exists($_filepath)) {
                 return $_filepath;
             }
         }
     }
     // relative file name?
     if (!preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $file)) {
         foreach ($_directories as $_directory) {
             $_filepath = $_directory . $file;
             if (file_exists($_filepath)) {
                 return $_filepath;
             }
             if ($source->smarty->use_include_path && !preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $_directory)) {
                 // try PHP include_path
                 if (($_filepath = Smarty_Internal_Get_Include_Path::getIncludePath($_filepath)) !== false) {
                     return $_filepath;
                 }
             }
         }
     }
     // try absolute filepath
     if (file_exists($file)) {
         return $file;
     }
     // no tpl file found
     if ($_default_handler) {
         if (!is_callable($_default_handler)) {
             if ($source instanceof Smarty_Config_Source) {
                 throw new SmartyException("Default config handler not callable");
             } else {
                 throw new SmartyException("Default template handler not callable");
             }
         }
         $_return = call_user_func_array($_default_handler, array($source->type, $source->name, &$_content, &$_timestamp, $source->smarty));
         if (is_string($_return)) {
             return $_return;
         } elseif ($_return === true) {
             $source->content = $_content;
             $source->timestamp = $_timestamp;
             return $_filepath;
         }
     }
     // give up
     return false;
 }
开发者ID:iLoiLohas,项目名称:pinchshopper,代码行数:101,代码来源:smarty_resource.php

示例11: loadPlugin

 public function loadPlugin($plugin_name, $check = true)
 {
     if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false))) {
         return true;
     }
     $_name_parts = explode('_', $plugin_name, 3);
     if (!isset($_name_parts[2]) || strtolower($_name_parts[0]) !== 'smarty') {
         throw new SmartyException("plugin {$plugin_name} is not a valid name format");
         return false;
     }
     if (strtolower($_name_parts[1]) == 'internal') {
         $file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php';
         if (file_exists($file)) {
             require_once $file;
             return $file;
         } else {
             return false;
         }
     }
     $_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php";
     $_stream_resolve_include_path = function_exists('stream_resolve_include_path');
     foreach ($this->getPluginsDir() as $_plugin_dir) {
         $names = array($_plugin_dir . $_plugin_filename, $_plugin_dir . strtolower($_plugin_filename));
         foreach ($names as $file) {
             if (file_exists($file)) {
                 require_once $file;
                 return $file;
             }
             if ($this->use_include_path && !preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $_plugin_dir)) {
                 if ($_stream_resolve_include_path) {
                     $file = stream_resolve_include_path($file);
                 } else {
                     $file = Smarty_Internal_Get_Include_Path::getIncludePath($file);
                 }
                 if ($file !== false) {
                     require_once $file;
                     return $file;
                 }
             }
         }
     }
     return false;
 }
开发者ID:EfncoPlugins,项目名称:web-portal-lite-client-portal-secure-file-sharing-private-messaging,代码行数:43,代码来源:smarty.class.php

示例12: buildFilepath

 /**
  * build template filepath by traversing the template_dir array
  *
  * @param Smarty_Template_Source    $source    source object
  * @param  Smarty_Internal_Template $_template template object
  *
  * @return string fully qualified filepath
  * @throws SmartyException
  */
 protected function buildFilepath(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
 {
     $file = $source->name;
     // absolute file ?
     if ($file[0] == '/' || $file[1] == ':') {
         $file = $source->smarty->_realpath($file, true);
         return is_file($file) ? $file : false;
     }
     // go relative to a given template?
     if ($file[0] == '.' && $_template && isset($_template->parent) && $_template->parent->_objType == 2 && preg_match('#^[.]{1,2}[\\\\/]#', $file)) {
         if ($_template->parent->source->type != 'file' && $_template->parent->source->type != 'extends' && !isset($_template->parent->_cache['allow_relative_path'])) {
             throw new SmartyException("Template '{$file}' cannot be relative to template of resource type '{$_template->parent->source->type}'");
         }
         $path = dirname($_template->parent->source->filepath) . DS . $file;
         // normalize path
         $path = $source->smarty->_realpath($path);
         // files relative to a template only get one shot
         return is_file($path) ? $path : false;
     }
     // normalize DS
     if (strpos($file, DS == '/' ? '\\' : '/') !== false) {
         $file = str_replace(DS == '/' ? '\\' : '/', DS, $file);
     }
     $_directories = $source->smarty->getTemplateDir(null, $source->isConfig);
     // template_dir index?
     if ($file[0] == '[' && preg_match('#^\\[([^\\]]+)\\](.+)$#', $file, $fileMatch)) {
         $file = $fileMatch[2];
         $_indices = explode(',', $fileMatch[1]);
         $_index_dirs = array();
         foreach ($_indices as $index) {
             $index = trim($index);
             // try string indexes
             if (isset($_directories[$index])) {
                 $_index_dirs[] = $_directories[$index];
             } elseif (is_numeric($index)) {
                 // try numeric index
                 $index = (int) $index;
                 if (isset($_directories[$index])) {
                     $_index_dirs[] = $_directories[$index];
                 } else {
                     // try at location index
                     $keys = array_keys($_directories);
                     if (isset($_directories[$keys[$index]])) {
                         $_index_dirs[] = $_directories[$keys[$index]];
                     }
                 }
             }
         }
         if (empty($_index_dirs)) {
             // index not found
             return false;
         } else {
             $_directories = $_index_dirs;
         }
     }
     // relative file name?
     foreach ($_directories as $_directory) {
         $path = $_directory . $file;
         if (is_file($path)) {
             return strpos($path, '.' . DS) !== false ? $source->smarty->_realpath($path) : $path;
         }
     }
     if (!isset($_index_dirs)) {
         // Could be relative to cwd
         $path = $source->smarty->_realpath($file, true);
         if (is_file($path)) {
             return $path;
         }
     }
     // Use include path ?
     if ($source->smarty->use_include_path) {
         return Smarty_Internal_Get_Include_Path::getIncludePath($_directories, $file, $source->smarty);
     }
     return false;
 }
开发者ID:rockflying,项目名称:smarty,代码行数:84,代码来源:smarty_internal_resource_file.php

示例13: loadPlugin

 /**
 * Takes unknown classes and loads plugin files for them
 * class name format: Smarty_PluginType_PluginName
 * plugin filename format: plugintype.pluginname.php
 *
 * @param string $plugin_name    class plugin name to load
 * @param bool   $check          check if already loaded
 * @return string |boolean filepath of loaded file or false
 */
 public function loadPlugin($plugin_name, $check = true)
 {
     // if function or class exists, exit silently (already loaded)
     if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false)))
         return true;
     // Plugin name is expected to be: Smarty_[Type]_[Name]
     $_plugin_name = strtolower($plugin_name);
     $_name_parts = explode('_', $_plugin_name, 3);
     // class name must have three parts to be valid plugin
     if (count($_name_parts) < 3 || $_name_parts[0] !== 'smarty') {
         throw new SmartyException("plugin {$plugin_name} is not a valid name format");
         return false;
     }
     // if type is "internal", get plugin from sysplugins
     if ($_name_parts[1] == 'internal') {
         $file = SMARTY_SYSPLUGINS_DIR . $_plugin_name . '.php';
         if (file_exists($file)) {
             require_once($file);
             return $file;
         } else {
             return false;
         }
     }
     // plugin filename is expected to be: [type].[name].php
     $_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php";
     // loop through plugin dirs and find the plugin
     foreach($this->getPluginsDir() as $_plugin_dir) {
         $file = $_plugin_dir . $_plugin_filename;
         if (file_exists($file)) {
             require_once($file);
             return $file;
         }
         if ($this->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) {
             // try PHP include_path
             if (($file = Smarty_Internal_Get_Include_Path::getIncludePath($file)) !== false) {
                 require_once($file);
                 return $file;
             }
         }
     }
     // no plugin loaded
     return false;
 }
开发者ID:9px,项目名称:BookShare,代码行数:52,代码来源:Smarty.class.php


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