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

smarty_internal_method_registerdefaulttemplatehandler.php 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Smarty Method RegisterDefaultTemplateHandler
  4. *
  5. * Smarty::registerDefaultTemplateHandler() method
  6. *
  7. * @package Smarty
  8. * @subpackage PluginsInternal
  9. * @author Uwe Tews
  10. */
  11. class Smarty_Internal_Method_RegisterDefaultTemplateHandler
  12. {
  13. /**
  14. * Valid for Smarty and template object
  15. *
  16. * @var int
  17. */
  18. public $objMap = 3;
  19. /**
  20. * Register template default handler
  21. *
  22. * @api Smarty::registerDefaultTemplateHandler()
  23. *
  24. * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
  25. * @param callable $callback class/method name
  26. *
  27. * @return \Smarty|\Smarty_Internal_Template
  28. * @throws SmartyException if $callback is not callable
  29. */
  30. public function registerDefaultTemplateHandler(Smarty_Internal_TemplateBase $obj, $callback)
  31. {
  32. $smarty = isset($obj->smarty) ? $obj->smarty : $obj;
  33. if (is_callable($callback)) {
  34. $smarty->default_template_handler_func = $callback;
  35. } else {
  36. throw new SmartyException("Default template handler not callable");
  37. }
  38. return $obj;
  39. }
  40. /**
  41. * get default content from template or config resource handler
  42. *
  43. * @param Smarty_Template_Source $source
  44. */
  45. public static function _getDefaultTemplate(Smarty_Template_Source $source)
  46. {
  47. if ($source->isConfig) {
  48. $default_handler = $source->smarty->default_config_handler_func;
  49. } else {
  50. $default_handler = $source->smarty->default_template_handler_func;
  51. }
  52. $_content = $_timestamp = null;
  53. $_return = call_user_func_array($default_handler, array($source->type, $source->name, &$_content, &$_timestamp,
  54. $source->smarty));
  55. if (is_string($_return)) {
  56. $source->exists = is_file($_return);
  57. if ($source->exists) {
  58. $source->timestamp = filemtime($_return);
  59. }
  60. $source->filepath = $_return;
  61. } elseif ($_return === true) {
  62. $source->content = $_content;
  63. $source->timestamp = $_timestamp;
  64. $source->exists = true;
  65. $source->handler->recompiled = true;
  66. $source->filepath = false;
  67. }
  68. }
  69. }