diff options
author | rvelices <rv-github@modusoptimus.com> | 2008-02-27 02:31:51 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2008-02-27 02:31:51 +0000 |
commit | 75bb450a6ece6b2e30ad4c148083b7192d7d7224 (patch) | |
tree | 6b3e6c0da5baa7ba7e736e79a4b49a83918f25c9 /include/smarty/libs/internals/core.assemble_plugin_filepath.php | |
parent | 01687607ec04f32ca03370456c112b64f66ca599 (diff) |
- first smarty use ... (in admin.php and admin plugins page)
git-svn-id: http://piwigo.org/svn/trunk@2216 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/smarty/libs/internals/core.assemble_plugin_filepath.php')
-rw-r--r-- | include/smarty/libs/internals/core.assemble_plugin_filepath.php | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/include/smarty/libs/internals/core.assemble_plugin_filepath.php b/include/smarty/libs/internals/core.assemble_plugin_filepath.php new file mode 100644 index 000000000..690d3ddbc --- /dev/null +++ b/include/smarty/libs/internals/core.assemble_plugin_filepath.php @@ -0,0 +1,67 @@ +<?php +/** + * Smarty plugin + * @package Smarty + * @subpackage plugins + */ + +/** + * assemble filepath of requested plugin + * + * @param string $type + * @param string $name + * @return string|false + */ +function smarty_core_assemble_plugin_filepath($params, &$smarty) +{ + static $_filepaths_cache = array(); + + $_plugin_filename = $params['type'] . '.' . $params['name'] . '.php'; + if (isset($_filepaths_cache[$_plugin_filename])) { + return $_filepaths_cache[$_plugin_filename]; + } + $_return = false; + + foreach ((array)$smarty->plugins_dir as $_plugin_dir) { + + $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; + + // see if path is relative + if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $_plugin_dir)) { + $_relative_paths[] = $_plugin_dir; + // relative path, see if it is in the SMARTY_DIR + if (@is_readable(SMARTY_DIR . $_plugin_filepath)) { + $_return = SMARTY_DIR . $_plugin_filepath; + break; + } + } + // try relative to cwd (or absolute) + if (@is_readable($_plugin_filepath)) { + $_return = $_plugin_filepath; + break; + } + } + + if($_return === false) { + // still not found, try PHP include_path + if(isset($_relative_paths)) { + foreach ((array)$_relative_paths as $_plugin_dir) { + + $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; + + $_params = array('file_path' => $_plugin_filepath); + require_once(SMARTY_CORE_DIR . 'core.get_include_path.php'); + if(smarty_core_get_include_path($_params, $smarty)) { + $_return = $_params['new_file_path']; + break; + } + } + } + } + $_filepaths_cache[$_plugin_filename] = $_return; + return $_return; +} + +/* vim: set expandtab: */ + +?> |