Commit | Line | Data |
---|---|---|
ccd27f54 S |
1 | <?php |
2 | /** | |
cd8826ea S |
3 | * Smarty Internal Plugin Templateparser Parse Tree |
4 | * These are classes to build parse tree in the template parser | |
ccd27f54 S |
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 | { | |
cd8826ea | 21 | |
ccd27f54 S |
22 | /** |
23 | * Saved block nesting level | |
24 | * | |
25 | * @var int | |
26 | */ | |
27 | public $saved_block_nesting; | |
28 | ||
29 | /** | |
30 | * Create parse tree buffer for Smarty tag | |
31 | * | |
32 | * @param object $parser parser object | |
33 | * @param string $data content | |
34 | */ | |
35 | public function __construct($parser, $data) | |
36 | { | |
37 | $this->parser = $parser; | |
38 | $this->data = $data; | |
39 | $this->saved_block_nesting = $parser->block_nesting_level; | |
40 | } | |
41 | ||
42 | /** | |
43 | * Return buffer content | |
44 | * | |
45 | * @return string content | |
46 | */ | |
47 | public function to_smarty_php() | |
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 | * @return string template code | |
56 | */ | |
57 | public function assign_to_var() | |
58 | { | |
59 | $var = sprintf('$_tmp%d', ++ Smarty_Internal_Templateparser::$prefix_number); | |
cd8826ea S |
60 | $tmp = $this->parser->compiler->appendCode('<?php ob_start();?>', $this->data); |
61 | $tmp = $this->parser->compiler->appendCode($tmp, "<?php {$var}=ob_get_clean();?>"); | |
62 | $this->parser->compiler->prefix_code[] = sprintf("%s", $tmp); | |
ccd27f54 S |
63 | |
64 | return $var; | |
65 | } | |
66 | } |