mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
- bugfix {foreach} first attribute was not correctly reset since commit 05a8fa2
of 02.08.2015 https://github.com/smarty-php/smarty/issues/90
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
===== 3.1.28-dev===== (xx.xx.2015)
|
===== 3.1.28-dev===== (xx.xx.2015)
|
||||||
|
17.09.2015
|
||||||
|
- bugfix {foreach} first attribute was not correctly reset since commit 05a8fa2 of 02.08.2015 https://github.com/smarty-php/smarty/issues/90
|
||||||
|
|
||||||
16.09.2015
|
16.09.2015
|
||||||
- update compiler by moving no longer needed properties, code optimizations and other
|
- update compiler by moving no longer needed properties, code optimizations and other
|
||||||
|
|
||||||
|
@@ -119,7 +119,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '3.1.28-dev/61';
|
const SMARTY_VERSION = '3.1.28-dev/62';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
|
@@ -87,7 +87,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
|||||||
*/
|
*/
|
||||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||||
{
|
{
|
||||||
$compiler->loopNesting++;
|
$compiler->loopNesting ++;
|
||||||
// init
|
// init
|
||||||
$this->isNamed = false;
|
$this->isNamed = false;
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
@@ -118,7 +118,8 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
|||||||
if ($fromName) {
|
if ($fromName) {
|
||||||
foreach (array('item', 'key') as $a) {
|
foreach (array('item', 'key') as $a) {
|
||||||
if (isset($attributes[$a]) && $attributes[$a] == $fromName) {
|
if (isset($attributes[$a]) && $attributes[$a] == $fromName) {
|
||||||
$compiler->trigger_template_error("'{$a}' and 'from' may not have same variable name '{$fromName}'", null, true);
|
$compiler->trigger_template_error("'{$a}' and 'from' may not have same variable name '{$fromName}'",
|
||||||
|
null, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,13 +163,14 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
|||||||
}
|
}
|
||||||
foreach (array('item', 'key') as $a) {
|
foreach (array('item', 'key') as $a) {
|
||||||
if (isset($attributes[$a])) {
|
if (isset($attributes[$a])) {
|
||||||
$saveVars['saved_' .
|
$saveVars['saved_' . $a] =
|
||||||
$a] = "isset(\$_smarty_tpl->tpl_vars['{$attributes[$a]}']) ? \$_smarty_tpl->tpl_vars['{$attributes[$a]}'] : false;";
|
"isset(\$_smarty_tpl->tpl_vars['{$attributes[$a]}']) ? \$_smarty_tpl->tpl_vars['{$attributes[$a]}'] : false;";
|
||||||
$restoreVars[] = "if ({$local}saved_{$a}) {\n\$_smarty_tpl->tpl_vars['{$attributes[$a]}'] = {$local}saved_{$a};\n}\n";
|
$restoreVars[] =
|
||||||
|
"if ({$local}saved_{$a}) {\n\$_smarty_tpl->tpl_vars['{$attributes[$a]}'] = {$local}saved_{$a};\n}\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->openTag($compiler, 'foreach', array('foreach', $compiler->nocache, $local, $restoreVars, $itemVar,
|
$this->openTag($compiler, 'foreach',
|
||||||
true));
|
array('foreach', $compiler->nocache, $local, $restoreVars, $itemVar, true));
|
||||||
// maybe nocache because of nocache variables
|
// maybe nocache because of nocache variables
|
||||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||||
|
|
||||||
@@ -256,10 +258,10 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
|||||||
if (isset($namedAttr['last'])) {
|
if (isset($namedAttr['last'])) {
|
||||||
$output .= "{$foreachVar}->value['last'] = {$local}iteration == {$local}total;\n";
|
$output .= "{$foreachVar}->value['last'] = {$local}iteration == {$local}total;\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (isset($namedAttr['first']) || isset($itemAttr['first'])) {
|
if (isset($namedAttr['first']) || isset($itemAttr['first'])) {
|
||||||
$output .= "{$local}first = false;\n";
|
$output .= "{$local}first = false;\n";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$output .= "{$local}saved_local_item = {$itemVar};\n";
|
$output .= "{$local}saved_local_item = {$itemVar};\n";
|
||||||
$output .= "?>";
|
$output .= "?>";
|
||||||
|
|
||||||
@@ -318,14 +320,14 @@ class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase
|
|||||||
*/
|
*/
|
||||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||||
{
|
{
|
||||||
$compiler->loopNesting--;
|
$compiler->loopNesting --;
|
||||||
// must endblock be nocache?
|
// must endblock be nocache?
|
||||||
if ($compiler->nocache) {
|
if ($compiler->nocache) {
|
||||||
$compiler->tag_nocache = true;
|
$compiler->tag_nocache = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
list($openTag, $compiler->nocache, $local, $restoreVars, $itemVar, $restore) = $this->closeTag($compiler, array('foreach',
|
list($openTag, $compiler->nocache, $local, $restoreVars, $itemVar, $restore) =
|
||||||
'foreachelse'));
|
$this->closeTag($compiler, array('foreach', 'foreachelse'));
|
||||||
$output = "<?php\n";
|
$output = "<?php\n";
|
||||||
|
|
||||||
if ($restore) {
|
if ($restore) {
|
||||||
|
Reference in New Issue
Block a user