- file order for exted resource inverted

- clear_compiled_tpl and clear_cache_all will not touch .svn folder any longer
This commit is contained in:
Uwe.Tews
2009-03-28 08:47:26 +00:00
parent 8a8766b0bd
commit e180d015ea
5 changed files with 11 additions and 4 deletions

View File

@@ -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 03/27/2009
- added extend resource - added extend resource

View File

@@ -106,6 +106,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_Internal_PluginBase {
$_cacheDirs = new RecursiveDirectoryIterator($_dir); $_cacheDirs = new RecursiveDirectoryIterator($_dir);
$_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST); $_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($_cache as $_file) { foreach ($_cache as $_file) {
if (strpos($_file, '.svn') !== false) continue;
if ($_file->isDir()) { if ($_file->isDir()) {
if (!$_cache->isDot()) { if (!$_cache->isDot()) {
// delete folder if empty // delete folder if empty

View File

@@ -56,6 +56,7 @@ class Smarty_Internal_Resource_Extend extends Smarty_Internal_Base {
{ {
$this->template = $_template; $this->template = $_template;
$_files = explode('|', $_template->resource_name); $_files = explode('|', $_template->resource_name);
$_files = array_reverse($_files);
foreach ($_files as $_file) { foreach ($_files as $_file) {
$_filepath = $_template->buildTemplateFilepath ($_file); $_filepath = $_template->buildTemplateFilepath ($_file);
if ($_file != $_files[0]) { if ($_file != $_files[0]) {
@@ -64,7 +65,6 @@ class Smarty_Internal_Resource_Extend extends Smarty_Internal_Base {
// read template file // read template file
$_content = file_get_contents($_filepath); $_content = file_get_contents($_filepath);
if ($_file != $_files[count($_files)-1]) { 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); $_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 { } else {
$_template->template_source = $_content; $_template->template_source = $_content;

View File

@@ -290,7 +290,8 @@ class Smarty_Internal_TemplateBase {
*/ */
public function buildTemplateId ($_resource, $_cache_id, $_compile_id) 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);
} }
/** /**

View File

@@ -24,7 +24,7 @@ class Smarty_Method_Clear_Compiled_Tpl extends Smarty_Internal_Base {
* @param string $compile_id compile id * @param string $compile_id compile id
* @param integer $exp_time expiration time * @param integer $exp_time expiration time
* @return integer number of template files deleted * @return integer number of template files deleted
*/ */
public function execute($resource_name = null, $compile_id = null, $exp_time = null) public function execute($resource_name = null, $compile_id = null, $exp_time = null)
{ {
$_dir_sep = $this->smarty->use_sub_dirs ? DIRECTORY_SEPARATOR : '^'; $_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); $_compileDirs = new RecursiveDirectoryIterator($_dir);
$_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST); $_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($_compile as $_file) { foreach ($_compile as $_file) {
if (strpos($_file,'.svn') !== false) continue;
if ($_file->isDir()) { if ($_file->isDir()) {
if (!$_compile->isDot()) { if (!$_compile->isDot()) {
// delete folder if empty // delete folder if empty
@rmdir($_file->getPathname()); @rmdir($_file->getPathname());
} }
} else { } else {
if ((!isset($compile_id) || substr_compare((string)$_file, $_compile_id_part, 0, strlen($_compile_id_part)) == 0) && 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 || (!isset($resource_name) || substr_compare((string)$_file, $_resource_part_1, - strlen($_resource_part_1), strlen($_resource_part_1)) == 0 ||