- 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
- bugfix untility compileAllTemplates() did not create sha1 code for compiled template file names if template_dir was defined with no trailing DS
This commit is contained in:
uwe.tews@googlemail.com
2010-09-17 18:10:10 +00:00
parent 66752cd790
commit 18bcfa2ba7
6 changed files with 29 additions and 8 deletions

View File

@@ -1,3 +1,8 @@
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
- bugfix untility compileAllTemplates() did not create sha1 code for compiled template file names if template_dir was defined with no trailing DS
16/09/2010 16/09/2010
- bugfix when a doublequoted modifier parameter did contain Smarty tags and ':' - bugfix when a doublequoted modifier parameter did contain Smarty tags and ':'

View File

@@ -225,6 +225,8 @@ class Smarty extends Smarty_Internal_Data {
public $smarty = null; public $smarty = null;
// block tag hierarchy // block tag hierarchy
public $_tag_stack = array(); public $_tag_stack = array();
// flag if {block} tag is compiled for template inheritance
public $inheritance = false;
// plugins // plugins
public $_plugins = array(); public $_plugins = array();
// generate deprecated function call notices? // generate deprecated function call notices?

View File

@@ -34,6 +34,8 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
$compiler->nocache = true; $compiler->nocache = true;
} }
} }
// set flag for {block} tag
$compiler->smarty->inheritance = true;
// must merge includes // must merge includes
$this->compiler->smarty->merge_compiled_includes = true; $this->compiler->smarty->merge_compiled_includes = true;
@@ -109,6 +111,8 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase {
$compiler->smarty->merge_compiled_includes = $saved_data[2]; $compiler->smarty->merge_compiled_includes = $saved_data[2];
// $_output content has already nocache code processed // $_output content has already nocache code processed
$compiler->suppressNocacheProcessing = true; $compiler->suppressNocacheProcessing = true;
// reset flag
$compiler->smarty->inheritance = false;
return $_output; return $_output;
} }
} }

View File

@@ -56,11 +56,21 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
break; break;
case 'template': case 'template':
$_template_name = $compiler->template->template_resource; if ($compiler->smarty->inheritance) {
$ptr = $compiler->template->parent;
} else {
$ptr = $compiler->template;
}
$_template_name = $ptr->template_resource;
return "'$_template_name'"; return "'$_template_name'";
case 'current_dir': case 'current_dir':
$_template_dir_name = dirname($compiler->template->getTemplateFilepath()); if ($compiler->smarty->inheritance) {
$ptr = $compiler->template->parent;
} else {
$ptr = $compiler->template;
}
$_template_dir_name = dirname($ptr->getTemplateFilepath());
return "'$_template_dir_name'"; return "'$_template_dir_name'";
case 'version': case 'version':

View File

@@ -55,6 +55,9 @@ class Smarty_Internal_Resource_Extends {
$_files = explode('|', $_template->resource_name); $_files = explode('|', $_template->resource_name);
foreach ($_files as $_file) { foreach ($_files as $_file) {
$_filepath = $_template->buildTemplateFilepath ($_file); $_filepath = $_template->buildTemplateFilepath ($_file);
if ($_filepath === false) {
throw new SmartyException("Unable to load template 'file : {$_file}'");
}
if ($_filepath !== false) { if ($_filepath !== false) {
if ($_template->security) { if ($_template->security) {
$_template->smarty->security_handler->isTrustedResourceDir($_filepath); $_template->smarty->security_handler->isTrustedResourceDir($_filepath);
@@ -90,9 +93,6 @@ class Smarty_Internal_Resource_Extends {
$_files = array_reverse($this->allFilepaths); $_files = array_reverse($this->allFilepaths);
foreach ($_files as $_filepath) { foreach ($_files as $_filepath) {
// read template file // read template file
if ($_filepath === false) {
throw new SmartyException("Unable to load template 'file : {$_file}'");
}
if ($_filepath != $_files[0]) { if ($_filepath != $_files[0]) {
$_template->properties['file_dependency'][sha1($_filepath)] = array($_filepath, filemtime($_filepath)); $_template->properties['file_dependency'][sha1($_filepath)] = array($_filepath, filemtime($_filepath));
} }

View File

@@ -67,10 +67,10 @@ class Smarty_Internal_Utility {
$_file = $_fileinfo->getFilename(); $_file = $_fileinfo->getFilename();
if (!substr_compare($_file, $extention, - strlen($extention)) == 0) continue; if (!substr_compare($_file, $extention, - strlen($extention)) == 0) continue;
if ($_fileinfo->getPath() == substr($_dir, 0, -1)) { if ($_fileinfo->getPath() == substr($_dir, 0, -1)) {
$_template_file = $_file; $_template_file = $_file;
} else { } else {
$_template_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file; $_template_file = substr(substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file,1);
} }
echo '<br>', $_dir, '---', $_template_file; echo '<br>', $_dir, '---', $_template_file;
flush(); flush();
$_start_time = microtime(true); $_start_time = microtime(true);