From 52652dd4f970fbbf2f5ec1539357c28bea856a3a Mon Sep 17 00:00:00 2001 From: "Uwe.Tews" Date: Mon, 23 Mar 2009 15:29:50 +0000 Subject: [PATCH] - fixed {foreachelse} and {forelse} tags --- change_log.txt | 3 +++ libs/sysplugins/internal.compile_for.php | 2 +- libs/sysplugins/internal.compile_forclose.php | 2 -- libs/sysplugins/internal.compile_foreach.php | 2 +- libs/sysplugins/internal.compile_foreachclose.php | 2 +- libs/sysplugins/internal.compile_foreachelse.php | 2 +- libs/sysplugins/internal.compile_forelse.php | 7 ++----- libs/sysplugins/internal.templatebase.php | 2 +- libs/sysplugins/internal.templateparser.php | 8 ++++---- 9 files changed, 14 insertions(+), 16 deletions(-) diff --git a/change_log.txt b/change_log.txt index abc0b3d5..979f54ea 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,6 @@ +03/23/2009 +- fixed {foreachelse} and {forelse} tags + 03/22/2009 - fixed possible sources for notice errors - rearrange SVN into distribution and development folders diff --git a/libs/sysplugins/internal.compile_for.php b/libs/sysplugins/internal.compile_for.php index 532df371..de33ce13 100644 --- a/libs/sysplugins/internal.compile_for.php +++ b/libs/sysplugins/internal.compile_for.php @@ -46,7 +46,7 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase { $output = "tpl_vars[$item] = new Smarty_Variable;\n"; - $output .= " \$_from = $from; if (\$_from !== false) { if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array');}\n"; + $output .= " \$_from = $from; if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array');}\n"; $output .= " \$_smarty_tpl->tpl_vars[$item]->total=count(\$_from);\n"; $output .= " \$_smarty_tpl->tpl_vars[$item]->iteration=0;\n"; $output .= " \$_smarty_tpl->tpl_vars[$item]->index=-1;\n"; diff --git a/libs/sysplugins/internal.compile_forclose.php b/libs/sysplugins/internal.compile_forclose.php index d8e421d3..9b35b45b 100644 --- a/libs/sysplugins/internal.compile_forclose.php +++ b/libs/sysplugins/internal.compile_forclose.php @@ -28,8 +28,6 @@ class Smarty_Internal_Compile_ForClose extends Smarty_Internal_CompileBase { $_open_tag = $this->_close_tag(array('for', 'forarray', 'forelse')); if ($_open_tag == 'forelse') return ""; - elseif ($_open_tag == 'forarray') - return ""; else return ""; } diff --git a/libs/sysplugins/internal.compile_foreach.php b/libs/sysplugins/internal.compile_foreach.php index c3678b48..99ed37bc 100644 --- a/libs/sysplugins/internal.compile_foreach.php +++ b/libs/sysplugins/internal.compile_foreach.php @@ -49,7 +49,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase { if ($key != null) { $output .= " \$_smarty_tpl->tpl_vars[$key] = new Smarty_Variable;\n"; } - $output .= " \$_from = $from; if (\$_from !== false) { if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array');}\n"; + $output .= " \$_from = $from; if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array');}\n"; if ($name != null) { $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['total'] = count(\$_from);\n"; $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['iteration']=0;\n"; diff --git a/libs/sysplugins/internal.compile_foreachclose.php b/libs/sysplugins/internal.compile_foreachclose.php index 337f1762..182f6eb0 100644 --- a/libs/sysplugins/internal.compile_foreachclose.php +++ b/libs/sysplugins/internal.compile_foreachclose.php @@ -28,7 +28,7 @@ class Smarty_Internal_Compile_ForeachClose extends Smarty_Internal_CompileBase { if ($_open_tag == 'foreachelse') return ""; else - return ""; + return ""; } } diff --git a/libs/sysplugins/internal.compile_foreachelse.php b/libs/sysplugins/internal.compile_foreachelse.php index adef5b0e..ff9b5ce5 100644 --- a/libs/sysplugins/internal.compile_foreachelse.php +++ b/libs/sysplugins/internal.compile_foreachelse.php @@ -26,7 +26,7 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase { $this->_close_tag('foreach'); $this->_open_tag('foreachelse'); - return ""; + return ""; } } diff --git a/libs/sysplugins/internal.compile_forelse.php b/libs/sysplugins/internal.compile_forelse.php index 26c10ee8..467e40a4 100644 --- a/libs/sysplugins/internal.compile_forelse.php +++ b/libs/sysplugins/internal.compile_forelse.php @@ -25,12 +25,9 @@ class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase { // check and get attributes $_attr = $this->_get_attributes($args); - $_open_tag = $this->_close_tag(array('for', 'forarray')); + $this->_close_tag(array('for', 'forarray')); $this->_open_tag('forelse'); - if ($_open_tag == 'forarray') - return ""; - else - return ""; + return ""; } } diff --git a/libs/sysplugins/internal.templatebase.php b/libs/sysplugins/internal.templatebase.php index ca2aae44..8220fc8a 100644 --- a/libs/sysplugins/internal.templatebase.php +++ b/libs/sysplugins/internal.templatebase.php @@ -373,7 +373,7 @@ class Undefined_Smarty_Variable { // return always false public function __get ($name) { - return false; + return null; } } diff --git a/libs/sysplugins/internal.templateparser.php b/libs/sysplugins/internal.templateparser.php index 81955e8f..789ff561 100644 --- a/libs/sysplugins/internal.templateparser.php +++ b/libs/sysplugins/internal.templateparser.php @@ -1911,10 +1911,10 @@ static public $yy_action = array( #line 1916 "internal.templateparser.php" #line 292 "internal.templateparser.y" function yy_r61(){ if ($this->yystack[$this->yyidx + -1]->minor == '\'smarty\'') { $this->_retvalue = $this->compiler->compileTag(trim($this->yystack[$this->yyidx + -1]->minor,"'"),$this->yystack[$this->yyidx + 0]->minor);} else { - $this->_retvalue = '$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + -1]->minor .')->value'.$this->yystack[$this->yyidx + 0]->minor; $this->nocache=$this->template->getVariable(trim($this->yystack[$this->yyidx + -1]->minor,"'"))->nocache;} } + $this->_retvalue = '$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + -1]->minor .')->value'.$this->yystack[$this->yyidx + 0]->minor; $_var = $this->template->getVariable(trim($this->yystack[$this->yyidx + -1]->minor,"'")); if(!is_null($_var)) if ($_var->nocache) $this->nocache=true;} } #line 1920 "internal.templateparser.php" #line 295 "internal.templateparser.y" - function yy_r62(){ $this->_retvalue = '$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + -2]->minor .')->'.$this->yystack[$this->yyidx + 0]->minor; $this->nocache=$this->template->getVariable(trim($this->yystack[$this->yyidx + -2]->minor,"'"))->nocache; } + function yy_r62(){ $this->_retvalue = '$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + -2]->minor .')->'.$this->yystack[$this->yyidx + 0]->minor; $_var = $this->template->getVariable(trim($this->yystack[$this->yyidx + -2]->minor,"'")); if(!is_null($_var)) if ($_var->nocache) $this->nocache=true; } #line 1923 "internal.templateparser.php" #line 307 "internal.templateparser.y" function yy_r65(){return; } @@ -1941,7 +1941,7 @@ static public $yy_action = array( function yy_r73(){$this->_retvalue = '('.$this->yystack[$this->yyidx + -1]->minor.')'; } #line 1947 "internal.templateparser.php" #line 333 "internal.templateparser.y" - function yy_r74(){ $this->_retvalue = '$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + -2]->minor .')->value'.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; $this->nocache=$this->template->getVariable(trim($this->yystack[$this->yyidx + -2]->minor,"'"))->nocache; } + function yy_r74(){ $this->_retvalue = '$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + -2]->minor .')->value'.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; $_var = $this->template->getVariable(trim($this->yystack[$this->yyidx + -2]->minor,"'")); if(!is_null($_var)) if ($_var->nocache) $this->nocache=true; } #line 1950 "internal.templateparser.php" #line 335 "internal.templateparser.y" function yy_r75(){$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; } @@ -1983,7 +1983,7 @@ static public $yy_action = array( function yy_r86(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } #line 1989 "internal.templateparser.php" #line 384 "internal.templateparser.y" - function yy_r88(){$this->_retvalue = ',\''.$this->yystack[$this->yyidx + 0]->minor.'\''; } + function yy_r88(){$this->_retvalue = ','.$this->yystack[$this->yyidx + 0]->minor.''; } #line 1992 "internal.templateparser.php" #line 385 "internal.templateparser.y" function yy_r89(){$this->_retvalue = ','.$this->yystack[$this->yyidx + 0]->minor; }