- 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 12/16/2009
- update of changelog - update of changelog
- added {include file='foo.tpl' inline} inline option to merge compiled code of aubtemplate into the calling template - 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) 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

@@ -152,18 +152,17 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
} else { } else {
if ($has_compiled_template && !($compiler->template->caching && ($this->compiler->tag_nocache || $this->compiler->nocache))) { if ($has_compiled_template && !($compiler->template->caching && ($this->compiler->tag_nocache || $this->compiler->nocache))) {
$_output .= "\$_tpl_stack[] = \$_smarty_tpl; \$_smarty_tpl = \$_template;?>\n"; $_output .= "\$_tpl_stack[] = \$_smarty_tpl; \$_smarty_tpl = \$_template;?>\n";
$_output .= $compiled_tpl . "<?php /* End of included template \"" . $tpl->getTemplateFilepath() . "\" */ ?>"; $_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);?>"; $_output .= "<?php \$_smarty_tpl = array_pop(\$_tpl_stack);?>";
} else { } else {
$_output .= " echo \$_template->getRenderedTemplate();?>"; $_output .= " echo \$_template->getRenderedTemplate();?>";
}
}
if ($_parent_scope != SMARTY_LOCAL_SCOPE) {
$_output .= "<?php \$_template->updateParentVariables($_parent_scope);?>"; $_output .= "<?php \$_template->updateParentVariables($_parent_scope);?>";
} }
}
$_output .= "<?php unset(\$_template);?>"; $_output .= "<?php unset(\$_template);?>";
return $_output; 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; $_compile_id = isset($template->compile_id) ? preg_replace('![^\w\|]+!', '_', $template->compile_id) : null;
$_files = explode('|', $template->resource_name); $_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 use_sub_dirs, break file into directories
if ($template->smarty->use_sub_dirs) { if ($template->smarty->use_sub_dirs) {
$_filepath = substr($_filepath, 0, 2) . DS $_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; $_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!','_',$_template->compile_id) : null;
// $_filepath = md5($_template->resource_name); // $_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 use_sub_dirs, break file into directories
if ($_template->smarty->use_sub_dirs) { if ($_template->smarty->use_sub_dirs) {
$_filepath = substr($_filepath, 0, 2) . DS $_filepath = substr($_filepath, 0, 2) . DS