upgraded smarty version
[openemr.git] / vendor / smarty / smarty / libs / internals / core.assemble_plugin_filepath.php
blob22c02483fcd23f8eaceec426c5b43e763feb0355
1 <?php
2 /**
3 * Smarty plugin
4 * @package Smarty
5 * @subpackage plugins
6 */
8 /**
9 * assemble filepath of requested plugin
11 * @param string $type
12 * @param string $name
13 * @return string|false
15 function smarty_core_assemble_plugin_filepath($params, &$smarty)
17 $_plugin_filename = $params['type'] . '.' . $params['name'] . '.php';
18 if (isset($smarty->_filepaths_cache[$_plugin_filename])) {
19 return $smarty->_filepaths_cache[$_plugin_filename];
21 $_return = false;
23 foreach ((array)$smarty->plugins_dir as $_plugin_dir) {
25 $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
27 // see if path is relative
28 if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $_plugin_dir)) {
29 $_relative_paths[] = $_plugin_dir;
30 // relative path, see if it is in the SMARTY_DIR
31 if (@is_readable(SMARTY_DIR . $_plugin_filepath)) {
32 $_return = SMARTY_DIR . $_plugin_filepath;
33 break;
36 // try relative to cwd (or absolute)
37 if (@is_readable($_plugin_filepath)) {
38 $_return = $_plugin_filepath;
39 break;
43 if($_return === false) {
44 // still not found, try PHP include_path
45 if(isset($_relative_paths)) {
46 foreach ((array)$_relative_paths as $_plugin_dir) {
48 $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
50 $_params = array('file_path' => $_plugin_filepath);
51 require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
52 if(smarty_core_get_include_path($_params, $smarty)) {
53 $_return = $_params['new_file_path'];
54 break;
59 $smarty->_filepaths_cache[$_plugin_filename] = $_return;
60 return $_return;
63 /* vim: set expandtab: */