Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
2809 rexy 1
<?php
2
/**
3
 * Smarty Internal Plugin Compile Append
4
 * Compiles the {append} tag
5
 *
6
 * @package    Smarty
7
 * @subpackage Compiler
8
 * @author     Uwe Tews
9
 */
10
 
11
/**
12
 * Smarty Internal Plugin Compile Append Class
13
 *
14
 * @package    Smarty
15
 * @subpackage Compiler
16
 */
17
class Smarty_Internal_Compile_Append extends Smarty_Internal_Compile_Assign
18
{
19
    /**
20
     * Compiles code for the {append} tag
21
     *
22
     * @param array                                 $args      array with attributes from parser
23
     * @param \Smarty_Internal_TemplateCompilerBase $compiler  compiler object
24
     * @param array                                 $parameter array with compilation parameter
25
     *
26
     * @return string compiled code
27
     * @throws \SmartyCompilerException
28
     */
29
    public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
30
    {
31
        // the following must be assigned at runtime because it will be overwritten in parent class
32
        $this->required_attributes = array('var', 'value');
33
        $this->shorttag_order = array('var', 'value');
34
        $this->optional_attributes = array('scope', 'index');
35
        $this->mapCache = array();
36
        // check and get attributes
37
        $_attr = $this->getAttributes($compiler, $args);
38
        // map to compile assign attributes
39
        if (isset($_attr[ 'index' ])) {
40
            $_params[ 'smarty_internal_index' ] = '[' . $_attr[ 'index' ] . ']';
41
            unset($_attr[ 'index' ]);
42
        } else {
43
            $_params[ 'smarty_internal_index' ] = '[]';
44
        }
45
        $_new_attr = array();
46
        foreach ($_attr as $key => $value) {
47
            $_new_attr[] = array($key => $value);
48
        }
49
        // call compile assign
50
        return parent::compile($_new_attr, $compiler, $_params);
51
    }
52
}