From f236905fed45d11ca2b54819f2ccb80a9957b7c8 Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Sat, 3 Jan 2015 07:36:07 +0100 Subject: [PATCH] create different compiled templates and config files Smarty does now automatically detect a change of the $merge_compiled_includes and $escape_html property and create different compiled templates files depending on the setting. Same applies to config files and the $config_overwrite, $config_booleanize and $config_read_hidden properties. --- NEW_FEATURES.txt | 8 ++++++++ change_log.txt | 4 +++- libs/sysplugins/smarty_template_compiled.php | 8 +++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/NEW_FEATURES.txt b/NEW_FEATURES.txt index 282f8df5..fdc387c5 100644 --- a/NEW_FEATURES.txt +++ b/NEW_FEATURES.txt @@ -24,5 +24,13 @@ Smarty 3.1.22 The main template is level 1. The nesting level is checked at run time. When the maximum will be exceeded an Exception will be thrown. The default setting is 0 which does disable this check. + Compiled Templates + ================== + Smarty does now automatically detect a change of the $merge_compiled_includes and $escape_html + property and create different compiled templates files depending on the setting. + + Same applies to config files and the $config_overwrite, $config_booleanize and + $config_read_hidden properties. + \ No newline at end of file diff --git a/change_log.txt b/change_log.txt index c2e1236d..cb20ba45 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,8 +1,10 @@  ===== 3.1.22-dev ===== (xx.xx.2015) + - improvement automatically create different versions of compiled templates and config files depending + on property settings. - optimization restructure template processing by moving code into classes it better belongs to - optimization restructure config file processing - + 31.12.2014 - bugfix use function_exists('mb_get_info') for setting Smarty::$_MBSTRING. Function mb_split could be overloaded depending on php.ini mbstring.func_overload diff --git a/libs/sysplugins/smarty_template_compiled.php b/libs/sysplugins/smarty_template_compiled.php index cd8c8661..16b34feb 100644 --- a/libs/sysplugins/smarty_template_compiled.php +++ b/libs/sysplugins/smarty_template_compiled.php @@ -94,7 +94,13 @@ class Smarty_Template_Compiled public function populateCompiledFilepath(Smarty_Internal_Template $_template) { $_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!', '_', $_template->compile_id) : null; - $_filepath = $_template->source->uid; + if ($_template->source->isConfig) { + $_flag = '_' . ((int) $_template->smarty->config_read_hidden + (int) $_template->smarty->config_booleanize * 2 + + (int) $_template->smarty->config_overwrite * 4); + } else { + $_flag = '_' . ((int) $_template->smarty->merge_compiled_includes + (int) $_template->smarty->escape_html * 2); + } + $_filepath = $_template->source->uid . $_flag; // if use_sub_dirs, break file into directories if ($_template->smarty->use_sub_dirs) { $_filepath = substr($_filepath, 0, 2) . DS