gluon-web-remote

Web remote Administration for big size of gluon routers
git clone git://archive.git.mtrnord.blog/MTRNord/gluon-web-remote.git
Log | Files | Refs | README

smarty_internal_parsetree_dq.php (2956B)


      1 <?php
      2 
      3 /**
      4  * Double quoted string inside a tag.
      5  *
      6  * @package    Smarty
      7  * @subpackage Compiler
      8  * @ignore
      9  */
     10 
     11 /**
     12  * Double quoted string inside a tag.
     13  *
     14  * @package    Smarty
     15  * @subpackage Compiler
     16  * @ignore
     17  */
     18 class Smarty_Internal_ParseTree_Dq extends Smarty_Internal_ParseTree
     19 {
     20     /**
     21      * Create parse tree buffer for double quoted string subtrees
     22      *
     23      * @param object                    $parser  parser object
     24      * @param Smarty_Internal_ParseTree $subtree parse tree buffer
     25      */
     26     public function __construct($parser, Smarty_Internal_ParseTree $subtree)
     27     {
     28         $this->parser = $parser;
     29         $this->subtrees[] = $subtree;
     30         if ($subtree instanceof Smarty_Internal_ParseTree_Tag) {
     31             $this->parser->block_nesting_level = count($this->parser->compiler->_tag_stack);
     32         }
     33     }
     34 
     35     /**
     36      * Append buffer to subtree
     37      *
     38      * @param Smarty_Internal_ParseTree $subtree parse tree buffer
     39      */
     40     public function append_subtree(Smarty_Internal_ParseTree $subtree)
     41     {
     42         $last_subtree = count($this->subtrees) - 1;
     43         if ($last_subtree >= 0 && $this->subtrees[$last_subtree] instanceof Smarty_Internal_ParseTree_Tag && $this->subtrees[$last_subtree]->saved_block_nesting < $this->parser->block_nesting_level) {
     44             if ($subtree instanceof Smarty_Internal_ParseTree_Code) {
     45                 $this->subtrees[$last_subtree]->data = $this->parser->compiler->appendCode($this->subtrees[$last_subtree]->data, '<?php echo ' . $subtree->data . ';?>');
     46             } elseif ($subtree instanceof Smarty_Internal_ParseTree_DqContent) {
     47                 $this->subtrees[$last_subtree]->data = $this->parser->compiler->appendCode($this->subtrees[$last_subtree]->data, '<?php echo "' . $subtree->data . '";?>');
     48             } else {
     49                 $this->subtrees[$last_subtree]->data = $this->parser->compiler->appendCode($this->subtrees[$last_subtree]->data, $subtree->data);
     50             }
     51         } else {
     52             $this->subtrees[] = $subtree;
     53         }
     54         if ($subtree instanceof Smarty_Internal_ParseTree_Tag) {
     55             $this->parser->block_nesting_level = count($this->parser->compiler->_tag_stack);
     56         }
     57     }
     58 
     59     /**
     60      * Merge subtree buffer content together
     61      *
     62      * @return string compiled template code
     63      */
     64     public function to_smarty_php()
     65     {
     66         $code = '';
     67         foreach ($this->subtrees as $subtree) {
     68             if ($code !== "") {
     69                 $code .= ".";
     70             }
     71             if ($subtree instanceof Smarty_Internal_ParseTree_Tag) {
     72                 $more_php = $subtree->assign_to_var();
     73             } else {
     74                 $more_php = $subtree->to_smarty_php();
     75             }
     76 
     77             $code .= $more_php;
     78 
     79             if (!$subtree instanceof Smarty_Internal_ParseTree_DqContent) {
     80                 $this->parser->compiler->has_variable_string = true;
     81             }
     82         }
     83 
     84         return $code;
     85     }
     86 }