- bugfix {foreachelse} does fail if {section} was nested inside {foreach}

This commit is contained in:
uwe.tews@googlemail.com
2011-09-22 14:51:34 +00:00
parent 48295d9573
commit 6e22abb6dd
2 changed files with 6 additions and 3 deletions

View File

@@ -1,4 +1,7 @@
===== Smarty 3.1 trunk ===== ===== Smarty 3.1 trunk =====
22.09.2011
- bugfix {foreachelse} does fail if {section} was nested inside {foreach}
21.09.2011 21.09.2011
- bugfix look for mixed case plugin file names as in 3.0 if not found try all lowercase - bugfix look for mixed case plugin file names as in 3.0 if not found try all lowercase
- added $error_muting to suppress error messages even for badly implemented error_handlers - added $error_muting to suppress error messages even for badly implemented error_handlers

View File

@@ -100,7 +100,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase {
$usesPropTotal = $usesSmartyTotal || $usesSmartyShow || $usesPropShow || $usesPropLast || strpos($tpl->source->content, $ItemVarName . 'total') !== false; $usesPropTotal = $usesSmartyTotal || $usesSmartyShow || $usesPropShow || $usesPropLast || strpos($tpl->source->content, $ItemVarName . 'total') !== false;
// generate output code // generate output code
$output = "<?php "; $output = "<?php ";
$output .= " \$_smarty_tpl->tpl_vars[$item] = new Smarty_Variable;\n"; $output .= " \$_smarty_tpl->tpl_vars[$item] = new Smarty_Variable; \$_smarty_tpl->tpl_vars[$item]->_loop = false;\n";
if ($key != null) { if ($key != null) {
$output .= " \$_smarty_tpl->tpl_vars[$key] = new Smarty_Variable;\n"; $output .= " \$_smarty_tpl->tpl_vars[$key] = new Smarty_Variable;\n";
} }
@@ -131,7 +131,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase {
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['show']=(\$_smarty_tpl->tpl_vars[$item]->total > 0);\n"; $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['show']=(\$_smarty_tpl->tpl_vars[$item]->total > 0);\n";
} }
} }
$output .= "\$_loop = false;\nforeach (\$_from as \$_smarty_tpl->tpl_vars[$item]->key => \$_smarty_tpl->tpl_vars[$item]->value){\n\$_loop = true;\n"; $output .= "foreach (\$_from as \$_smarty_tpl->tpl_vars[$item]->key => \$_smarty_tpl->tpl_vars[$item]->value){\n\$_smarty_tpl->tpl_vars[$item]->_loop = true;\n";
if ($key != null) { if ($key != null) {
$output .= " \$_smarty_tpl->tpl_vars[$key]->value = \$_smarty_tpl->tpl_vars[$item]->key;\n"; $output .= " \$_smarty_tpl->tpl_vars[$key]->value = \$_smarty_tpl->tpl_vars[$item]->key;\n";
} }
@@ -191,7 +191,7 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase {
list($openTag, $nocache, $item, $key) = $this->closeTag($compiler, array('foreach')); list($openTag, $nocache, $item, $key) = $this->closeTag($compiler, array('foreach'));
$this->openTag($compiler, 'foreachelse', array('foreachelse', $nocache, $item, $key)); $this->openTag($compiler, 'foreachelse', array('foreachelse', $nocache, $item, $key));
return "<?php }\nif (!\$_loop) {\n?>"; return "<?php }\nif (!\$_smarty_tpl->tpl_vars[$item]->_loop) {\n?>";
} }
} }