|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
/**
|
|
Chris PeBenito |
696b41 |
* Smarty plugin
|
|
Chris PeBenito |
696b41 |
* @package Smarty
|
|
Chris PeBenito |
696b41 |
* @subpackage plugins
|
|
Chris PeBenito |
696b41 |
*/
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
/**
|
|
Chris PeBenito |
696b41 |
* assemble filepath of requested plugin
|
|
Chris PeBenito |
696b41 |
*
|
|
Chris PeBenito |
696b41 |
* @param string $type
|
|
Chris PeBenito |
696b41 |
* @param string $name
|
|
Chris PeBenito |
696b41 |
* @return string|false
|
|
Chris PeBenito |
696b41 |
*/
|
|
Chris PeBenito |
696b41 |
function smarty_core_assemble_plugin_filepath($params, &$smarty)
|
|
Chris PeBenito |
696b41 |
{
|
|
Chris PeBenito |
696b41 |
static $_filepaths_cache = array();
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
$_plugin_filename = $params['type'] . '.' . $params['name'] . '.php';
|
|
Chris PeBenito |
696b41 |
if (isset($_filepaths_cache[$_plugin_filename])) {
|
|
Chris PeBenito |
696b41 |
return $_filepaths_cache[$_plugin_filename];
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
$_return = false;
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
foreach ((array)$smarty->plugins_dir as $_plugin_dir) {
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
$_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
// see if path is relative
|
|
Chris PeBenito |
696b41 |
if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $_plugin_dir)) {
|
|
Chris PeBenito |
696b41 |
$_relative_paths[] = $_plugin_dir;
|
|
Chris PeBenito |
696b41 |
// relative path, see if it is in the SMARTY_DIR
|
|
Chris PeBenito |
696b41 |
if (@is_readable(SMARTY_DIR . $_plugin_filepath)) {
|
|
Chris PeBenito |
696b41 |
$_return = SMARTY_DIR . $_plugin_filepath;
|
|
Chris PeBenito |
696b41 |
break;
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
// try relative to cwd (or absolute)
|
|
Chris PeBenito |
696b41 |
if (@is_readable($_plugin_filepath)) {
|
|
Chris PeBenito |
696b41 |
$_return = $_plugin_filepath;
|
|
Chris PeBenito |
696b41 |
break;
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
if($_return === false) {
|
|
Chris PeBenito |
696b41 |
// still not found, try PHP include_path
|
|
Chris PeBenito |
696b41 |
if(isset($_relative_paths)) {
|
|
Chris PeBenito |
696b41 |
foreach ((array)$_relative_paths as $_plugin_dir) {
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
$_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
$_params = array('file_path' => $_plugin_filepath);
|
|
Chris PeBenito |
696b41 |
require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
|
|
Chris PeBenito |
696b41 |
if(smarty_core_get_include_path($_params, $smarty)) {
|
|
Chris PeBenito |
696b41 |
$_return = $_params['new_file_path'];
|
|
Chris PeBenito |
696b41 |
break;
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
$_filepaths_cache[$_plugin_filename] = $_return;
|
|
Chris PeBenito |
696b41 |
return $_return;
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
/* vim: set expandtab: */
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
?>
|