]> git.mxchange.org Git - friendica.git/blob - library/Smarty/libs/sysplugins/smarty_internal_get_include_path.php
Add Smarty to Composer
[friendica.git] / library / Smarty / libs / sysplugins / smarty_internal_get_include_path.php
1 <?php
2 /**
3  * Smarty read include path plugin
4  *
5  * @package    Smarty
6  * @subpackage PluginsInternal
7  * @author     Monte Ohrt
8  */
9
10 /**
11  * Smarty Internal Read Include Path Class
12  *
13  * @package    Smarty
14  * @subpackage PluginsInternal
15  */
16 class Smarty_Internal_Get_Include_Path
17 {
18     /**
19      * Return full file path from PHP include_path
20      *
21      * @param  string $filepath filepath
22      *
23      * @return string|boolean full filepath or false
24      */
25     public static function getIncludePath($filepath)
26     {
27         static $_include_path = null;
28
29         if (function_exists('stream_resolve_include_path')) {
30             // available since PHP 5.3.2
31             return stream_resolve_include_path($filepath);
32         }
33
34         if ($_include_path === null) {
35             $_include_path = explode(PATH_SEPARATOR, get_include_path());
36         }
37
38         foreach ($_include_path as $_path) {
39             if (file_exists($_path . DS . $filepath)) {
40                 return $_path . DS . $filepath;
41             }
42         }
43
44         return false;
45     }
46 }