diff options
author | Mario Vavti <mario@mariovavti.com> | 2015-12-06 20:12:05 +0100 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2015-12-06 20:12:05 +0100 |
commit | c23ce16cafb826c8bb4fe7aaf2a5525b29052b23 (patch) | |
tree | 2230b03cfa6b74f3898b57bee647bc6276fd5a53 /library/Smarty/libs/sysplugins/smarty_internal_extension_defaulttemplatehandler.php | |
parent | 78a70fed2f7cf9a53e6e4fab516b00cece12fbf0 (diff) | |
download | volse-hubzilla-c23ce16cafb826c8bb4fe7aaf2a5525b29052b23.tar.gz volse-hubzilla-c23ce16cafb826c8bb4fe7aaf2a5525b29052b23.tar.bz2 volse-hubzilla-c23ce16cafb826c8bb4fe7aaf2a5525b29052b23.zip |
update smarty library - seems to bring some performance improvement
Diffstat (limited to 'library/Smarty/libs/sysplugins/smarty_internal_extension_defaulttemplatehandler.php')
-rw-r--r-- | library/Smarty/libs/sysplugins/smarty_internal_extension_defaulttemplatehandler.php | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_extension_defaulttemplatehandler.php b/library/Smarty/libs/sysplugins/smarty_internal_extension_defaulttemplatehandler.php new file mode 100644 index 000000000..ed6029204 --- /dev/null +++ b/library/Smarty/libs/sysplugins/smarty_internal_extension_defaulttemplatehandler.php @@ -0,0 +1,85 @@ +<?php +/** + * Smarty Resource Extension + * + * @package Smarty + * @subpackage TemplateResources + * @author Uwe Tews + */ + +/** + * Smarty Resource Extension + * Default template and config file handling + * + * @package Smarty + * @subpackage TemplateResources + */ +class Smarty_Internal_Extension_DefaultTemplateHandler +{ + + /** + * get default content from template of config resource handler + * + * @param Smarty_Internal_Template $_template + * @param Smarty_Internal_Template_Source $source + * @param Smarty_Resource $resObj + */ + static function _getDefault(Smarty_Internal_Template $_template, &$source, &$resObj) + { + if ($source->isConfig) { + $default_handler = $_template->smarty->default_config_handler_func; + } else { + $default_handler = $_template->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->recompiled = true; + $source->filepath = false; + } + } + + /** + * register template default handler + * + * @param Smarty $smarty + * @param mixed $callback + * + * @throws SmartyException + */ + static function registerDefaultTemplateHandler(Smarty $smarty, $callback) + { + if (is_callable($callback)) { + $smarty->default_template_handler_func = $callback; + } else { + throw new SmartyException("Default template handler not callable"); + } + } + + /** + * register config default handler + * + * @param Smarty $smarty + * @param mixed $callback + * + * @throws SmartyException + */ + static function registerDefaultConfigHandler(Smarty $smarty, $callback) + { + if (is_callable($callback)) { + $smarty->default_config_handler_func = $callback; + } else { + throw new SmartyException("Default config handler not callable"); + } + } +}
\ No newline at end of file |