Содержимое файла | Последнее изменение | Открыть журнал | RSS
Редакция | Автор | № строки | Строка |
---|---|---|---|
304 | alex-w | 1 | <?php |
2 | /** |
||
3 | * Smarty Internal Plugin Compile If |
||
4 | * |
||
5 | * Compiles the {if} tag |
||
6 | * |
||
7 | * @package Smarty |
||
8 | * @subpackage Compiler |
||
9 | * @author Uwe Tews |
||
10 | */ |
||
11 | /** |
||
12 | * Smarty Internal Plugin Compile If Class |
||
13 | */ |
||
14 | class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase { |
||
15 | /** |
||
16 | * Compiles code for the {if} tag |
||
17 | * |
||
18 | * @param array $args array with attributes from parser |
||
19 | * @param object $compiler compiler object |
||
20 | * @return string compiled code |
||
21 | */ |
||
22 | public function compile($args, $compiler) |
||
23 | { |
||
24 | $this->compiler = $compiler; |
||
25 | $this->required_attributes = array('if condition'); |
||
26 | // check and get attributes |
||
27 | $_attr = $this->_get_attributes($args); |
||
28 | |||
29 | $this->_open_tag('if'); |
||
30 | if (is_array($args['if condition'])) { |
||
31 | $_output = " <?php if (!isset(\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."])) \$_smarty_tpl->tpl_vars[".$args['if condition']['var']."] = new Smarty_Variable;\n"; |
||
32 | $_output .= " if (\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."]->value = ".$args['if condition']['value']."): ?>"; |
||
33 | return $_output; |
||
34 | } else { |
||
35 | return '<?php if (' . $args['if condition'] . '): ?>'; |
||
36 | } |
||
37 | } |
||
38 | } |
||
39 | |||
40 | ?> |