1: | <?php
|
2: |
|
3: | |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: |
|
12: | class Smarty_Internal_Method_Append
|
13: | {
|
14: | |
15: | |
16: | |
17: | |
18: |
|
19: | public $objMap = 7;
|
20: |
|
21: | |
22: | |
23: | |
24: | |
25: | |
26: | |
27: | |
28: | |
29: | |
30: | |
31: | |
32: | |
33: | |
34: | |
35: |
|
36: | public function append(Smarty_Internal_Data $data, $tpl_var, $value = null, $merge = false, $nocache = false)
|
37: | {
|
38: | if (is_array($tpl_var)) {
|
39: |
|
40: | foreach ($tpl_var as $_key => $_val) {
|
41: | if ($_key !== '') {
|
42: | $this->append($data, $_key, $_val, $merge, $nocache);
|
43: | }
|
44: | }
|
45: | } else {
|
46: | if ($tpl_var !== '' && isset($value)) {
|
47: | if (!isset($data->tpl_vars[ $tpl_var ])) {
|
48: | $tpl_var_inst = $data->ext->getTemplateVars->_getVariable($data, $tpl_var, null, true, false);
|
49: | if ($tpl_var_inst instanceof Smarty_Undefined_Variable) {
|
50: | $data->tpl_vars[ $tpl_var ] = new Smarty_Variable(null, $nocache);
|
51: | } else {
|
52: | $data->tpl_vars[ $tpl_var ] = clone $tpl_var_inst;
|
53: | }
|
54: | }
|
55: | if (!(is_array($data->tpl_vars[ $tpl_var ]->value)
|
56: | || $data->tpl_vars[ $tpl_var ]->value instanceof ArrayAccess)
|
57: | ) {
|
58: | settype($data->tpl_vars[ $tpl_var ]->value, 'array');
|
59: | }
|
60: | if ($merge && is_array($value)) {
|
61: | foreach ($value as $_mkey => $_mval) {
|
62: | $data->tpl_vars[ $tpl_var ]->value[ $_mkey ] = $_mval;
|
63: | }
|
64: | } else {
|
65: | $data->tpl_vars[ $tpl_var ]->value[] = $value;
|
66: | }
|
67: | }
|
68: | if ($data->_isTplObj() && $data->scope) {
|
69: | $data->ext->_updateScope->_updateScope($data, $tpl_var);
|
70: | }
|
71: | }
|
72: | return $data;
|
73: | }
|
74: | }
|
75: | |