server/onyx/modules/templates/smarty/sysplugins/smarty_internal_get_include_path.php

47 lines
1.0 KiB
PHP
Raw Normal View History

2013-10-09 13:40:23 +00:00
<?php
/**
* Smarty read include path plugin
*
* @package Smarty
* @subpackage PluginsInternal
* @author Monte Ohrt
*/
/**
* Smarty Internal Read Include Path Class
*
* @package Smarty
* @subpackage PluginsInternal
*/
2013-10-09 17:08:38 +00:00
class Smarty_Internal_Get_Include_Path
{
2013-10-09 13:40:23 +00:00
/**
* Return full file path from PHP include_path
*
2013-10-09 17:08:38 +00:00
* @param string $filepath filepath
2013-10-09 13:40:23 +00:00
* @return string|boolean full filepath or false
*/
public static function getIncludePath($filepath)
{
static $_include_path = null;
2013-10-09 17:08:38 +00:00
2013-10-09 13:40:23 +00:00
if (function_exists('stream_resolve_include_path')) {
// available since PHP 5.3.2
return stream_resolve_include_path($filepath);
}
if ($_include_path === null) {
$_include_path = explode(PATH_SEPARATOR, get_include_path());
}
foreach ($_include_path as $_path) {
if (file_exists($_path . DS . $filepath)) {
return $_path . DS . $filepath;
}
}
return false;
}
}