Automatically exported from code.google.com/p/planningalerts
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

75 Zeilen
2.1 KiB

  1. <?php
  2. /**
  3. * Smarty plugin
  4. * @package Smarty
  5. * @subpackage plugins
  6. */
  7. /**
  8. * load a resource plugin
  9. *
  10. * @param string $type
  11. */
  12. // $type
  13. function smarty_core_load_resource_plugin($params, &$smarty)
  14. {
  15. /*
  16. * Resource plugins are not quite like the other ones, so they are
  17. * handled differently. The first element of plugin info is the array of
  18. * functions provided by the plugin, the second one indicates whether
  19. * all of them exist or not.
  20. */
  21. $_plugin = &$smarty->_plugins['resource'][$params['type']];
  22. if (isset($_plugin)) {
  23. if (!$_plugin[1] && count($_plugin[0])) {
  24. $_plugin[1] = true;
  25. foreach ($_plugin[0] as $_plugin_func) {
  26. if (!is_callable($_plugin_func)) {
  27. $_plugin[1] = false;
  28. break;
  29. }
  30. }
  31. }
  32. if (!$_plugin[1]) {
  33. $smarty->_trigger_fatal_error("[plugin] resource '" . $params['type'] . "' is not implemented", null, null, __FILE__, __LINE__);
  34. }
  35. return;
  36. }
  37. $_plugin_file = $smarty->_get_plugin_filepath('resource', $params['type']);
  38. $_found = ($_plugin_file != false);
  39. if ($_found) { /*
  40. * If the plugin file is found, it -must- provide the properly named
  41. * plugin functions.
  42. */
  43. include_once($_plugin_file);
  44. /*
  45. * Locate functions that we require the plugin to provide.
  46. */
  47. $_resource_ops = array('source', 'timestamp', 'secure', 'trusted');
  48. $_resource_funcs = array();
  49. foreach ($_resource_ops as $_op) {
  50. $_plugin_func = 'smarty_resource_' . $params['type'] . '_' . $_op;
  51. if (!function_exists($_plugin_func)) {
  52. $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", null, null, __FILE__, __LINE__);
  53. return;
  54. } else {
  55. $_resource_funcs[] = $_plugin_func;
  56. }
  57. }
  58. $smarty->_plugins['resource'][$params['type']] = array($_resource_funcs, true);
  59. }
  60. }
  61. /* vim: set expandtab: */
  62. ?>