mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-07 11:54:26 +02:00
- 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:
@@ -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
|
||||||
|
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -52,12 +52,12 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
|
|||||||
} else {
|
} else {
|
||||||
$tpl->parseResourceName($_file_to_check[0], $resource_type, $resource_name, $resource_handler);
|
$tpl->parseResourceName($_file_to_check[0], $resource_type, $resource_name, $resource_handler);
|
||||||
if ($resource_type == 'file') {
|
if ($resource_type == 'file') {
|
||||||
$must_compile = true; // subtemplate no longer existing
|
$must_compile = true; // subtemplate no longer existing
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name);
|
$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]) {
|
If ($mtime > $_file_to_check[1]) {
|
||||||
$must_compile = true;
|
$must_compile = true;
|
||||||
break;
|
break;
|
||||||
@@ -100,7 +100,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
|
|||||||
$_parent_scope = SMARTY_GLOBAL_SCOPE;
|
$_parent_scope = SMARTY_GLOBAL_SCOPE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$_caching= 'null';
|
$_caching = 'null';
|
||||||
// default for included templates
|
// default for included templates
|
||||||
if ($this->compiler->template->caching && !$this->compiler->nocache) {
|
if ($this->compiler->template->caching && !$this->compiler->nocache) {
|
||||||
$_caching = 9999;
|
$_caching = 9999;
|
||||||
@@ -115,8 +115,8 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
|
|||||||
$this->compiler->tag_nocache = true;
|
$this->compiler->tag_nocache = true;
|
||||||
$_caching = SMARTY_CACHING_LIFETIME_CURRENT;
|
$_caching = SMARTY_CACHING_LIFETIME_CURRENT;
|
||||||
} else {
|
} else {
|
||||||
$_cache_lifetime = 'null';
|
$_cache_lifetime = 'null';
|
||||||
}
|
}
|
||||||
if (isset($_attr['nocache'])) {
|
if (isset($_attr['nocache'])) {
|
||||||
if ($_attr['nocache'] == 'true') {
|
if ($_attr['nocache'] == 'true') {
|
||||||
$this->compiler->tag_nocache = true;
|
$this->compiler->tag_nocache = true;
|
||||||
@@ -132,7 +132,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// create template object
|
// 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
|
// delete {include} standard attributes
|
||||||
unset($_attr['file'], $_attr['assign'], $_attr['cache_lifetime'], $_attr['nocache'], $_attr['caching'], $_attr['scope'], $_attr['inline']);
|
unset($_attr['file'], $_attr['assign'], $_attr['cache_lifetime'], $_attr['nocache'], $_attr['caching'], $_attr['scope'], $_attr['inline']);
|
||||||
// remaining attributes must be assigned as smarty variable
|
// 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
|
// was there an assign attribute
|
||||||
if (isset($_assign)) {
|
if (isset($_assign)) {
|
||||||
$_output .= "\$_smarty_tpl->assign($_assign,\$_template->getRenderedTemplate()); ?>";
|
$_output .= "\$_smarty_tpl->assign($_assign,\$_template->getRenderedTemplate());?>";
|
||||||
} 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 = array_pop(\$_tpl_stack);?>";
|
$_output .= "<?php \$_smarty_tpl->updateParentVariables($_parent_scope);?>";
|
||||||
|
$_output .= "<?php /* End of included template \"" . $tpl->getTemplateFilepath() . "\" */ ?>";
|
||||||
|
$_output .= "<?php \$_smarty_tpl = array_pop(\$_tpl_stack);?>";
|
||||||
} else {
|
} else {
|
||||||
$_output .= " echo \$_template->getRenderedTemplate(); ?>";
|
$_output .= " echo \$_template->getRenderedTemplate();?>";
|
||||||
|
$_output .= "<?php \$_template->updateParentVariables($_parent_scope);?>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($_parent_scope != SMARTY_LOCAL_SCOPE) {
|
$_output .= "<?php unset(\$_template);?>";
|
||||||
$_output .= "<?php \$_template->updateParentVariables($_parent_scope); ?>";
|
|
||||||
}
|
|
||||||
$_output .= "<?php unset(\$_template); ?>";
|
|
||||||
return $_output;
|
return $_output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -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
|
||||||
|
@@ -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
|
||||||
|
Reference in New Issue
Block a user