diff --git a/change_log.txt b/change_log.txt index 8892c397..810628f0 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,7 @@ +18/09/2010 +- bugfix untility compileAllConfig() did not create sha1 code for compiled template file names if template_dir was defined with no trailing DS +- bugfix on templateExists() for extends resource + 17/09/2010 - bugfix {$smarty.template} and {$smarty.current_dir} did not compile correctly within {block} tags - bugfix corrected error message on missing template files in extends resource diff --git a/libs/sysplugins/smarty_internal_resource_extends.php b/libs/sysplugins/smarty_internal_resource_extends.php index 891c950f..c263f8ac 100644 --- a/libs/sysplugins/smarty_internal_resource_extends.php +++ b/libs/sysplugins/smarty_internal_resource_extends.php @@ -37,11 +37,13 @@ class Smarty_Internal_Resource_Extends { */ public function isExisting($_template) { - if ($_template->getTemplateFilepath() === false) { + $_template->getTemplateFilepath(); + foreach ($this->allFilepaths as $_filepath) { + if ($_filepath === false) { return false; - } else { - return true; - } + } + } + return true; } /** * Get filepath to template source @@ -55,16 +57,13 @@ class Smarty_Internal_Resource_Extends { $_files = explode('|', $_template->resource_name); foreach ($_files as $_file) { $_filepath = $_template->buildTemplateFilepath ($_file); - if ($_filepath === false) { - throw new SmartyException("Unable to load template 'file : {$_file}'"); - } if ($_filepath !== false) { if ($_template->security) { $_template->smarty->security_handler->isTrustedResourceDir($_filepath); } } $sha1String .= $_filepath; - $this->allFilepaths[] = $_filepath; + $this->allFilepaths[$_file] = $_filepath; } $_template->templateUid = sha1($sha1String); return $_filepath; @@ -91,14 +90,19 @@ class Smarty_Internal_Resource_Extends { { $this->template = $_template; $_files = array_reverse($this->allFilepaths); - foreach ($_files as $_filepath) { + $_first = reset($_files); + $_last = end($_files); + foreach ($_files as $_file => $_filepath) { + if ($_filepath === false) { + throw new SmartyException("Unable to load template 'file : {$_file}'"); + } // read template file - if ($_filepath != $_files[0]) { + if ($_filepath != $_first) { $_template->properties['file_dependency'][sha1($_filepath)] = array($_filepath, filemtime($_filepath)); } $_template->template_filepath = $_filepath; $_content = file_get_contents($_filepath); - if ($_filepath != $_files[count($_files)-1]) { + if ($_filepath != $_last) { if (preg_match_all("!({$this->_ldl}block\s(.+?){$this->_rdl})!", $_content, $_open) != preg_match_all("!({$this->_ldl}/block(.*?){$this->_rdl})!", $_content, $_close)) { $this->smarty->trigger_error("unmatched {block} {/block} pairs in file '$_filepath'"); @@ -127,7 +131,6 @@ class Smarty_Internal_Resource_Extends { return true; } } - // $_template->template_filepath = $saved_filepath; } /** diff --git a/libs/sysplugins/smarty_internal_utility.php b/libs/sysplugins/smarty_internal_utility.php index 8759cbd3..01e5b224 100644 --- a/libs/sysplugins/smarty_internal_utility.php +++ b/libs/sysplugins/smarty_internal_utility.php @@ -127,7 +127,7 @@ class Smarty_Internal_Utility { if ($_fileinfo->getPath() == substr($_dir, 0, -1)) { $_config_file = $_file; } else { - $_config_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file; + $_config_file = substr(substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file,1); } echo '
', $_dir, '---', $_config_file; flush();