К новейшей редакции | Содержимое файла | Последнее изменение | Открыть журнал | RSS
Редакция | Автор | № строки | Строка |
---|---|---|---|
304 | alex-w | 1 | <?php |
2 | /** |
||
3 | * Smarty Internal Plugin Compile Print Expression |
||
4 | * |
||
5 | * Compiles any tag which will output an expression or variable |
||
6 | * |
||
7 | * @package Smarty |
||
8 | * @subpackage Compiler |
||
9 | * @author Uwe Tews |
||
10 | */ |
||
11 | /** |
||
12 | * Smarty Internal Plugin Compile Print Expression Class |
||
13 | */ |
||
14 | class Smarty_Internal_Compile_Print_Expression extends Smarty_Internal_CompileBase { |
||
15 | /** |
||
16 | * Compiles code for gererting output from any expression |
||
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('value'); |
||
26 | $this->optional_attributes = array('assign', 'nocache', 'filter', 'nofilter'); |
||
27 | // check and get attributes |
||
28 | $_attr = $this->_get_attributes($args); |
||
29 | |||
30 | if (isset($_attr['nocache'])) { |
||
31 | if ($_attr['nocache'] == 'true') { |
||
32 | $this->compiler->tag_nocache = true; |
||
33 | } |
||
34 | } |
||
35 | |||
36 | if (!isset($_attr['filter'])) { |
||
37 | $_attr['filter'] = 'null'; |
||
38 | } |
||
39 | if (isset($_attr['nofilter'])) { |
||
40 | if ($_attr['nofilter'] == 'true') { |
||
41 | $_attr['filter'] = 'false'; |
||
42 | } |
||
43 | } |
||
44 | |||
45 | if (isset($_attr['assign'])) { |
||
46 | // assign output to variable |
||
47 | $output = '<?php $_smarty_tpl->assign(' . $_attr['assign'] . ',' . $_attr['value'] . ');?>'; |
||
48 | } else { |
||
49 | // display value |
||
50 | $this->compiler->has_output = true; |
||
51 | $output = '<?php echo $this->smarty->filter_handler->execute(\'variable\', ' . $_attr['value'] . ',' . $_attr['filter'] . ');?>'; |
||
52 | } |
||
53 | return $output; |
||
54 | } |
||
55 | } |
||
56 | |||
57 | ?> |