|
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 * Compiles code for the {append} tag |
|
20 * |
|
21 * @param array $args array with attributes from parser |
|
22 * @param object $compiler compiler object |
|
23 * @param array $parameter array with compilation parameter |
|
24 * |
|
25 * @return string compiled code |
|
26 */ |
|
27 public function compile($args, $compiler, $parameter) { |
|
28 // the following must be assigned at runtime because it will be overwritten in parent class |
|
29 $this->required_attributes = array('var', 'value'); |
|
30 $this->shorttag_order = array('var', 'value'); |
|
31 $this->optional_attributes = array('scope', 'index'); |
|
32 // check and get attributes |
|
33 $_attr = $this->getAttributes($compiler, $args); |
|
34 // map to compile assign attributes |
|
35 if (isset($_attr['index'])) { |
|
36 $_params['smarty_internal_index'] = '[' . $_attr['index'] . ']'; |
|
37 unset($_attr['index']); |
|
38 } else { |
|
39 $_params['smarty_internal_index'] = '[]'; |
|
40 } |
|
41 $_new_attr = array(); |
|
42 foreach ($_attr as $key => $value) { |
|
43 $_new_attr[] = array($key => $value); |
|
44 } |
|
45 // call compile assign |
|
46 return parent::compile($_new_attr, $compiler, $_params); |
|
47 } |
|
48 } |