diff options
| author | uwe.tews@googlemail.com <uwe.tews@googlemail.com> | 2010-11-09 20:35:47 +0000 |
|---|---|---|
| committer | uwe.tews@googlemail.com <uwe.tews@googlemail.com> | 2010-11-09 20:35:47 +0000 |
| commit | 87ec00f518f5b608bb67645c43e3d9b160cac6ad (patch) | |
| tree | 0cf01dc37d876522454fd1125f6999fdfead8af2 /libs | |
| parent | 7af4fc75212361493f7310343d159887b5936d95 (diff) | |
| download | smarty-87ec00f518f5b608bb67645c43e3d9b160cac6ad.tar.gz smarty-87ec00f518f5b608bb67645c43e3d9b160cac6ad.tar.bz2 smarty-87ec00f518f5b608bb67645c43e3d9b160cac6ad.zip | |
-bugfix on complex expressions as start value for {for} tag
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/sysplugins/smarty_internal_compile_for.php | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libs/sysplugins/smarty_internal_compile_for.php b/libs/sysplugins/smarty_internal_compile_for.php index 77f196cc..164b298a 100644 --- a/libs/sysplugins/smarty_internal_compile_for.php +++ b/libs/sysplugins/smarty_internal_compile_for.php @@ -66,9 +66,9 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase { $output .= "\$_smarty_tpl->tpl_vars[$_statement[var]]->step = ($_attr[to] - ($_statement[value]) < 0) ? -1 : 1;"; } if (isset($_attr['max'])) { - $output .= "\$_smarty_tpl->tpl_vars[$_statement[var]]->total = (int)min(ceil((\$_smarty_tpl->tpl_vars[$_statement[var]]->step > 0 ? $_attr[to]+1 - $_statement[value] : $_statement[value]-($_attr[to])+1)/abs(\$_smarty_tpl->tpl_vars[$_statement[var]]->step)),$_attr[max]);\n"; + $output .= "\$_smarty_tpl->tpl_vars[$_statement[var]]->total = (int)min(ceil((\$_smarty_tpl->tpl_vars[$_statement[var]]->step > 0 ? $_attr[to]+1 - ($_statement[value]) : $_statement[value]-($_attr[to])+1)/abs(\$_smarty_tpl->tpl_vars[$_statement[var]]->step)),$_attr[max]);\n"; } else { - $output .= "\$_smarty_tpl->tpl_vars[$_statement[var]]->total = (int)ceil((\$_smarty_tpl->tpl_vars[$_statement[var]]->step > 0 ? $_attr[to]+1 - $_statement[value] : $_statement[value]-($_attr[to])+1)/abs(\$_smarty_tpl->tpl_vars[$_statement[var]]->step));\n"; + $output .= "\$_smarty_tpl->tpl_vars[$_statement[var]]->total = (int)ceil((\$_smarty_tpl->tpl_vars[$_statement[var]]->step > 0 ? $_attr[to]+1 - ($_statement[value]) : $_statement[value]-($_attr[to])+1)/abs(\$_smarty_tpl->tpl_vars[$_statement[var]]->step));\n"; } $output .= "if (\$_smarty_tpl->tpl_vars[$_statement[var]]->total > 0){\n"; $output .= "for (\$_smarty_tpl->tpl_vars[$_statement[var]]->value = $_statement[value], \$_smarty_tpl->tpl_vars[$_statement[var]]->iteration = 1;\$_smarty_tpl->tpl_vars[$_statement[var]]->iteration <= \$_smarty_tpl->tpl_vars[$_statement[var]]->total;\$_smarty_tpl->tpl_vars[$_statement[var]]->value += \$_smarty_tpl->tpl_vars[$_statement[var]]->step, \$_smarty_tpl->tpl_vars[$_statement[var]]->iteration++){\n"; |
