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 $compiler->template->tpl_vars[trim($parameter[
'if condition'][
'var'][
'var'],
"'")] =
new Smarty_variable(null,
true);
47 $compiler->template->tpl_vars[trim($parameter[
'if condition'][
'var'],
"'")] =
new Smarty_variable(null,
true);
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'].
"){?>";
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'].
"){?>";
61 return "<?php if ({$parameter['if condition']}){?>";
83 public function compile($args, $compiler, $parameter)
85 list($nesting, $compiler->tag_nocache) = $this->
closeTag($compiler, array(
'if',
'elseif'));
86 $this->
openTag($compiler,
'else', array($nesting, $compiler->tag_nocache));
88 return "<?php }else{ ?>";
109 public function compile($args, $compiler, $parameter)
114 list($nesting, $compiler->tag_nocache) = $this->
closeTag($compiler, array(
'if',
'elseif'));
116 if (!array_key_exists(
"if condition",$parameter)) {
117 $compiler->trigger_template_error(
"missing elseif condition", $compiler->lex->taglineno);
120 if (is_array($parameter[
'if condition'])) {
121 $condition_by_assign =
true;
122 if ($compiler->nocache) {
125 if (is_array($parameter[
'if condition'][
'var'])) {
126 $compiler->template->tpl_vars[trim($parameter[
'if condition'][
'var'][
'var'],
"'")] =
new Smarty_variable(null,
true);
128 $compiler->template->tpl_vars[trim($parameter[
'if condition'][
'var'],
"'")] =
new Smarty_variable(null,
true);
134 $condition_by_assign =
false;
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'] .
"){?>";
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'] .
"){?>";
149 $this->
openTag($compiler,
'elseif', array($nesting, $compiler->tag_nocache));
150 return "<?php }elseif({$parameter['if condition']}){?>";
154 foreach ($compiler->prefix_code as $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'] .
"){?>";
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'] .
"){?>";
168 return "<?php }else{?>{$tmp}<?php if ({$parameter['if condition']}){?>";
191 public function compile($args, $compiler, $parameter)
194 if ($compiler->nocache) {
195 $compiler->tag_nocache =
true;
197 list($nesting, $compiler->nocache) = $this->
closeTag($compiler, array(
'if',
'else',
'elseif'));
199 for (
$i = 0;
$i < $nesting;
$i++) {
202 return "<?php {$tmp}?>";
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.