- bugfix of parent/global variable update at included/merged subtemplates

- encode final template filepath into filename of compiled and cached files
This commit is contained in:
Uwe.Tews
2009-12-17 16:58:44 +00:00
parent 13448b9b0b
commit aaa7b8f245
5 changed files with 24 additions and 21 deletions

View File

@@ -1,3 +1,7 @@
12/17/2009
- bugfix of parent/global variable update at included/merged subtemplates
- encode final template filepath into filename of compiled and cached files
12/16/2009
- update of changelog
- added {include file='foo.tpl' inline} inline option to merge compiled code of aubtemplate into the calling template

View File

@@ -27,7 +27,7 @@ class Smarty_Internal_CacheResource_File {
*/
public function getCachedFilepath($template)
{
return $this->buildCachedFilepath ($template->resource_name, $template->cache_id, $template->compile_id);
return $this->buildCachedFilepath ($template->getTemplateFilepath(), $template->cache_id, $template->compile_id);
}
/**

View File

@@ -52,12 +52,12 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
} else {
$tpl->parseResourceName($_file_to_check[0], $resource_type, $resource_name, $resource_handler);
if ($resource_type == 'file') {
$must_compile = true; // subtemplate no longer existing
$must_compile = true; // subtemplate no longer existing
break;
}
$mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name);
}
// If ($mtime != $_file_to_check[1]) {
// If ($mtime != $_file_to_check[1]) {
If ($mtime > $_file_to_check[1]) {
$must_compile = true;
break;
@@ -100,7 +100,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
$_parent_scope = SMARTY_GLOBAL_SCOPE;
}
}
$_caching= 'null';
$_caching = 'null';
// default for included templates
if ($this->compiler->template->caching && !$this->compiler->nocache) {
$_caching = 9999;
@@ -132,7 +132,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
}
}
// create template object
$_output = "<?php \$_template = new {$compiler->smarty->template_class} ($include_file, \$_smarty_tpl->smarty, \$_smarty_tpl, \$_smarty_tpl->cache_id, \$_smarty_tpl->compile_id, $_caching, $_cache_lifetime);";
$_output = "<?php \$_template = new {$compiler->smarty->template_class}($include_file, \$_smarty_tpl->smarty, \$_smarty_tpl, \$_smarty_tpl->cache_id, \$_smarty_tpl->compile_id, $_caching, $_cache_lifetime);";
// delete {include} standard attributes
unset($_attr['file'], $_attr['assign'], $_attr['cache_lifetime'], $_attr['nocache'], $_attr['caching'], $_attr['scope'], $_attr['inline']);
// remaining attributes must be assigned as smarty variable
@@ -148,22 +148,21 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
}
// was there an assign attribute
if (isset($_assign)) {
$_output .= "\$_smarty_tpl->assign($_assign,\$_template->getRenderedTemplate()); ?>";
$_output .= "\$_smarty_tpl->assign($_assign,\$_template->getRenderedTemplate());?>";
} else {
if ($has_compiled_template && !($compiler->template->caching && ($this->compiler->tag_nocache || $this->compiler->nocache))) {
$_output .= " \$_tpl_stack[] = \$_smarty_tpl; \$_smarty_tpl = \$_template;?>\n";
$_output .= $compiled_tpl . "<?php /* End of included template \"" . $tpl->getTemplateFilepath() . "\" */ ?>";
$_output .= "<?php \$_smarty_tpl = array_pop(\$_tpl_stack);?>";
$_output .= "\$_tpl_stack[] = \$_smarty_tpl; \$_smarty_tpl = \$_template;?>\n";
$_output .= $compiled_tpl;
$_output .= "<?php \$_smarty_tpl->updateParentVariables($_parent_scope);?>";
$_output .= "<?php /* End of included template \"" . $tpl->getTemplateFilepath() . "\" */ ?>";
$_output .= "<?php \$_smarty_tpl = array_pop(\$_tpl_stack);?>";
} else {
$_output .= " echo \$_template->getRenderedTemplate(); ?>";
$_output .= " echo \$_template->getRenderedTemplate();?>";
$_output .= "<?php \$_template->updateParentVariables($_parent_scope);?>";
}
}
if ($_parent_scope != SMARTY_LOCAL_SCOPE) {
$_output .= "<?php \$_template->updateParentVariables($_parent_scope); ?>";
}
$_output .= "<?php unset(\$_template); ?>";
$_output .= "<?php unset(\$_template);?>";
return $_output;
}
}
?>

View File

@@ -166,7 +166,7 @@ class Smarty_Internal_Resource_Extends {
{
$_compile_id = isset($template->compile_id) ? preg_replace('![^\w\|]+!', '_', $template->compile_id) : null;
$_files = explode('|', $template->resource_name);
$_filepath = (string)abs(crc32($template->resource_name));
$_filepath = (string)abs(crc32($template->getTemplateFilepath()));
// if use_sub_dirs, break file into directories
if ($template->smarty->use_sub_dirs) {
$_filepath = substr($_filepath, 0, 2) . DS

View File

@@ -113,7 +113,7 @@ class Smarty_Internal_Resource_File {
{
$_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!','_',$_template->compile_id) : null;
// $_filepath = md5($_template->resource_name);
$_filepath = (string)abs(crc32($_template->resource_name));
$_filepath = (string)abs(crc32($_template->getTemplateFilepath()));
// if use_sub_dirs, break file into directories
if ($_template->smarty->use_sub_dirs) {
$_filepath = substr($_filepath, 0, 2) . DS