smarty_internal_get_include_path.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. * Return full file path from PHP include_path
  18. *
  19. * @param string $filepath filepath
  20. * @return string|boolean full filepath or false
  21. */
  22. public static function getIncludePath($filepath)
  23. {
  24. static $_include_path = null;
  25. if (function_exists('stream_resolve_include_path')) {
  26. // available since PHP 5.3.2
  27. return stream_resolve_include_path($filepath);
  28. }
  29. if ($_include_path === null) {
  30. $_include_path = explode(PATH_SEPARATOR, get_include_path());
  31. }
  32. foreach ($_include_path as $_path) {
  33. if (file_exists($_path . DS . $filepath)) {
  34. return $_path . DS . $filepath;
  35. }
  36. }
  37. return false;
  38. }
  39. }
  40. ?>