library/smarty/libs/sysplugins/smarty_internal_parsetree_tag.php
changeset 46 f11c31f7fa3e
parent 45 a56e7f9a0463
child 47 03388ec805b4
equal deleted inserted replaced
45:a56e7f9a0463 46:f11c31f7fa3e
     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 object $parser parser object
       
    32      * @param string $data content
       
    33      */
       
    34     public function __construct($parser, $data) {
       
    35         $this->parser = $parser;
       
    36         $this->data = $data;
       
    37         $this->saved_block_nesting = $parser->block_nesting_level;
       
    38     }
       
    39 
       
    40     /**
       
    41      * Return buffer content
       
    42      *
       
    43      * @return string content
       
    44      */
       
    45     public function to_smarty_php() {
       
    46         return $this->data;
       
    47     }
       
    48 
       
    49     /**
       
    50      * Return complied code that loads the evaluated output of buffer content into a temporary variable
       
    51      *
       
    52      * @return string template code
       
    53      */
       
    54     public function assign_to_var() {
       
    55         $var = sprintf('$_tmp%d', ++Smarty_Internal_Templateparser::$prefix_number);
       
    56         $tmp = $this->parser->compiler->appendCode('<?php ob_start();?>', $this->data);
       
    57         $tmp = $this->parser->compiler->appendCode($tmp, "<?php {$var}=ob_get_clean();?>");
       
    58         $this->parser->compiler->prefix_code[] = sprintf("%s", $tmp);
       
    59 
       
    60         return $var;
       
    61     }
       
    62 }