From c23ce16cafb826c8bb4fe7aaf2a5525b29052b23 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 6 Dec 2015 20:12:05 +0100 Subject: update smarty library - seems to bring some performance improvement --- .../libs/sysplugins/smarty_template_config.php | 118 +++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 library/Smarty/libs/sysplugins/smarty_template_config.php (limited to 'library/Smarty/libs/sysplugins/smarty_template_config.php') diff --git a/library/Smarty/libs/sysplugins/smarty_template_config.php b/library/Smarty/libs/sysplugins/smarty_template_config.php new file mode 100644 index 000000000..f48d4711d --- /dev/null +++ b/library/Smarty/libs/sysplugins/smarty_template_config.php @@ -0,0 +1,118 @@ +handler = clone $handler; // Note: prone to circular references + $this->resource = $resource; + $this->type = $type; + $this->name = $name; + $this->smarty = $smarty; + } + + /** + * initialize Source Object for given resource + * Either [$_template] or [$smarty, $template_resource] must be specified + * + * @param Smarty_Internal_Template $_template template object + * @param Smarty $smarty smarty object + * @param string $template_resource resource identifier + * + * @return Smarty_Template_Source Source Object + * @throws SmartyException + */ + public static function load(Smarty_Internal_Template $_template = null, Smarty $smarty = null, $template_resource = null) + { + static $_incompatible_resources = array('extends' => true, 'php' => true); + $smarty = $_template->smarty; + $template_resource = $_template->template_resource; + if (empty($template_resource)) { + throw new SmartyException('Missing config name'); + } + // parse resource_name, load resource handler + list($name, $type) = Smarty_Resource::parseResourceName($template_resource, $smarty->default_config_type); + // make sure configs are not loaded via anything smarty can't handle + if (isset($_incompatible_resources[$type])) { + throw new SmartyException ("Unable to use resource '{$type}' for config"); + } + $resource = Smarty_Resource::load($smarty, $type); + $source = new Smarty_Template_Config($resource, $smarty, $template_resource, $type, $name); + $resource->populate($source, $_template); + if ((!isset($source->exists) || !$source->exists) && isset($_template->smarty->default_config_handler_func)) { + Smarty_Internal_Extension_DefaultTemplateHandler::_getDefault($_template, $source, $resource); + } + $source->unique_resource = $resource->buildUniqueResourceName($smarty, $name, true); + return $source; + } +} -- cgit v1.2.3 From 26c465ad0c1d5b6801507ed190430f44ac92c672 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 6 Dec 2015 21:09:58 +0100 Subject: update smarty to 3.1.28-dev which fixes a bug where changes in a template are only visible on the second pageload which is annoying for developing --- .../libs/sysplugins/smarty_template_config.php | 45 ++++++---------------- 1 file changed, 12 insertions(+), 33 deletions(-) (limited to 'library/Smarty/libs/sysplugins/smarty_template_config.php') diff --git a/library/Smarty/libs/sysplugins/smarty_template_config.php b/library/Smarty/libs/sysplugins/smarty_template_config.php index f48d4711d..f0fff5080 100644 --- a/library/Smarty/libs/sysplugins/smarty_template_config.php +++ b/library/Smarty/libs/sysplugins/smarty_template_config.php @@ -14,34 +14,10 @@ * @package Smarty * @subpackage TemplateResources * @author Uwe Tews - * @property integer $timestamp Source Timestamp - * @property boolean $exists Source Existence - * @property boolean $template Extended Template reference - * @property string $content Source Content + * */ class Smarty_Template_Config extends Smarty_Template_Source { - /** - * Name of the Class to compile this resource's contents with - * - * @var string - */ - public $compiler_class = 'Smarty_Internal_Config_File_Compiler'; - - /** - * Name of the Class to tokenize this resource's contents with - * - * @var string - */ - public $template_lexer_class = 'Smarty_Internal_Configfilelexer'; - - /** - * Name of the Class to parse this resource's contents with - * - * @var string - */ - public $template_parser_class = 'Smarty_Internal_Configfileparser'; - /** * array of section names, single section or null * @@ -74,7 +50,11 @@ class Smarty_Template_Config extends Smarty_Template_Source */ public function __construct(Smarty_Resource $handler, Smarty $smarty, $resource, $type, $name) { + // must clone handler as we change class names $this->handler = clone $handler; // Note: prone to circular references + $this->handler->compiler_class = 'Smarty_Internal_Config_File_Compiler'; + $this->handler->template_lexer_class = 'Smarty_Internal_Configfilelexer'; + $this->handler->template_parser_class = 'Smarty_Internal_Configfileparser'; $this->resource = $resource; $this->type = $type; $this->name = $name; @@ -89,30 +69,29 @@ class Smarty_Template_Config extends Smarty_Template_Source * @param Smarty $smarty smarty object * @param string $template_resource resource identifier * - * @return Smarty_Template_Source Source Object + * @return Smarty_Template_Config Source Object * @throws SmartyException */ public static function load(Smarty_Internal_Template $_template = null, Smarty $smarty = null, $template_resource = null) { static $_incompatible_resources = array('extends' => true, 'php' => true); - $smarty = $_template->smarty; $template_resource = $_template->template_resource; if (empty($template_resource)) { throw new SmartyException('Missing config name'); } // parse resource_name, load resource handler - list($name, $type) = Smarty_Resource::parseResourceName($template_resource, $smarty->default_config_type); + list($name, $type) = Smarty_Resource::parseResourceName($template_resource, $_template->smarty->default_config_type); // make sure configs are not loaded via anything smarty can't handle if (isset($_incompatible_resources[$type])) { throw new SmartyException ("Unable to use resource '{$type}' for config"); } - $resource = Smarty_Resource::load($smarty, $type); - $source = new Smarty_Template_Config($resource, $smarty, $template_resource, $type, $name); + $resource = Smarty_Resource::load($_template->smarty, $type); + $source = new Smarty_Template_Config($resource, $_template->smarty, $template_resource, $type, $name); $resource->populate($source, $_template); - if ((!isset($source->exists) || !$source->exists) && isset($_template->smarty->default_config_handler_func)) { - Smarty_Internal_Extension_DefaultTemplateHandler::_getDefault($_template, $source, $resource); + if (!$source->exists && isset($_template->smarty->default_config_handler_func)) { + Smarty_Internal_Method_RegisterDefaultTemplateHandler::_getDefaultTemplate($source); } - $source->unique_resource = $resource->buildUniqueResourceName($smarty, $name, true); + $source->unique_resource = $resource->buildUniqueResourceName($_template->smarty, $name, true); return $source; } } -- cgit v1.2.3