diff --git a/change_log.txt b/change_log.txt index be7b8b24..7d134965 100644 --- a/change_log.txt +++ b/change_log.txt @@ -3,6 +3,7 @@ - optimize autoloader - optimize subtemplate handling - update template inheritance processing + - move code of {call} processing back into Smarty_Internal_Template class 30.08.2015 - size optimization move some runtime functions into extension diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 545a58c5..12c000bc 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -119,7 +119,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.28-dev/57'; + const SMARTY_VERSION = '3.1.28-dev/58'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_compile_call.php b/libs/sysplugins/smarty_internal_compile_call.php index 9b1cc585..0b241bfd 100644 --- a/libs/sysplugins/smarty_internal_compile_call.php +++ b/libs/sysplugins/smarty_internal_compile_call.php @@ -23,6 +23,7 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase * @see Smarty_Internal_CompileBase */ public $required_attributes = array('name'); + /** * Attribute definition: Overwrites base class. * @@ -30,6 +31,7 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase * @see Smarty_Internal_CompileBase */ public $shorttag_order = array('name'); + /** * Attribute definition: Overwrites base class. * @@ -76,9 +78,11 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase //$compiler->suppressNocacheProcessing = true; // was there an assign attribute if (isset($_assign)) { - $_output = "_Function->callTemplateFunction({$_name}, \$_smarty_tpl, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n"; + $_output = + "callTemplateFunction({$_name}, \$_smarty_tpl, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n"; } else { - $_output = "_Function->callTemplateFunction({$_name}, \$_smarty_tpl, {$_params}, {$_nocache});?>\n"; + $_output = + "callTemplateFunction({$_name}, \$_smarty_tpl, {$_params}, {$_nocache});?>\n"; } return $_output; } diff --git a/libs/sysplugins/smarty_internal_runtime_function.php b/libs/sysplugins/smarty_internal_runtime_function.php deleted file mode 100644 index a1f72735..00000000 --- a/libs/sysplugins/smarty_internal_runtime_function.php +++ /dev/null @@ -1,48 +0,0 @@ -tpl_function[$name])) { - if (!$_smarty_tpl->caching || ($_smarty_tpl->caching && $nocache)) { - $function = $_smarty_tpl->tpl_function[$name]['call_name']; - } else { - if (isset($_smarty_tpl->tpl_function[$name]['call_name_caching'])) { - $function = $_smarty_tpl->tpl_function[$name]['call_name_caching']; - } else { - $function = $_smarty_tpl->tpl_function[$name]['call_name']; - } - } - if (function_exists($function)) { - $function ($_smarty_tpl, $params); - return; - } - // try to load template function dynamically - if (Smarty_Internal_Function_Call_Handler::call($name, $_smarty_tpl, $function)) { - $function ($_smarty_tpl, $params); - return; - } - } - throw new SmartyException("Unable to find template function '{$name}'"); - } - -} \ No newline at end of file diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index e69c753b..88e711a9 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -426,7 +426,42 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase } } - /** + /** + * Call template function + * + * @param string $name template function name + * @param object|\Smarty_Internal_Template $_smarty_tpl template object + * @param array $params parameter array + * @param bool $nocache true if called nocache + * + * @throws \SmartyException + */ + public function callTemplateFunction($name, Smarty_Internal_Template $_smarty_tpl, $params, $nocache) + { + if (isset($_smarty_tpl->tpl_function[$name])) { + if (!$_smarty_tpl->caching || ($_smarty_tpl->caching && $nocache)) { + $function = $_smarty_tpl->tpl_function[$name]['call_name']; + } else { + if (isset($_smarty_tpl->tpl_function[$name]['call_name_caching'])) { + $function = $_smarty_tpl->tpl_function[$name]['call_name_caching']; + } else { + $function = $_smarty_tpl->tpl_function[$name]['call_name']; + } + } + if (function_exists($function)) { + $function ($_smarty_tpl, $params); + return; + } + // try to load template function dynamically + if (Smarty_Internal_Function_Call_Handler::call($name, $_smarty_tpl, $function)) { + $function ($_smarty_tpl, $params); + return; + } + } + throw new SmartyException("Unable to find template function '{$name}'"); + } + + /** * This function is executed automatically when a compiled or cached template file is included * - Decode saved properties from compiled template and cache files * - Check if compiled or cache file is valid diff --git a/libs/sysplugins/smarty_internal_templatebase.php b/libs/sysplugins/smarty_internal_templatebase.php index 768a5644..9a3a95c2 100644 --- a/libs/sysplugins/smarty_internal_templatebase.php +++ b/libs/sysplugins/smarty_internal_templatebase.php @@ -97,6 +97,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data * @return string rendered template output */ public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false) + $merge_tpl_vars = true, $no_output_filter = false) { $result = $this->_execute($template, $cache_id, $compile_id, $parent, 'fetch'); return $result === null ? ob_get_clean() : $result; @@ -173,8 +174,9 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data // fetch template content $level = ob_get_level(); try { - $_smarty_old_error_level = ($this->_objType == 1 && - isset($smarty->error_reporting)) ? error_reporting($smarty->error_reporting) : null; + $_smarty_old_error_level = + ($this->_objType == 1 && isset($smarty->error_reporting)) ? error_reporting($smarty->error_reporting) : + null; if ($function == 'isCached') { if ($template->caching) { // return cache status of template @@ -336,7 +338,8 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data * @return \Smarty|\Smarty_Internal_Template * @throws \SmartyException */ - public function registerObject($object_name, $object, $allowed_methods_properties = array(), $format = true, $block_methods = array()) + public function registerObject($object_name, $object, $allowed_methods_properties = array(), $format = true, + $block_methods = array()) { /* @var Smarty $smarty */ $smarty = isset($this->smarty) ? $this->smarty : $this; @@ -357,8 +360,8 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data } } // register the object - $smarty->registered_objects[$object_name] = array($object, (array) $allowed_methods_properties, - (boolean) $format, (array) $block_methods); + $smarty->registered_objects[$object_name] = + array($object, (array) $allowed_methods_properties, (boolean) $format, (array) $block_methods); return $this; }