|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Smarty Internal Plugin Data |
|
4
|
|
|
* This file contains the basic classes and methods for template and variable creation |
|
5
|
|
|
* |
|
6
|
|
|
* @package Smarty |
|
7
|
|
|
* @subpackage Template |
|
8
|
|
|
* @author Uwe Tews |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Base class with template and variable methods |
|
13
|
|
|
* |
|
14
|
|
|
* @package Smarty |
|
15
|
|
|
* @subpackage Template |
|
16
|
|
|
* |
|
17
|
|
|
* @property int $scope |
|
18
|
|
|
* @property Smarty $smarty |
|
19
|
|
|
* The following methods will be dynamically loaded by the extension handler when they are called. |
|
20
|
|
|
* They are located in a corresponding Smarty_Internal_Method_xxxx class |
|
21
|
|
|
* |
|
22
|
|
|
* @method mixed getConfigVariable(string $varName, bool $errorEnable = true) |
|
23
|
|
|
* @method mixed getConfigVars(string $varName = null, bool $searchParents = true) |
|
24
|
|
|
* @method mixed getGlobal(string $varName = null) |
|
25
|
|
|
* @method mixed getStreamVariable(string $variable) |
|
26
|
|
|
* @method Smarty_Internal_Data clearAssign(mixed $tpl_var) |
|
27
|
|
|
* @method Smarty_Internal_Data clearAllAssign() |
|
28
|
|
|
* @method Smarty_Internal_Data clearConfig(string $varName = null) |
|
29
|
|
|
* @method Smarty_Internal_Data configLoad(string $config_file, mixed $sections = null, string $scope = 'local') |
|
30
|
|
|
*/ |
|
31
|
|
|
class Smarty_Internal_Data |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* This object type (Smarty = 1, template = 2, data = 4) |
|
35
|
|
|
* |
|
36
|
|
|
* @var int |
|
37
|
|
|
*/ |
|
38
|
|
|
public $_objType = 4; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* name of class used for templates |
|
42
|
|
|
* |
|
43
|
|
|
* @var string |
|
44
|
|
|
*/ |
|
45
|
|
|
public $template_class = 'Smarty_Internal_Template'; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* template variables |
|
49
|
|
|
* |
|
50
|
|
|
* @var Smarty_Variable[] |
|
51
|
|
|
*/ |
|
52
|
|
|
public $tpl_vars = array(); |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* parent template (if any) |
|
56
|
|
|
* |
|
57
|
|
|
* @var Smarty|Smarty_Internal_Template|Smarty_Internal_Data |
|
58
|
|
|
*/ |
|
59
|
|
|
public $parent = null; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* configuration settings |
|
63
|
|
|
* |
|
64
|
|
|
* @var string[] |
|
65
|
|
|
*/ |
|
66
|
|
|
public $config_vars = array(); |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* extension handler |
|
70
|
|
|
* |
|
71
|
|
|
* @var Smarty_Internal_Extension_Handler |
|
72
|
|
|
*/ |
|
73
|
|
|
public $ext = null; |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Smarty_Internal_Data constructor. |
|
77
|
|
|
* |
|
78
|
|
|
* Install extension handler |
|
79
|
|
|
*/ |
|
80
|
|
|
public function __construct() |
|
81
|
|
|
{ |
|
82
|
|
|
$this->ext = new Smarty_Internal_Extension_Handler(); |
|
83
|
|
|
$this->ext->objType = $this->_objType; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* assigns a Smarty variable |
|
88
|
|
|
* |
|
89
|
|
|
* @param array|string $tpl_var the template variable name(s) |
|
90
|
|
|
* @param mixed $value the value to assign |
|
91
|
|
|
* @param boolean $nocache if true any output of this variable will be not cached |
|
92
|
|
|
* |
|
93
|
|
|
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for |
|
94
|
|
|
* chaining |
|
95
|
|
|
*/ |
|
96
|
|
|
public function assign($tpl_var, $value = null, $nocache = false) |
|
97
|
|
|
{ |
|
98
|
|
|
if (is_array($tpl_var)) { |
|
99
|
|
|
foreach ($tpl_var as $_key => $_val) { |
|
100
|
|
|
$this->assign($_key, $_val, $nocache); |
|
101
|
|
|
} |
|
102
|
|
|
} else { |
|
103
|
|
|
if ($tpl_var != '') { |
|
104
|
|
|
if ($this->_objType === 2) { |
|
105
|
|
|
/** @var Smarty_Internal_Template $this */ |
|
106
|
|
|
$this->_assignInScope($tpl_var, $value, $nocache); |
|
|
|
|
|
|
107
|
|
|
} else { |
|
108
|
|
|
$this->tpl_vars[ $tpl_var ] = new Smarty_Variable($value, $nocache); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
return $this; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* appends values to template variables |
|
117
|
|
|
* |
|
118
|
|
|
* @api Smarty::append() |
|
119
|
|
|
* @link http://www.smarty.net/docs/en/api.append.tpl |
|
120
|
|
|
* |
|
121
|
|
|
* @param array|string $tpl_var the template variable name(s) |
|
122
|
|
|
* @param mixed $value the value to append |
|
123
|
|
|
* @param bool $merge flag if array elements shall be merged |
|
124
|
|
|
* @param bool $nocache if true any output of this variable will |
|
125
|
|
|
* be not cached |
|
126
|
|
|
* |
|
127
|
|
|
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty |
|
128
|
|
|
*/ |
|
129
|
|
|
public function append($tpl_var, $value = null, $merge = false, $nocache = false) |
|
130
|
|
|
{ |
|
131
|
|
|
return $this->ext->append->append($this, $tpl_var, $value, $merge, $nocache); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* assigns a global Smarty variable |
|
136
|
|
|
* |
|
137
|
|
|
* @param string $varName the global variable name |
|
138
|
|
|
* @param mixed $value the value to assign |
|
139
|
|
|
* @param boolean $nocache if true any output of this variable will be not cached |
|
140
|
|
|
* |
|
141
|
|
|
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty |
|
142
|
|
|
*/ |
|
143
|
|
|
public function assignGlobal($varName, $value = null, $nocache = false) |
|
144
|
|
|
{ |
|
145
|
|
|
return $this->ext->assignGlobal->assignGlobal($this, $varName, $value, $nocache); |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* appends values to template variables by reference |
|
150
|
|
|
* |
|
151
|
|
|
* @param string $tpl_var the template variable name |
|
152
|
|
|
* @param mixed &$value the referenced value to append |
|
153
|
|
|
* @param boolean $merge flag if array elements shall be merged |
|
154
|
|
|
* |
|
155
|
|
|
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty |
|
156
|
|
|
*/ |
|
157
|
|
|
public function appendByRef($tpl_var, &$value, $merge = false) |
|
158
|
|
|
{ |
|
159
|
|
|
return $this->ext->appendByRef->appendByRef($this, $tpl_var, $value, $merge); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* assigns values to template variables by reference |
|
164
|
|
|
* |
|
165
|
|
|
* @param string $tpl_var the template variable name |
|
166
|
|
|
* @param $value |
|
167
|
|
|
* @param boolean $nocache if true any output of this variable will be not cached |
|
168
|
|
|
* |
|
169
|
|
|
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty |
|
170
|
|
|
*/ |
|
171
|
|
|
public function assignByRef($tpl_var, &$value, $nocache = false) |
|
172
|
|
|
{ |
|
173
|
|
|
return $this->ext->assignByRef->assignByRef($this, $tpl_var, $value, $nocache); |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* Returns a single or all template variables |
|
178
|
|
|
* |
|
179
|
|
|
* @api Smarty::getTemplateVars() |
|
180
|
|
|
* @link http://www.smarty.net/docs/en/api.get.template.vars.tpl |
|
181
|
|
|
* |
|
182
|
|
|
* @param string $varName variable name or null |
|
183
|
|
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object |
|
184
|
|
|
* @param bool $searchParents include parent templates? |
|
185
|
|
|
* |
|
186
|
|
|
* @return mixed variable value or or array of variables |
|
187
|
|
|
*/ |
|
188
|
|
|
public function getTemplateVars($varName = null, Smarty_Internal_Data $_ptr = null, $searchParents = true) |
|
189
|
|
|
{ |
|
190
|
|
|
return $this->ext->getTemplateVars->getTemplateVars($this, $varName, $_ptr, $searchParents); |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* gets the object of a Smarty variable |
|
195
|
|
|
* |
|
196
|
|
|
* @param string $variable the name of the Smarty variable |
|
197
|
|
|
* @param Smarty_Internal_Data $_ptr optional pointer to data object |
|
198
|
|
|
* @param boolean $searchParents search also in parent data |
|
199
|
|
|
* @param bool $error_enable |
|
200
|
|
|
* |
|
201
|
|
|
* @return Smarty_Variable|Smarty_Undefined_Variable the object of the variable |
|
202
|
|
|
* @deprecated since 3.1.28 please use Smarty_Internal_Data::getTemplateVars() instead. |
|
203
|
|
|
*/ |
|
204
|
|
|
public function getVariable($variable = null, Smarty_Internal_Data $_ptr = null, $searchParents = true, |
|
205
|
|
|
$error_enable = true) |
|
206
|
|
|
{ |
|
207
|
|
|
return $this->ext->getTemplateVars->_getVariable($this, $variable, $_ptr, $searchParents, $error_enable); |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* Follow the parent chain an merge template and config variables |
|
212
|
|
|
* |
|
213
|
|
|
* @param \Smarty_Internal_Data|null $data |
|
214
|
|
|
*/ |
|
215
|
|
|
public function _mergeVars(Smarty_Internal_Data $data = null) |
|
216
|
|
|
{ |
|
217
|
|
|
if (isset($data)) { |
|
218
|
|
|
if (!empty($this->tpl_vars)) { |
|
219
|
|
|
$data->tpl_vars = array_merge($this->tpl_vars, $data->tpl_vars); |
|
220
|
|
|
} |
|
221
|
|
|
if (!empty($this->config_vars)) { |
|
222
|
|
|
$data->config_vars = array_merge($this->config_vars, $data->config_vars); |
|
223
|
|
|
} |
|
224
|
|
|
} else { |
|
225
|
|
|
$data = $this; |
|
226
|
|
|
} |
|
227
|
|
|
if (isset($this->parent)) { |
|
228
|
|
|
$this->parent->_mergeVars($data); |
|
229
|
|
|
} |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
/** |
|
233
|
|
|
* Return true if this instance is a Data obj |
|
234
|
|
|
* |
|
235
|
|
|
* @return bool |
|
236
|
|
|
*/ |
|
237
|
|
|
public function _isDataObj() |
|
238
|
|
|
{ |
|
239
|
|
|
return $this->_objType === 4; |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
|
|
/** |
|
243
|
|
|
* Return true if this instance is a template obj |
|
244
|
|
|
* |
|
245
|
|
|
* @return bool |
|
246
|
|
|
*/ |
|
247
|
|
|
public function _isTplObj() |
|
248
|
|
|
{ |
|
249
|
|
|
return $this->_objType === 2; |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
/** |
|
253
|
|
|
* Return true if this instance is a Smarty obj |
|
254
|
|
|
* |
|
255
|
|
|
* @return bool |
|
256
|
|
|
*/ |
|
257
|
|
|
public function _isSmartyObj() |
|
258
|
|
|
{ |
|
259
|
|
|
return $this->_objType === 1; |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
/** |
|
263
|
|
|
* Get Smarty object |
|
264
|
|
|
* |
|
265
|
|
|
* @return Smarty |
|
266
|
|
|
*/ |
|
267
|
|
|
public function _getSmartyObj() |
|
268
|
|
|
{ |
|
269
|
|
|
return $this->smarty; |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
/** |
|
273
|
|
|
* Handle unknown class methods |
|
274
|
|
|
* |
|
275
|
|
|
* @param string $name unknown method-name |
|
276
|
|
|
* @param array $args argument array |
|
277
|
|
|
* |
|
278
|
|
|
* @return mixed |
|
279
|
|
|
* @throws SmartyException |
|
280
|
|
|
*/ |
|
281
|
|
|
public function __call($name, $args) |
|
282
|
|
|
{ |
|
283
|
|
|
return $this->ext->_callExternalMethod($this, $name, $args); |
|
284
|
|
|
} |
|
285
|
|
|
} |
|
286
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.