Commit | Line | Data |
---|---|---|
e586807d H |
1 | <?php |
2 | /** | |
3 | * Smarty plugin | |
4 | * @package Smarty | |
5 | * @subpackage plugins | |
6 | */ | |
7 | ||
8 | /** | |
9 | * assemble filepath of requested plugin | |
10 | * | |
11 | * @param string $type | |
12 | * @param string $name | |
13 | * @return string|false | |
14 | */ | |
15 | function smarty_core_assemble_plugin_filepath($params, &$smarty) | |
16 | { | |
17 | ||
18 | $_plugin_filename = $params['type'] . '.' . $params['name'] . '.php'; | |
19 | $_return = false; | |
20 | ||
21 | foreach ((array)$smarty->plugins_dir as $_plugin_dir) { | |
22 | ||
23 | $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; | |
24 | ||
25 | // see if path is relative | |
26 | if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $_plugin_dir)) { | |
27 | $_relative_paths[] = $_plugin_dir; | |
28 | // relative path, see if it is in the SMARTY_DIR | |
29 | if (@is_readable(SMARTY_DIR . $_plugin_filepath)) { | |
30 | $_return = SMARTY_DIR . $_plugin_filepath; | |
31 | break; | |
32 | } | |
33 | } | |
34 | // try relative to cwd (or absolute) | |
35 | if (@is_readable($_plugin_filepath)) { | |
36 | $_return = $_plugin_filepath; | |
37 | break; | |
38 | } | |
39 | } | |
40 | ||
41 | if($_return === false) { | |
42 | // still not found, try PHP include_path | |
43 | if(isset($_relative_paths)) { | |
44 | foreach ((array)$_relative_paths as $_plugin_dir) { | |
45 | ||
46 | $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; | |
47 | ||
48 | $_params = array('file_path' => $_plugin_filepath); | |
49 | require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php'); | |
50 | if(smarty_core_get_include_path($_params, $smarty)) { | |
51 | return $_params['new_file_path']; | |
52 | } | |
53 | } | |
54 | } | |
55 | } | |
56 | ||
57 | return $_return; | |
58 | } | |
59 | ||
60 | /* vim: set expandtab: */ | |
61 | ||
62 | ?> |