From eab8a101e7a3fcbb41e01a574985e06c5a3775de Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 18 Oct 2018 02:40:38 +0200 Subject: Updating Smarty --- .../sysplugins/smarty_internal_compile_for.php | 42 ++++++++++------------ 1 file changed, 18 insertions(+), 24 deletions(-) (limited to 'lib/smarty3/sysplugins/smarty_internal_compile_for.php') diff --git a/lib/smarty3/sysplugins/smarty_internal_compile_for.php b/lib/smarty3/sysplugins/smarty_internal_compile_for.php index e5e7c61..3f113e5 100644 --- a/lib/smarty3/sysplugins/smarty_internal_compile_for.php +++ b/lib/smarty3/sysplugins/smarty_internal_compile_for.php @@ -26,16 +26,16 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase * The parser is generating different sets of attribute by which this compiler can * determine which syntax is used. * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @param array $parameter array with compilation parameter + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @param array $parameter array with compilation parameter * * @return string compiled code */ public function compile($args, $compiler, $parameter) { - $compiler->loopNesting ++; - if ($parameter == 0) { + $compiler->loopNesting++; + if ($parameter === 0) { $this->required_attributes = array('start', 'to'); $this->optional_attributes = array('max', 'step'); } else { @@ -45,9 +45,8 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase $this->mapCache = array(); // check and get attributes $_attr = $this->getAttributes($compiler, $args); - $output = "tpl_vars[$var]->total > 0) {\n"; $output .= "for (\$_smarty_tpl->tpl_vars[$var]->value{$index} = $_statement[value], \$_smarty_tpl->tpl_vars[$var]->iteration = 1;\$_smarty_tpl->tpl_vars[$var]->iteration <= \$_smarty_tpl->tpl_vars[$var]->total;\$_smarty_tpl->tpl_vars[$var]->value{$index} += \$_smarty_tpl->tpl_vars[$var]->step, \$_smarty_tpl->tpl_vars[$var]->iteration++) {\n"; - $output .= "\$_smarty_tpl->tpl_vars[$var]->first = \$_smarty_tpl->tpl_vars[$var]->iteration == 1;"; - $output .= "\$_smarty_tpl->tpl_vars[$var]->last = \$_smarty_tpl->tpl_vars[$var]->iteration == \$_smarty_tpl->tpl_vars[$var]->total;"; + $output .= "\$_smarty_tpl->tpl_vars[$var]->first = \$_smarty_tpl->tpl_vars[$var]->iteration === 1;"; + $output .= "\$_smarty_tpl->tpl_vars[$var]->last = \$_smarty_tpl->tpl_vars[$var]->iteration === \$_smarty_tpl->tpl_vars[$var]->total;"; } - $output .= "?>"; - + $output .= '?>'; $this->openTag($compiler, 'for', array('for', $compiler->nocache)); // maybe nocache because of nocache variables $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; @@ -113,9 +111,9 @@ class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase /** * Compiles code for the {forelse} tag * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @param array $parameter array with compilation parameter + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @param array $parameter array with compilation parameter * * @return string compiled code */ @@ -123,10 +121,8 @@ class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase { // check and get attributes $_attr = $this->getAttributes($compiler, $args); - list($openTag, $nocache) = $this->closeTag($compiler, array('for')); $this->openTag($compiler, 'forelse', array('forelse', $nocache)); - return ""; } } @@ -142,29 +138,27 @@ class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase /** * Compiles code for the {/for} tag * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @param array $parameter array with compilation parameter + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @param array $parameter array with compilation parameter * * @return string compiled code */ public function compile($args, $compiler, $parameter) { - $compiler->loopNesting --; + $compiler->loopNesting--; // check and get attributes $_attr = $this->getAttributes($compiler, $args); // must endblock be nocache? if ($compiler->nocache) { $compiler->tag_nocache = true; } - list($openTag, $compiler->nocache) = $this->closeTag($compiler, array('for', 'forelse')); - $output = "\n"; + $output .= "?>"; return $output; } } -- cgit v1.2.3