1: | <?php |
2: | /** |
3: | * Smarty Internal Plugin Templateparser Parse Tree |
4: | * These are classes to build parse tree in the template parser |
5: | * |
6: | * @package Smarty |
7: | * @subpackage Compiler |
8: | * @author Thue Kristensen |
9: | * @author Uwe Tews |
10: | */ |
11: | |
12: | /** |
13: | * A complete smarty tag. |
14: | * |
15: | * @package Smarty |
16: | * @subpackage Compiler |
17: | * @ignore |
18: | */ |
19: | class Smarty_Internal_ParseTree_Tag extends Smarty_Internal_ParseTree |
20: | { |
21: | /** |
22: | * Saved block nesting level |
23: | * |
24: | * @var int |
25: | */ |
26: | public $saved_block_nesting; |
27: | |
28: | /** |
29: | * Create parse tree buffer for Smarty tag |
30: | * |
31: | * @param \Smarty_Internal_Templateparser $parser parser object |
32: | * @param string $data content |
33: | */ |
34: | public function __construct(Smarty_Internal_Templateparser $parser, $data) |
35: | { |
36: | $this->data = $data; |
37: | $this->saved_block_nesting = $parser->block_nesting_level; |
38: | } |
39: | |
40: | /** |
41: | * Return buffer content |
42: | * |
43: | * @param \Smarty_Internal_Templateparser $parser |
44: | * |
45: | * @return string content |
46: | */ |
47: | public function to_smarty_php(Smarty_Internal_Templateparser $parser) |
48: | { |
49: | return $this->data; |
50: | } |
51: | |
52: | /** |
53: | * Return complied code that loads the evaluated output of buffer content into a temporary variable |
54: | * |
55: | * @param \Smarty_Internal_Templateparser $parser |
56: | * |
57: | * @return string template code |
58: | */ |
59: | public function assign_to_var(Smarty_Internal_Templateparser $parser) |
60: | { |
61: | $var = $parser->compiler->getNewPrefixVariable(); |
62: | $tmp = $parser->compiler->appendCode('<?php ob_start();?>', $this->data); |
63: | $tmp = $parser->compiler->appendCode($tmp, "<?php {$var}=ob_get_clean();?>"); |
64: | $parser->compiler->prefix_code[] = sprintf('%s', $tmp); |
65: | return $var; |
66: | } |
67: | } |
68: |