From fa10e0945ecd45bfe78a2c8fb015a43092b4944b Mon Sep 17 00:00:00 2001 From: plegall Date: Thu, 10 Dec 2015 14:02:22 +0100 Subject: bug #385 update to smarty-3.1.28-dev (from Github) --- ...ernal_method_registerdefaulttemplatehandler.php | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 include/smarty/libs/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php (limited to 'include/smarty/libs/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php') diff --git a/include/smarty/libs/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php b/include/smarty/libs/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php new file mode 100644 index 000000000..40979e7a6 --- /dev/null +++ b/include/smarty/libs/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php @@ -0,0 +1,72 @@ +smarty) ? $obj->smarty : $obj; + if (is_callable($callback)) { + $smarty->default_template_handler_func = $callback; + } else { + throw new SmartyException("Default template handler not callable"); + } + return $obj; + } + + /** + * get default content from template or config resource handler + * + * @param Smarty_Template_Source $source + */ + public static function _getDefaultTemplate(Smarty_Template_Source $source) + { + if ($source->isConfig) { + $default_handler = $source->smarty->default_config_handler_func; + } else { + $default_handler = $source->smarty->default_template_handler_func; + } + $_content = $_timestamp = null; + $_return = call_user_func_array($default_handler, array($source->type, $source->name, &$_content, &$_timestamp, + $source->smarty)); + if (is_string($_return)) { + $source->exists = is_file($_return); + if ($source->exists) { + $source->timestamp = filemtime($_return); + } + $source->filepath = $_return; + } elseif ($_return === true) { + $source->content = $_content; + $source->timestamp = $_timestamp; + $source->exists = true; + $source->handler->recompiled = true; + $source->filepath = false; + } + } +} \ No newline at end of file -- cgit v1.2.3