28 public function compile($args, $compiler, $parameter)
32 $this->
openTag($compiler,
'if', array(1, $compiler->nocache));
34 $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
36 if (!array_key_exists(
"if condition", $parameter)) {
37 $compiler->trigger_template_error(
"missing if condition", $compiler->lex->taglineno);
40 if (is_array($parameter[
'if condition'])) {
41 if ($compiler->nocache) {
44 if (is_array($parameter[
'if condition'][
'var'])) {
45 $var = trim($parameter[
'if condition'][
'var'][
'var'],
"'");
47 $var = trim($parameter[
'if condition'][
'var'],
"'");
49 if (isset($compiler->template->tpl_vars[$var])) {
50 $compiler->template->tpl_vars[$var]->nocache =
true;
57 if (is_array($parameter[
'if condition'][
'var'])) {
58 $_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";
59 $_output .=
"if (\$_smarty_tpl->tpl_vars[" . $parameter[
'if condition'][
'var'][
'var'] .
"]->value" . $parameter[
'if condition'][
'var'][
'smarty_internal_index'] .
" = " . $parameter[
'if condition'][
'value'] .
") {?>";
61 $_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});";
62 $_output .=
"if (\$_smarty_tpl->tpl_vars[" . $parameter[
'if condition'][
'var'] .
"]->value = " . $parameter[
'if condition'][
'value'] .
") {?>";
67 return "<?php if ({$parameter['if condition']}) {?>";
89 public function compile($args, $compiler, $parameter)
91 list($nesting, $compiler->tag_nocache) = $this->
closeTag($compiler, array(
'if',
'elseif'));
92 $this->
openTag($compiler,
'else', array($nesting, $compiler->tag_nocache));
94 return "<?php } else { ?>";
115 public function compile($args, $compiler, $parameter)
120 list($nesting, $compiler->tag_nocache) = $this->
closeTag($compiler, array(
'if',
'elseif'));
122 if (!array_key_exists(
"if condition", $parameter)) {
123 $compiler->trigger_template_error(
"missing elseif condition", $compiler->lex->taglineno);
126 if (is_array($parameter[
'if condition'])) {
127 $condition_by_assign =
true;
128 if ($compiler->nocache) {
131 if (is_array($parameter[
'if condition'][
'var'])) {
132 $var = trim($parameter[
'if condition'][
'var'][
'var'],
"'");
134 $var = trim($parameter[
'if condition'][
'var'],
"'");
136 if (isset($compiler->template->tpl_vars[$var])) {
137 $compiler->template->tpl_vars[$var]->nocache =
true;
145 $condition_by_assign =
false;
148 if (empty($compiler->prefix_code)) {
149 if ($condition_by_assign) {
150 $this->
openTag($compiler,
'elseif', array($nesting + 1, $compiler->tag_nocache));
151 if (is_array($parameter[
'if condition'][
'var'])) {
152 $_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";
153 $_output .=
"if (\$_smarty_tpl->tpl_vars[" . $parameter[
'if condition'][
'var'][
'var'] .
"]->value" . $parameter[
'if condition'][
'var'][
'smarty_internal_index'] .
" = " . $parameter[
'if condition'][
'value'] .
") {?>";
155 $_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});";
156 $_output .=
"if (\$_smarty_tpl->tpl_vars[" . $parameter[
'if condition'][
'var'] .
"]->value = " . $parameter[
'if condition'][
'value'] .
") {?>";
161 $this->
openTag($compiler,
'elseif', array($nesting, $compiler->tag_nocache));
163 return "<?php } elseif ({$parameter['if condition']}) {?>";
167 foreach ($compiler->prefix_code as $code) {
168 $tmp = $compiler->appendCode($tmp, $code);
170 $compiler->prefix_code = array();
171 $tmp = $compiler->appendCode(
"<?php } else {?>", $tmp);
172 $this->
openTag($compiler,
'elseif', array($nesting + 1, $compiler->tag_nocache));
173 if ($condition_by_assign) {
174 if (is_array($parameter[
'if condition'][
'var'])) {
175 $_output = $compiler->appendCode($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");
176 $_output .=
"if (\$_smarty_tpl->tpl_vars[" . $parameter[
'if condition'][
'var'][
'var'] .
"]->value" . $parameter[
'if condition'][
'var'][
'smarty_internal_index'] .
" = " . $parameter[
'if condition'][
'value'] .
") {?>";
178 $_output = $compiler->appendCode($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});");
179 $_output .=
"if (\$_smarty_tpl->tpl_vars[" . $parameter[
'if condition'][
'var'] .
"]->value = " . $parameter[
'if condition'][
'value'] .
") {?>";
184 return $compiler->appendCode($tmp,
"<?php if ({$parameter['if condition']}) {?>");
207 public function compile($args, $compiler, $parameter)
210 if ($compiler->nocache) {
211 $compiler->tag_nocache =
true;
213 list($nesting, $compiler->nocache) = $this->
closeTag($compiler, array(
'if',
'else',
'elseif'));
215 for ($i = 0; $i < $nesting; $i ++) {
219 return "<?php {$tmp}?>";