Automatically exported from code.google.com/p/planningalerts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

68 lines
1.9 KiB

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