PEEL Shopping
Open source ecommerce : PEEL Shopping
smarty_internal_compile_if.php
Go to the documentation of this file.
1 <?php
19 
28  public function compile($args, $compiler, $parameter)
29  {
30  // check and get attributes
31  $_attr = $this->getAttributes($compiler, $args);
32  $this->openTag($compiler, 'if', array(1, $compiler->nocache));
33  // must whole block be nocache ?
34  $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
35 
36  if (!array_key_exists("if condition",$parameter)) {
37  $compiler->trigger_template_error("missing if condition", $compiler->lex->taglineno);
38  }
39 
40  if (is_array($parameter['if condition'])) {
41  if ($compiler->nocache) {
42  $_nocache = ',true';
43  // create nocache var to make it know for further compiling
44  if (is_array($parameter['if condition']['var'])) {
45  $compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Smarty_variable(null, true);
46  } else {
47  $compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Smarty_variable(null, true);
48  }
49  } else {
50  $_nocache = '';
51  }
52  if (is_array($parameter['if condition']['var'])) {
53  $_output = "<?php 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";
54  $_output .= "if (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]->value".$parameter['if condition']['var']['smarty_internal_index']." = ".$parameter['if condition']['value']."){?>";
55  } else {
56  $_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."])) \$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."] = new Smarty_Variable(null{$_nocache});";
57  $_output .= "if (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."]->value = ".$parameter['if condition']['value']."){?>";
58  }
59  return $_output;
60  } else {
61  return "<?php if ({$parameter['if condition']}){?>";
62  }
63  }
64 
65 }
66 
74 
83  public function compile($args, $compiler, $parameter)
84  {
85  list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));
86  $this->openTag($compiler, 'else', array($nesting, $compiler->tag_nocache));
87 
88  return "<?php }else{ ?>";
89  }
90 
91 }
92 
100 
109  public function compile($args, $compiler, $parameter)
110  {
111  // check and get attributes
112  $_attr = $this->getAttributes($compiler, $args);
113 
114  list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));
115 
116  if (!array_key_exists("if condition",$parameter)) {
117  $compiler->trigger_template_error("missing elseif condition", $compiler->lex->taglineno);
118  }
119 
120  if (is_array($parameter['if condition'])) {
121  $condition_by_assign = true;
122  if ($compiler->nocache) {
123  $_nocache = ',true';
124  // create nocache var to make it know for further compiling
125  if (is_array($parameter['if condition']['var'])) {
126  $compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Smarty_variable(null, true);
127  } else {
128  $compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Smarty_variable(null, true);
129  }
130  } else {
131  $_nocache = '';
132  }
133  } else {
134  $condition_by_assign = false;
135  }
136 
137  if (empty($compiler->prefix_code)) {
138  if ($condition_by_assign) {
139  $this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));
140  if (is_array($parameter['if condition']['var'])) {
141  $_output = "<?php }else{ 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";
142  $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" . $parameter['if condition']['var']['smarty_internal_index'] . " = " . $parameter['if condition']['value'] . "){?>";
143  } else {
144  $_output = "<?php }else{ if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});";
145  $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . "){?>";
146  }
147  return $_output;
148  } else {
149  $this->openTag($compiler, 'elseif', array($nesting, $compiler->tag_nocache));
150  return "<?php }elseif({$parameter['if condition']}){?>";
151  }
152  } else {
153  $tmp = '';
154  foreach ($compiler->prefix_code as $code)
155  $tmp .= $code;
156  $compiler->prefix_code = array();
157  $this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));
158  if ($condition_by_assign) {
159  if (is_array($parameter['if condition']['var'])) {
160  $_output = "<?php }else{?>{$tmp}<?php 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";
161  $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" . $parameter['if condition']['var']['smarty_internal_index'] . " = " . $parameter['if condition']['value'] . "){?>";
162  } else {
163  $_output = "<?php }else{?>{$tmp}<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});";
164  $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . "){?>";
165  }
166  return $_output;
167  } else {
168  return "<?php }else{?>{$tmp}<?php if ({$parameter['if condition']}){?>";
169  }
170  }
171  }
172 
173 }
174 
182 
191  public function compile($args, $compiler, $parameter)
192  {
193  // must endblock be nocache?
194  if ($compiler->nocache) {
195  $compiler->tag_nocache = true;
196  }
197  list($nesting, $compiler->nocache) = $this->closeTag($compiler, array('if', 'else', 'elseif'));
198  $tmp = '';
199  for ($i = 0; $i < $nesting; $i++) {
200  $tmp .= '}';
201  }
202  return "<?php {$tmp}?>";
203  }
204 
205 }
206 
207 ?>
openTag($compiler, $openTag, $data=null)
Push opening tag name on stack.
getAttributes($compiler, $attributes)
This function checks if the attributes passed are valid.
compile($args, $compiler, $parameter)
Compiles code for the {/if} tag.
compile($args, $compiler, $parameter)
Compiles code for the {if} tag.
compile($args, $compiler, $parameter)
Compiles code for the {else} tag.
compile($args, $compiler, $parameter)
Compiles code for the {elseif} tag.
closeTag($compiler, $expectedTag)
Pop closing tag.

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:41:17 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.