smarty_internal_get_include_path.php 1.0 KB

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