mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-02 05:11:36 +01:00
- update/bugfix scope attribute handling reworked. Read the newfeatures.txt file
This commit is contained in:
@@ -39,44 +39,37 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
|
||||
|
||||
// maybe nocache because of nocache variables
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
$_output = "<?php\n";
|
||||
if (is_array($parameter[ 'if condition' ])) {
|
||||
if ($compiler->nocache) {
|
||||
$_nocache = ',true';
|
||||
// create nocache var to make it know for further compiling
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$var = trim($parameter[ 'if condition' ][ 'var' ][ 'var' ], "'");
|
||||
$var = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
||||
} else {
|
||||
$var = trim($parameter[ 'if condition' ][ 'var' ], "'");
|
||||
}
|
||||
if (isset($compiler->template->tpl_vars[ $var ])) {
|
||||
$compiler->template->tpl_vars[ $var ]->nocache = true;
|
||||
} else {
|
||||
$compiler->template->tpl_vars[ $var ] = new Smarty_Variable(null, true);
|
||||
$var = $parameter[ 'if condition' ][ 'var' ];
|
||||
}
|
||||
$compiler->setNocacheInVariable($var);
|
||||
} else {
|
||||
$_nocache = '';
|
||||
}
|
||||
$assignCompiler = new Smarty_Internal_Compile_Assign();
|
||||
$assignAttr = array();
|
||||
$assignAttr[][ 'value' ] = $parameter[ 'if condition' ][ 'value' ];
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$_output .= "if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ][ 'var' ] .
|
||||
"]) || !is_array(\$_smarty_tpl->tpl_vars[" .
|
||||
$parameter[ 'if condition' ][ 'var' ][ 'var' ] .
|
||||
"]->value)) \$_smarty_tpl->_createLocalArrayVariable(" .
|
||||
$parameter[ 'if condition' ][ 'var' ][ 'var' ] . "$_nocache);\n";
|
||||
$_output .= "while (\$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ][ 'var' ] .
|
||||
"]->value" . $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ] . " = " .
|
||||
$parameter[ 'if condition' ][ 'value' ] . ") {?>";
|
||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
||||
$_output = "<?php while (" . $parameter[ 'if condition' ][ 'value' ] . ") {?>";
|
||||
$_output .= $assignCompiler->compile($assignAttr, $compiler,
|
||||
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ]));
|
||||
} else {
|
||||
$_output .= "if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ] .
|
||||
"])) \$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ] .
|
||||
"] = new Smarty_Variable(null{$_nocache});";
|
||||
$_output .= "while (\$_smarty_tpl->tpl_vars[" . $parameter[ 'if condition' ][ 'var' ] . "]->value = " .
|
||||
$parameter[ 'if condition' ][ 'value' ] . ") {?>";
|
||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ];
|
||||
$_output = "<?php while (" . $parameter[ 'if condition' ][ 'value' ] . ") {?>";
|
||||
$_output .= $assignCompiler->compile($assignAttr, $compiler, array());
|
||||
}
|
||||
|
||||
return $_output;
|
||||
} else {
|
||||
$_output .= "while ({$parameter['if condition']}) {?>";
|
||||
return "<?php\n while ({$parameter['if condition']}) {?>";
|
||||
}
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user