From e180d015ea8470fe5e3af82dc8f7bc607fe3d548 Mon Sep 17 00:00:00 2001 From: "Uwe.Tews" Date: Sat, 28 Mar 2009 08:47:26 +0000 Subject: [PATCH] - file order for exted resource inverted - clear_compiled_tpl and clear_cache_all will not touch .svn folder any longer --- change_log.txt | 4 ++++ libs/sysplugins/internal.cacheresource_file.php | 1 + libs/sysplugins/internal.resource_extend.php | 2 +- libs/sysplugins/internal.templatebase.php | 3 ++- libs/sysplugins/method.clear_compiled_tpl.php | 5 +++-- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/change_log.txt b/change_log.txt index 8125178c..2c334743 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,7 @@ +03/28/2009 +- file order for exted resource inverted +- clear_compiled_tpl and clear_cache_all will not touch .svn folder any longer + 03/27/2009 - added extend resource diff --git a/libs/sysplugins/internal.cacheresource_file.php b/libs/sysplugins/internal.cacheresource_file.php index 398a376c..05928c2c 100644 --- a/libs/sysplugins/internal.cacheresource_file.php +++ b/libs/sysplugins/internal.cacheresource_file.php @@ -106,6 +106,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_Internal_PluginBase { $_cacheDirs = new RecursiveDirectoryIterator($_dir); $_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST); foreach ($_cache as $_file) { + if (strpos($_file, '.svn') !== false) continue; if ($_file->isDir()) { if (!$_cache->isDot()) { // delete folder if empty diff --git a/libs/sysplugins/internal.resource_extend.php b/libs/sysplugins/internal.resource_extend.php index ddf53f93..a69c2354 100644 --- a/libs/sysplugins/internal.resource_extend.php +++ b/libs/sysplugins/internal.resource_extend.php @@ -56,6 +56,7 @@ class Smarty_Internal_Resource_Extend extends Smarty_Internal_Base { { $this->template = $_template; $_files = explode('|', $_template->resource_name); + $_files = array_reverse($_files); foreach ($_files as $_file) { $_filepath = $_template->buildTemplateFilepath ($_file); if ($_file != $_files[0]) { @@ -64,7 +65,6 @@ class Smarty_Internal_Resource_Extend extends Smarty_Internal_Base { // read template file $_content = file_get_contents($_filepath); if ($_file != $_files[count($_files)-1]) { - $_content = preg_replace ('/' . $this->smarty->left_delimiter . 'extend\s+(?:file=)?\s*(\S+?|(["\']).+?\2)' . $this->smarty->right_delimiter . '/i', '' , $_content, 1); $_content = preg_replace_callback('/(' . $this->smarty->left_delimiter . 'block(.+?)' . $this->smarty->right_delimiter . ')((?:\r?\n?)(.*?)(?:\r?\n?))(' . $this->smarty->left_delimiter . '\/block(.*?)' . $this->smarty->right_delimiter . ')/is', array('Smarty_Internal_Resource_Extend', 'saveBlockData'), $_content); } else { $_template->template_source = $_content; diff --git a/libs/sysplugins/internal.templatebase.php b/libs/sysplugins/internal.templatebase.php index 63694321..64e45320 100644 --- a/libs/sysplugins/internal.templatebase.php +++ b/libs/sysplugins/internal.templatebase.php @@ -290,7 +290,8 @@ class Smarty_Internal_TemplateBase { */ public function buildTemplateId ($_resource, $_cache_id, $_compile_id) { - return md5($_resource . md5($_cache_id) . md5($_compile_id)); +// return md5($_resource . md5($_cache_id) . md5($_compile_id)); + return crc32($_resource . $_cache_id . $_compile_id); } /** diff --git a/libs/sysplugins/method.clear_compiled_tpl.php b/libs/sysplugins/method.clear_compiled_tpl.php index 6f5bf593..58f7a687 100644 --- a/libs/sysplugins/method.clear_compiled_tpl.php +++ b/libs/sysplugins/method.clear_compiled_tpl.php @@ -24,7 +24,7 @@ class Smarty_Method_Clear_Compiled_Tpl extends Smarty_Internal_Base { * @param string $compile_id compile id * @param integer $exp_time expiration time * @return integer number of template files deleted - */ + */ public function execute($resource_name = null, $compile_id = null, $exp_time = null) { $_dir_sep = $this->smarty->use_sub_dirs ? DIRECTORY_SEPARATOR : '^'; @@ -45,11 +45,12 @@ class Smarty_Method_Clear_Compiled_Tpl extends Smarty_Internal_Base { $_compileDirs = new RecursiveDirectoryIterator($_dir); $_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST); foreach ($_compile as $_file) { + if (strpos($_file,'.svn') !== false) continue; if ($_file->isDir()) { if (!$_compile->isDot()) { // delete folder if empty @rmdir($_file->getPathname()); - } + } } else { if ((!isset($compile_id) || substr_compare((string)$_file, $_compile_id_part, 0, strlen($_compile_id_part)) == 0) && (!isset($resource_name) || substr_compare((string)$_file, $_resource_part_1, - strlen($_resource_part_1), strlen($_resource_part_1)) == 0 ||