|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* XOOPS template engine class |
|
4
|
|
|
* |
|
5
|
|
|
* You may not change or alter any portion of this comment or credits |
|
6
|
|
|
* of supporting developers from this source code or any supporting source code |
|
7
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
8
|
|
|
* This program is distributed in the hope that it will be useful, |
|
9
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11
|
|
|
* |
|
12
|
|
|
* @copyright (c) 2000-2021 XOOPS Project (https://xoops.org) |
|
13
|
|
|
* @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html) |
|
14
|
|
|
* @author Kazumi Ono <[email protected]> |
|
15
|
|
|
* @author Skalpa Keo <[email protected]> |
|
16
|
|
|
* @author Taiwen Jiang <[email protected]> |
|
17
|
|
|
* @package kernel |
|
18
|
|
|
* @subpackage core |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
defined('XOOPS_ROOT_PATH') || exit('Restricted access'); |
|
22
|
|
|
|
|
23
|
|
|
use \Smarty\Smarty; |
|
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
xoops_loadLanguage('global'); |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Template engine |
|
29
|
|
|
* |
|
30
|
|
|
* @package kernel |
|
31
|
|
|
* @subpackage core |
|
32
|
|
|
* @author Kazumi Ono <[email protected]> |
|
33
|
|
|
* @copyright (c) 2000-2022 XOOPS Project (https://xoops.org) |
|
34
|
|
|
*/ |
|
35
|
|
|
class XoopsTpl extends Smarty |
|
36
|
|
|
{ |
|
37
|
|
|
/** @var xos_opal_Theme */ |
|
38
|
|
|
public $currentTheme; |
|
39
|
|
|
/** |
|
40
|
|
|
* XoopsTpl constructor. |
|
41
|
|
|
*/ |
|
42
|
|
|
public function __construct() |
|
43
|
|
|
{ |
|
44
|
|
|
global $xoopsConfig; |
|
45
|
|
|
|
|
46
|
|
|
parent::__construct(); |
|
47
|
|
|
|
|
48
|
|
|
$this->setLeftDelimiter('<{'); |
|
49
|
|
|
$this->setRightDelimiter('}>'); |
|
50
|
|
|
$this->setTemplateDir(XOOPS_THEME_PATH); |
|
51
|
|
|
$this->setCacheDir(XOOPS_VAR_PATH . '/caches/smarty_cache'); |
|
52
|
|
|
$this->setCompileDir(XOOPS_VAR_PATH . '/caches/smarty_compile'); |
|
53
|
|
|
$this->compile_check = $this::COMPILECHECK_ON; // ($xoopsConfig['theme_fromfile'] == 1); |
|
|
|
|
|
|
54
|
|
|
$this->addPluginsDir(XOOPS_ROOT_PATH . '/class/smarty/plugins/'); |
|
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
// Register the count function |
|
57
|
|
|
$this->registerPlugin('modifier', 'count', 'count'); |
|
58
|
|
|
// Register the strstr function |
|
59
|
|
|
$this->registerPlugin('modifier', 'strstr', 'strstr'); |
|
60
|
|
|
// Register the trim function |
|
61
|
|
|
$this->registerPlugin('modifier', 'trim', 'trim'); |
|
62
|
|
|
|
|
63
|
|
|
if ($xoopsConfig['debug_mode']) { |
|
64
|
|
|
$this->debugging_ctrl = 'URL'; |
|
|
|
|
|
|
65
|
|
|
// $this->debug_tpl = XOOPS_ROOT_PATH . '/class/smarty/xoops_tpl/debug.tpl'; |
|
66
|
|
|
if ($xoopsConfig['debug_mode'] == 3) { |
|
67
|
|
|
$this->debugging = true; |
|
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
$this->setCompileId(); |
|
71
|
|
|
$this->assign( |
|
72
|
|
|
[ |
|
73
|
|
|
'xoops_url' => XOOPS_URL, |
|
74
|
|
|
'xoops_rootpath' => XOOPS_ROOT_PATH, |
|
75
|
|
|
'xoops_langcode' => _LANGCODE, |
|
76
|
|
|
'xoops_charset' => _CHARSET, |
|
77
|
|
|
'xoops_version' => XOOPS_VERSION, |
|
78
|
|
|
'xoops_upload_url' => XOOPS_UPLOAD_URL, |
|
79
|
|
|
], |
|
80
|
|
|
); |
|
81
|
|
|
$xoopsPreload = XoopsPreload::getInstance(); |
|
82
|
|
|
$xoopsPreload->triggerEvent('core.class.template.new', [$this]); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Adds directory of plugin files |
|
87
|
|
|
* |
|
88
|
|
|
* @param null|array|string $path |
|
89
|
|
|
* |
|
90
|
|
|
* @return static current Smarty instance for chaining |
|
91
|
|
|
* @deprecated since 5.0 |
|
92
|
|
|
*/ |
|
93
|
|
|
public function addPluginsDir($path) { |
|
94
|
|
|
|
|
95
|
|
|
foreach([ |
|
96
|
|
|
'function', |
|
97
|
|
|
'modifier', |
|
98
|
|
|
'block', |
|
99
|
|
|
'compiler', |
|
100
|
|
|
'prefilter', |
|
101
|
|
|
'postfilter', |
|
102
|
|
|
'outputfilter' |
|
103
|
|
|
] as $type) { |
|
104
|
|
|
foreach (glob($path . $type . '.?*.php') as $filename) { |
|
|
|
|
|
|
105
|
|
|
$pluginName = $this->getPluginNameFromFilename($filename); |
|
106
|
|
|
if ($pluginName !== null) { |
|
107
|
|
|
require_once $filename; |
|
108
|
|
|
$functionOrClassName = 'smarty_' . $type . '_' . $pluginName; |
|
109
|
|
|
if (function_exists($functionOrClassName) || class_exists($functionOrClassName)) { |
|
110
|
|
|
$this->registerPlugin($type, $pluginName, $functionOrClassName, true, []); |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
$type = 'resource'; |
|
117
|
|
|
foreach (glob($path . $type . '.?*.php') as $filename) { |
|
118
|
|
|
$pluginName = $this->getPluginNameFromFilename($filename); |
|
119
|
|
|
if ($pluginName !== null) { |
|
120
|
|
|
require_once $filename; |
|
121
|
|
|
if (class_exists($className = 'Smarty_' . ucfirst($type) . '_' . ucfirst($pluginName))) { |
|
122
|
|
|
$this->registerResource($pluginName, new $className()); |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
return $this; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* Renders output from template data |
|
132
|
|
|
* |
|
133
|
|
|
* @param string $tplSource The template to render |
|
134
|
|
|
* @param bool $display If rendered text should be output or returned |
|
135
|
|
|
* @param null $vars |
|
|
|
|
|
|
136
|
|
|
* |
|
137
|
|
|
* @return string Rendered output if $display was false |
|
138
|
|
|
*/ |
|
139
|
|
|
public function fetchFromData($tplSource, $display = false, $vars = null) |
|
140
|
|
|
{ |
|
141
|
|
|
if (!function_exists('smarty_function_eval')) { |
|
142
|
|
|
require_once SMARTY_DIR . '/plugins/function.eval.php'; |
|
|
|
|
|
|
143
|
|
|
} |
|
144
|
|
|
if (isset($vars)) { |
|
145
|
|
|
$oldVars = $this->_tpl_vars; |
|
146
|
|
|
$this->assign($vars); |
|
147
|
|
|
$out = smarty_function_eval( |
|
148
|
|
|
[ |
|
149
|
|
|
'var' => $tplSource, |
|
150
|
|
|
], |
|
151
|
|
|
$this, |
|
152
|
|
|
); |
|
153
|
|
|
$this->_tpl_vars = $oldVars; |
|
|
|
|
|
|
154
|
|
|
|
|
155
|
|
|
return $out; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
return smarty_function_eval( |
|
159
|
|
|
[ |
|
160
|
|
|
'var' => $tplSource, |
|
161
|
|
|
], |
|
162
|
|
|
$this, |
|
163
|
|
|
); |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* @param $filename |
|
168
|
|
|
* |
|
169
|
|
|
* @return string|null |
|
170
|
|
|
*/ |
|
171
|
|
|
private function getPluginNameFromFilename($filename) { |
|
172
|
|
|
if (!preg_match('/.*\.([a-z_A-Z0-9]+)\.php$/',$filename,$matches)) { |
|
173
|
|
|
return null; |
|
174
|
|
|
} |
|
175
|
|
|
return $matches[1]; |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* XoopsTpl::touch |
|
180
|
|
|
* |
|
181
|
|
|
* @param mixed $resourceName |
|
182
|
|
|
* @return bool |
|
183
|
|
|
*/ |
|
184
|
|
|
public function xoopsTouch($resourceName) |
|
185
|
|
|
{ |
|
186
|
|
|
//$result = $this->compileAllTemplates($resourceName, true); // May be necessary? |
|
187
|
|
|
$this->clearCache($resourceName); |
|
188
|
|
|
return true; |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
/** |
|
192
|
|
|
* returns an auto_id for auto-file-functions |
|
193
|
|
|
* |
|
194
|
|
|
* @param string $cache_id |
|
195
|
|
|
* @param string $compile_id |
|
196
|
|
|
* @return string |null |
|
197
|
|
|
*/ |
|
198
|
|
|
public function _get_auto_id($cache_id = null, $compile_id = null) |
|
199
|
|
|
{ |
|
200
|
|
|
if (isset($cache_id)) { |
|
201
|
|
|
return isset($compile_id) ? $compile_id . '-' . $cache_id : $cache_id; |
|
202
|
|
|
} elseif (isset($compile_id)) { |
|
203
|
|
|
return $compile_id; |
|
204
|
|
|
} else { |
|
205
|
|
|
return null; |
|
206
|
|
|
} |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/** |
|
210
|
|
|
* XoopsTpl::setCompileId() |
|
211
|
|
|
* |
|
212
|
|
|
* @param mixed $module_dirname |
|
213
|
|
|
* @param mixed $theme_set |
|
214
|
|
|
* @param mixed $template_set |
|
215
|
|
|
* @return void |
|
216
|
|
|
*/ |
|
217
|
|
|
public function setCompileId($module_dirname = null, $theme_set = null, $template_set = null) |
|
218
|
|
|
{ |
|
219
|
|
|
global $xoopsConfig; |
|
220
|
|
|
|
|
221
|
|
|
$template_set = empty($template_set) ? $xoopsConfig['template_set'] : $template_set; |
|
222
|
|
|
$theme_set = empty($theme_set) ? $xoopsConfig['theme_set'] : $theme_set; |
|
223
|
|
|
if (class_exists('XoopsSystemCpanel', false)) { |
|
224
|
|
|
$cPrefix = 'cp-'; |
|
225
|
|
|
$theme_set = isset($xoopsConfig['cpanel']) ? $cPrefix . $xoopsConfig['cpanel'] : $cPrefix . 'default'; |
|
226
|
|
|
} |
|
227
|
|
|
$module_dirname = empty($module_dirname) ? (empty($GLOBALS['xoopsModule']) ? 'system' : $GLOBALS['xoopsModule']->getVar('dirname', 'n')) : $module_dirname; |
|
228
|
|
|
$this->compile_id = substr(md5(XOOPS_URL), 0, 8) . '-' . $module_dirname . '-' . $theme_set . '-' . $template_set; |
|
|
|
|
|
|
229
|
|
|
//$this->_compile_id = $this->compile_id; |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
/** |
|
233
|
|
|
* XoopsTpl::clearCache() |
|
234
|
|
|
* |
|
235
|
|
|
* @param mixed $module_dirname |
|
236
|
|
|
* @param mixed $theme_set |
|
237
|
|
|
* @param mixed $template_set |
|
238
|
|
|
* @return bool |
|
239
|
|
|
*/ |
|
240
|
|
|
public function xoopsClearCache($module_dirname = null, $theme_set = null, $template_set = null) |
|
241
|
|
|
{ |
|
242
|
|
|
$compile_id = $this->compile_id; |
|
243
|
|
|
$this->setCompileId($module_dirname, $template_set, $theme_set); |
|
244
|
|
|
return $this->clearCompiledTemplate(null, $compile_id); |
|
245
|
|
|
} |
|
246
|
|
|
|
|
247
|
|
|
/** |
|
248
|
|
|
* |
|
249
|
|
|
* @deprecated DO NOT USE THESE METHODS, ACCESS THE CORRESPONDING PROPERTIES INSTEAD |
|
250
|
|
|
* @param $dirname |
|
251
|
|
|
*/ |
|
252
|
|
|
public function xoops_setTemplateDir($dirname) |
|
253
|
|
|
{ |
|
254
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . '($value) is deprecated since XOOPS 2.5.4, please use \'$xoopsTpl->template_dir=$value;\' instead.'); |
|
255
|
|
|
|
|
256
|
|
|
$this->template_dir = $dirname; |
|
|
|
|
|
|
257
|
|
|
} |
|
258
|
|
|
|
|
259
|
|
|
/** |
|
260
|
|
|
* @deprecated DO NOT USE THESE METHODS, ACCESS THE CORRESPONDING PROPERTIES INSTEAD |
|
261
|
|
|
* @return string |
|
262
|
|
|
*/ |
|
263
|
|
|
public function xoops_getTemplateDir() |
|
264
|
|
|
{ |
|
265
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . '() is deprecated since XOOPS 2.5.4, please use \'$xoopsTpl->template_dir;\' instead.'); |
|
266
|
|
|
|
|
267
|
|
|
return $this->template_dir; |
|
268
|
|
|
} |
|
269
|
|
|
|
|
270
|
|
|
/** |
|
271
|
|
|
* @deprecated DO NOT USE THESE METHODS, ACCESS THE CORRESPONDING PROPERTIES INSTEAD |
|
272
|
|
|
* @param bool $flag |
|
273
|
|
|
*/ |
|
274
|
|
|
public function xoops_setDebugging($flag = false) |
|
275
|
|
|
{ |
|
276
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . '($value) is deprecated since XOOPS 2.5.4, please use \'$xoopsTpl->debugging=$value;\' instead.'); |
|
277
|
|
|
|
|
278
|
|
|
$this->debugging = is_bool($flag) ? $flag : false; |
|
|
|
|
|
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
|
|
/** |
|
282
|
|
|
* @deprecated DO NOT USE THESE METHODS, ACCESS THE CORRESPONDING PROPERTIES INSTEAD |
|
283
|
|
|
* @param int $num |
|
284
|
|
|
*/ |
|
285
|
|
|
public function xoops_setCaching($num = 0) |
|
286
|
|
|
{ |
|
287
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . '($value) is deprecated since XOOPS 2.5.4, please use \'$xoopsTpl->caching=$value;\' instead.'); |
|
288
|
|
|
|
|
289
|
|
|
$this->caching = (int) $num; |
|
|
|
|
|
|
290
|
|
|
} |
|
291
|
|
|
|
|
292
|
|
|
/** |
|
293
|
|
|
* @deprecated DO NOT USE THESE METHODS, ACCESS THE CORRESPONDING PROPERTIES INSTEAD |
|
294
|
|
|
* @param $dirname |
|
295
|
|
|
*/ |
|
296
|
|
|
public function xoops_setCompileDir($dirname) |
|
297
|
|
|
{ |
|
298
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . '($value) is deprecated since XOOPS 2.5.4, please use \'$xoopsTpl->compile_dir=$value;\' instead.'); |
|
299
|
|
|
|
|
300
|
|
|
$this->compile_dir = $dirname; |
|
|
|
|
|
|
301
|
|
|
} |
|
302
|
|
|
|
|
303
|
|
|
/** |
|
304
|
|
|
* @deprecated DO NOT USE THESE METHODS, ACCESS THE CORRESPONDING PROPERTIES INSTEAD |
|
305
|
|
|
* @param $dirname |
|
306
|
|
|
*/ |
|
307
|
|
|
public function xoops_setCacheDir($dirname) |
|
308
|
|
|
{ |
|
309
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . '($value) is deprecated since XOOPS 2.5.4, please use \'$xoopsTpl->cache_dir=$value;\' instead.'); |
|
310
|
|
|
|
|
311
|
|
|
$this->cache_dir = $dirname; |
|
|
|
|
|
|
312
|
|
|
} |
|
313
|
|
|
|
|
314
|
|
|
/** |
|
315
|
|
|
* @deprecated DO NOT USE THESE METHODS, ACCESS THE CORRESPONDING PROPERTIES INSTEAD |
|
316
|
|
|
* @return bool |
|
317
|
|
|
*/ |
|
318
|
|
|
public function xoops_canUpdateFromFile() |
|
319
|
|
|
{ |
|
320
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . '($value) is deprecated since XOOPS 2.5.4, please use \'$xoopsTpl->compile_check;\' instead.'); |
|
321
|
|
|
|
|
322
|
|
|
return $this->compile_check; |
|
323
|
|
|
} |
|
324
|
|
|
|
|
325
|
|
|
/** |
|
326
|
|
|
* @deprecated DO NOT USE THESE METHODS, ACCESS THE CORRESPONDING PROPERTIES INSTEAD |
|
327
|
|
|
* @param $data |
|
328
|
|
|
* |
|
329
|
|
|
* @return string |
|
330
|
|
|
*/ |
|
331
|
|
|
public function xoops_fetchFromData($data) |
|
332
|
|
|
{ |
|
333
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . '($value) is deprecated since XOOPS 2.5.4, please use \'$xoopsTpl->fetchFromData($value);\' instead.'); |
|
334
|
|
|
|
|
335
|
|
|
return $this->fetchFromData($data); |
|
336
|
|
|
} |
|
337
|
|
|
|
|
338
|
|
|
/** |
|
339
|
|
|
* @deprecated DO NOT USE THESE METHODS, ACCESS THE CORRESPONDING PROPERTIES INSTEAD |
|
340
|
|
|
* @param int $num |
|
341
|
|
|
*/ |
|
342
|
|
|
public function xoops_setCacheTime($num = 0) |
|
343
|
|
|
{ |
|
344
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . '($value) is deprecated since XOOPS 2.5.4, please use \'$xoopsTpl->cache_lifetime=$value;\' instead.'); |
|
345
|
|
|
|
|
346
|
|
|
if (($num = (int) $num) <= 0) { |
|
347
|
|
|
$this->caching = 0; |
|
|
|
|
|
|
348
|
|
|
} else { |
|
349
|
|
|
$this->cache_lifetime = $num; |
|
|
|
|
|
|
350
|
|
|
} |
|
351
|
|
|
} |
|
352
|
|
|
|
|
353
|
|
|
/** |
|
354
|
|
|
* deprecated assign_by_ref |
|
355
|
|
|
* |
|
356
|
|
|
* @param string $tpl_var the template variable name |
|
357
|
|
|
* @param mixed &$value the referenced value to assign |
|
358
|
|
|
*/ |
|
359
|
|
|
public function assign_by_ref($tpl_var, &$value) |
|
360
|
|
|
{ |
|
361
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use assignByRef"); |
|
362
|
|
|
$this->assignByRef($tpl_var, $value); |
|
363
|
|
|
} |
|
364
|
|
|
|
|
365
|
|
|
/** |
|
366
|
|
|
* deprecated assignByRef |
|
367
|
|
|
* |
|
368
|
|
|
* @param string $tpl_var the template variable name |
|
369
|
|
|
* @param mixed &$value the referenced value to assign |
|
370
|
|
|
*/ |
|
371
|
|
|
public function assignByRef($tpl_var, &$value) |
|
372
|
|
|
{ |
|
373
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use assign"); |
|
374
|
|
|
$this->assign($tpl_var, $value); |
|
375
|
|
|
} |
|
376
|
|
|
|
|
377
|
|
|
/** |
|
378
|
|
|
* deprecated append_by_ref |
|
379
|
|
|
* |
|
380
|
|
|
* @param string $tpl_var the template variable name |
|
381
|
|
|
* @param mixed &$value the referenced value to append |
|
382
|
|
|
* @param boolean $merge flag if array elements shall be merged |
|
383
|
|
|
*/ |
|
384
|
|
|
public function append_by_ref($tpl_var, &$value, $merge = false) |
|
385
|
|
|
{ |
|
386
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use appendByRef"); |
|
387
|
|
|
$this->appendByRef($tpl_var, $value, $merge); |
|
388
|
|
|
} |
|
389
|
|
|
|
|
390
|
|
|
/** |
|
391
|
|
|
* deprecated appendByRef |
|
392
|
|
|
* |
|
393
|
|
|
* @param string $tpl_var the template variable name |
|
394
|
|
|
* @param mixed &$value the referenced value to append |
|
395
|
|
|
* @param boolean $merge flag if array elements shall be merged |
|
396
|
|
|
*/ |
|
397
|
|
|
public function appendByRef($tpl_var, &$value, $merge = false) |
|
398
|
|
|
{ |
|
399
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use appendByRef"); |
|
400
|
|
|
$this->append($tpl_var, $value, $merge); |
|
401
|
|
|
} |
|
402
|
|
|
|
|
403
|
|
|
/** |
|
404
|
|
|
* deprecated clear_assign |
|
405
|
|
|
* |
|
406
|
|
|
* @param string $tpl_var the template variable to clear |
|
407
|
|
|
*/ |
|
408
|
|
|
public function clear_assign($tpl_var) |
|
409
|
|
|
{ |
|
410
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use clearAssign"); |
|
411
|
|
|
$this->clearAssign($tpl_var); |
|
412
|
|
|
} |
|
413
|
|
|
|
|
414
|
|
|
/** |
|
415
|
|
|
* deprecated register_function |
|
416
|
|
|
* |
|
417
|
|
|
* @param string $function the name of the template function |
|
418
|
|
|
* @param string $function_impl the name of the PHP function to register |
|
419
|
|
|
* @param bool $cacheable |
|
420
|
|
|
* @param mixed $cache_attrs |
|
421
|
|
|
* |
|
422
|
|
|
* @throws \SmartyException |
|
423
|
|
|
*/ |
|
424
|
|
|
public function register_function($function, $function_impl, $cacheable = true, $cache_attrs = null) |
|
425
|
|
|
{ |
|
426
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use registerPlugin"); |
|
427
|
|
|
$this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs); |
|
428
|
|
|
} |
|
429
|
|
|
|
|
430
|
|
|
/** |
|
431
|
|
|
* deprecated unregister_function |
|
432
|
|
|
* |
|
433
|
|
|
* @param string $function name of template function |
|
434
|
|
|
*/ |
|
435
|
|
|
public function unregister_function($function) |
|
436
|
|
|
{ |
|
437
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use unregisterPlugin"); |
|
438
|
|
|
$this->unregisterPlugin('function', $function); |
|
439
|
|
|
} |
|
440
|
|
|
|
|
441
|
|
|
/** |
|
442
|
|
|
* deprecated register_object |
|
443
|
|
|
* |
|
444
|
|
|
* @param string $object name of template object |
|
445
|
|
|
* @param object $object_impl the referenced PHP object to register |
|
446
|
|
|
* @param array $allowed list of allowed methods (empty = all) |
|
447
|
|
|
* @param boolean $smarty_args smarty argument format, else traditional |
|
448
|
|
|
* @param array $block_methods list of methods that are block format |
|
449
|
|
|
* |
|
450
|
|
|
* @throws SmartyException |
|
451
|
|
|
* @internal param array $block_functs list of methods that are block format |
|
452
|
|
|
*/ |
|
453
|
|
|
public function register_object( |
|
454
|
|
|
$object, |
|
455
|
|
|
$object_impl, |
|
456
|
|
|
$allowed = [], |
|
457
|
|
|
$smarty_args = true, |
|
458
|
|
|
$block_methods = [] |
|
459
|
|
|
) { |
|
460
|
|
|
$allowed = (array)$allowed; |
|
461
|
|
|
$smarty_args = (bool)$smarty_args; |
|
462
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use registerObject"); |
|
463
|
|
|
$this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods); |
|
464
|
|
|
} |
|
465
|
|
|
|
|
466
|
|
|
/** |
|
467
|
|
|
* deprecated unregister_object |
|
468
|
|
|
* |
|
469
|
|
|
* @param string $object name of template object |
|
470
|
|
|
*/ |
|
471
|
|
|
public function unregister_object($object) |
|
472
|
|
|
{ |
|
473
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use unregisterObject"); |
|
474
|
|
|
$this->unregisterObject($object); |
|
475
|
|
|
} |
|
476
|
|
|
|
|
477
|
|
|
/** |
|
478
|
|
|
* deprecated register_block |
|
479
|
|
|
* |
|
480
|
|
|
* @param string $block name of template block |
|
481
|
|
|
* @param string $block_impl PHP function to register |
|
482
|
|
|
* @param bool $cacheable |
|
483
|
|
|
* @param mixed $cache_attrs |
|
484
|
|
|
* |
|
485
|
|
|
* @throws \SmartyException |
|
486
|
|
|
*/ |
|
487
|
|
|
public function register_block($block, $block_impl, $cacheable = true, $cache_attrs = null) |
|
488
|
|
|
{ |
|
489
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use registerPlugin"); |
|
490
|
|
|
$this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs); |
|
491
|
|
|
} |
|
492
|
|
|
|
|
493
|
|
|
/** |
|
494
|
|
|
* deprecated unregister_block |
|
495
|
|
|
* |
|
496
|
|
|
* @param string $block name of template function |
|
497
|
|
|
*/ |
|
498
|
|
|
public function unregister_block($block) |
|
499
|
|
|
{ |
|
500
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use unregisterPlugin"); |
|
501
|
|
|
$this->unregisterPlugin('block', $block); |
|
502
|
|
|
} |
|
503
|
|
|
|
|
504
|
|
|
/** |
|
505
|
|
|
* deprecated register_compiler_function |
|
506
|
|
|
* |
|
507
|
|
|
* @param string $function name of template function |
|
508
|
|
|
* @param string $function_impl name of PHP function to register |
|
509
|
|
|
* @param bool $cacheable |
|
510
|
|
|
* |
|
511
|
|
|
* @throws \SmartyException |
|
512
|
|
|
*/ |
|
513
|
|
|
public function register_compiler_function($function, $function_impl, $cacheable = true) |
|
514
|
|
|
{ |
|
515
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use registerPlugin"); |
|
516
|
|
|
$this->registerPlugin('compiler', $function, $function_impl, $cacheable); |
|
517
|
|
|
} |
|
518
|
|
|
|
|
519
|
|
|
/** |
|
520
|
|
|
* deprecated unregister_compiler_function |
|
521
|
|
|
* |
|
522
|
|
|
* @param string $function name of template function |
|
523
|
|
|
*/ |
|
524
|
|
|
public function unregister_compiler_function($function) |
|
525
|
|
|
{ |
|
526
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use unregisterPlugin"); |
|
527
|
|
|
$this->unregisterPlugin('compiler', $function); |
|
528
|
|
|
} |
|
529
|
|
|
|
|
530
|
|
|
/** |
|
531
|
|
|
* deprecated register_modifier |
|
532
|
|
|
* |
|
533
|
|
|
* @param string $modifier name of template modifier |
|
534
|
|
|
* @param string $modifier_impl name of PHP function to register |
|
535
|
|
|
* |
|
536
|
|
|
* @throws \SmartyException |
|
537
|
|
|
*/ |
|
538
|
|
|
public function register_modifier($modifier, $modifier_impl) |
|
539
|
|
|
{ |
|
540
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use registerPlugin"); |
|
541
|
|
|
$this->registerPlugin('modifier', $modifier, $modifier_impl); |
|
542
|
|
|
} |
|
543
|
|
|
|
|
544
|
|
|
/** |
|
545
|
|
|
* deprecated unregister_modifier |
|
546
|
|
|
* |
|
547
|
|
|
* @param string $modifier name of template modifier |
|
548
|
|
|
*/ |
|
549
|
|
|
public function unregister_modifier($modifier) |
|
550
|
|
|
{ |
|
551
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use unregisterPlugin"); |
|
552
|
|
|
$this->unregisterPlugin('modifier', $modifier); |
|
553
|
|
|
} |
|
554
|
|
|
|
|
555
|
|
|
/** |
|
556
|
|
|
* deprecated register_resource |
|
557
|
|
|
* |
|
558
|
|
|
* @param string $type name of resource |
|
559
|
|
|
* @param array $functions array of functions to handle resource |
|
560
|
|
|
*/ |
|
561
|
|
|
public function register_resource($type, $functions) |
|
562
|
|
|
{ |
|
563
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use registerResource"); |
|
564
|
|
|
$this->registerResource($type, $functions); |
|
565
|
|
|
} |
|
566
|
|
|
|
|
567
|
|
|
/** |
|
568
|
|
|
* deprecated unregister_resource |
|
569
|
|
|
* |
|
570
|
|
|
* @param string $type name of resource |
|
571
|
|
|
*/ |
|
572
|
|
|
public function unregister_resource($type) |
|
573
|
|
|
{ |
|
574
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use unregisterResource"); |
|
575
|
|
|
$this->unregisterResource($type); |
|
576
|
|
|
} |
|
577
|
|
|
|
|
578
|
|
|
/** |
|
579
|
|
|
* deprecated register_prefilter |
|
580
|
|
|
* |
|
581
|
|
|
* @param callable $function |
|
582
|
|
|
* |
|
583
|
|
|
* @throws \SmartyException |
|
584
|
|
|
*/ |
|
585
|
|
|
public function register_prefilter($function) |
|
586
|
|
|
{ |
|
587
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use registerFilter"); |
|
588
|
|
|
$this->registerFilter('pre', $function); |
|
589
|
|
|
} |
|
590
|
|
|
|
|
591
|
|
|
/** |
|
592
|
|
|
* deprecated unregister_prefilter |
|
593
|
|
|
* |
|
594
|
|
|
* @param callable $function |
|
595
|
|
|
*/ |
|
596
|
|
|
public function unregister_prefilter($function) |
|
597
|
|
|
{ |
|
598
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use unregisterFilter"); |
|
599
|
|
|
$this->unregisterFilter('pre', $function); |
|
600
|
|
|
} |
|
601
|
|
|
|
|
602
|
|
|
/** |
|
603
|
|
|
* deprecated register_postfilter |
|
604
|
|
|
* |
|
605
|
|
|
* @param callable $function |
|
606
|
|
|
* |
|
607
|
|
|
* @throws \SmartyException |
|
608
|
|
|
*/ |
|
609
|
|
|
public function register_postfilter($function) |
|
610
|
|
|
{ |
|
611
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use registerFilter"); |
|
612
|
|
|
$this->registerFilter('post', $function); |
|
613
|
|
|
} |
|
614
|
|
|
|
|
615
|
|
|
/** |
|
616
|
|
|
* deprecated unregister_postfilter |
|
617
|
|
|
* |
|
618
|
|
|
* @param callable $function |
|
619
|
|
|
*/ |
|
620
|
|
|
public function unregister_postfilter($function) |
|
621
|
|
|
{ |
|
622
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use unregisterFilter"); |
|
623
|
|
|
$this->unregisterFilter('post', $function); |
|
624
|
|
|
} |
|
625
|
|
|
|
|
626
|
|
|
/** |
|
627
|
|
|
* deprecated register_outputfilter |
|
628
|
|
|
* |
|
629
|
|
|
* @param callable $function |
|
630
|
|
|
* |
|
631
|
|
|
* @throws \SmartyException |
|
632
|
|
|
*/ |
|
633
|
|
|
public function register_outputfilter($function) |
|
634
|
|
|
{ |
|
635
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use registerFilter"); |
|
636
|
|
|
$this->registerFilter('output', $function); |
|
637
|
|
|
} |
|
638
|
|
|
|
|
639
|
|
|
/** |
|
640
|
|
|
* deprecated unregister_outputfilter |
|
641
|
|
|
* |
|
642
|
|
|
* @param callable $function |
|
643
|
|
|
*/ |
|
644
|
|
|
public function unregister_outputfilter($function) |
|
645
|
|
|
{ |
|
646
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use unregisterFilter"); |
|
647
|
|
|
$this->unregisterFilter('output', $function); |
|
648
|
|
|
} |
|
649
|
|
|
|
|
650
|
|
|
/** |
|
651
|
|
|
* deprecated load_filter |
|
652
|
|
|
* |
|
653
|
|
|
* @param string $type filter type |
|
654
|
|
|
* @param string $name filter name |
|
655
|
|
|
* |
|
656
|
|
|
* @throws \SmartyException |
|
657
|
|
|
*/ |
|
658
|
|
|
public function load_filter($type, $name) |
|
659
|
|
|
{ |
|
660
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use loadFilter"); |
|
661
|
|
|
$this->loadFilter($type, $name); |
|
662
|
|
|
} |
|
663
|
|
|
|
|
664
|
|
|
/** |
|
665
|
|
|
* deprecated clear_cache |
|
666
|
|
|
* |
|
667
|
|
|
* @param string $tpl_file name of template file |
|
668
|
|
|
* @param string $cache_id name of cache_id |
|
669
|
|
|
* @param string $compile_id name of compile_id |
|
670
|
|
|
* @param string $exp_time expiration time |
|
671
|
|
|
* |
|
672
|
|
|
* @return boolean |
|
673
|
|
|
*/ |
|
674
|
|
|
public function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null) |
|
675
|
|
|
{ |
|
676
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use clearCache"); |
|
677
|
|
|
return $this->clearCache($tpl_file, $cache_id, $compile_id, $exp_time); |
|
678
|
|
|
} |
|
679
|
|
|
|
|
680
|
|
|
/** |
|
681
|
|
|
* deprecated clear_all_cache |
|
682
|
|
|
* |
|
683
|
|
|
* @param string $exp_time expire time |
|
684
|
|
|
* |
|
685
|
|
|
* @return boolean |
|
686
|
|
|
*/ |
|
687
|
|
|
public function clear_all_cache($exp_time = null) |
|
688
|
|
|
{ |
|
689
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use clearCache"); |
|
690
|
|
|
return $this->clearCache(null, null, null, $exp_time); |
|
691
|
|
|
} |
|
692
|
|
|
|
|
693
|
|
|
/** |
|
694
|
|
|
* deprecated is_cached |
|
695
|
|
|
* |
|
696
|
|
|
* @param string $tpl_file name of template file |
|
697
|
|
|
* @param string $cache_id |
|
698
|
|
|
* @param string $compile_id |
|
699
|
|
|
* |
|
700
|
|
|
* @return bool |
|
701
|
|
|
* @throws \Exception |
|
702
|
|
|
* @throws \SmartyException |
|
703
|
|
|
*/ |
|
704
|
|
|
public function is_cached($tpl_file, $cache_id = null, $compile_id = null) |
|
705
|
|
|
{ |
|
706
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use isCached"); |
|
707
|
|
|
return $this->isCached($tpl_file, $cache_id, $compile_id); |
|
708
|
|
|
} |
|
709
|
|
|
|
|
710
|
|
|
/** |
|
711
|
|
|
* deprecated clear_all_assign |
|
712
|
|
|
*/ |
|
713
|
|
|
public function clear_all_assign() |
|
714
|
|
|
{ |
|
715
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use clearAllAssign"); |
|
716
|
|
|
$this->clearAllAssign(); |
|
717
|
|
|
} |
|
718
|
|
|
|
|
719
|
|
|
/** |
|
720
|
|
|
* deprecated clear_compiled_tpl |
|
721
|
|
|
* |
|
722
|
|
|
* @param string $tpl_file |
|
723
|
|
|
* @param string $compile_id |
|
724
|
|
|
* @param string $exp_time |
|
725
|
|
|
* |
|
726
|
|
|
* @return boolean results of {@link smarty_core_rm_auto()} |
|
727
|
|
|
*/ |
|
728
|
|
|
public function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null) |
|
729
|
|
|
{ |
|
730
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use clearCompiledTemplate"); |
|
731
|
|
|
return $this->clearCompiledTemplate($tpl_file, $compile_id, $exp_time); |
|
732
|
|
|
} |
|
733
|
|
|
|
|
734
|
|
|
/** |
|
735
|
|
|
* deprecated template_exists |
|
736
|
|
|
* |
|
737
|
|
|
* @param string $tpl_file |
|
738
|
|
|
* |
|
739
|
|
|
* @return bool |
|
740
|
|
|
* @throws \SmartyException |
|
741
|
|
|
*/ |
|
742
|
|
|
public function template_exists($tpl_file) |
|
743
|
|
|
{ |
|
744
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use templateExists"); |
|
745
|
|
|
return $this->templateExists($tpl_file); |
|
746
|
|
|
} |
|
747
|
|
|
|
|
748
|
|
|
/** |
|
749
|
|
|
* deprecated get_template_vars |
|
750
|
|
|
* |
|
751
|
|
|
* @param string $name |
|
752
|
|
|
* |
|
753
|
|
|
* @return array |
|
754
|
|
|
*/ |
|
755
|
|
|
public function get_template_vars($name = null) |
|
756
|
|
|
{ |
|
757
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use getTemplateVars"); |
|
758
|
|
|
return $this->getTemplateVars($name); |
|
759
|
|
|
} |
|
760
|
|
|
|
|
761
|
|
|
/** |
|
762
|
|
|
* deprecated get_config_vars |
|
763
|
|
|
* |
|
764
|
|
|
* @param string $name |
|
765
|
|
|
* |
|
766
|
|
|
* @return array |
|
767
|
|
|
*/ |
|
768
|
|
|
public function get_config_vars($name = null) |
|
769
|
|
|
{ |
|
770
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use getConfigVars"); |
|
771
|
|
|
return $this->getConfigVars($name); |
|
772
|
|
|
} |
|
773
|
|
|
|
|
774
|
|
|
/** |
|
775
|
|
|
* deprecated config_load |
|
776
|
|
|
* |
|
777
|
|
|
* @param string $file |
|
778
|
|
|
* @param string $section |
|
779
|
|
|
* @param string $scope |
|
780
|
|
|
*/ |
|
781
|
|
|
public function config_load($file, $section = null, $scope = 'global') |
|
782
|
|
|
{ |
|
783
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use ConfigLoad"); |
|
784
|
|
|
$this->ConfigLoad($file, $section, $scope); |
|
785
|
|
|
} |
|
786
|
|
|
|
|
787
|
|
|
/** |
|
788
|
|
|
* deprecated get_registered_object |
|
789
|
|
|
* |
|
790
|
|
|
* @param string $name |
|
791
|
|
|
* |
|
792
|
|
|
* @return object |
|
793
|
|
|
*/ |
|
794
|
|
|
public function get_registered_object($name) |
|
795
|
|
|
{ |
|
796
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use getRegisteredObject"); |
|
797
|
|
|
return $this->getRegisteredObject($name); |
|
798
|
|
|
} |
|
799
|
|
|
|
|
800
|
|
|
/** |
|
801
|
|
|
* deprecated clear_config |
|
802
|
|
|
* |
|
803
|
|
|
* @param string $var |
|
804
|
|
|
*/ |
|
805
|
|
|
public function clear_config($var = null) |
|
806
|
|
|
{ |
|
807
|
|
|
$GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . " is deprecated, please use clearConfig"); |
|
808
|
|
|
$this->clearConfig($var); |
|
809
|
|
|
} |
|
810
|
|
|
} |
|
811
|
|
|
|
|
812
|
|
|
/** |
|
813
|
|
|
* function to update compiled template file in templates_c folder |
|
814
|
|
|
* |
|
815
|
|
|
* @param string $tpl_id |
|
816
|
|
|
* @param boolean $clear_old |
|
817
|
|
|
* @return boolean |
|
818
|
|
|
*/ |
|
819
|
|
|
function xoops_template_touch($tpl_id) |
|
820
|
|
|
{ |
|
821
|
|
|
$tplfile_handler = xoops_getHandler('tplfile'); |
|
822
|
|
|
$tplfile = $tplfile_handler->get((int) $tpl_id); |
|
823
|
|
|
|
|
824
|
|
|
if (is_object($tplfile)) { |
|
825
|
|
|
$file = $tplfile->getVar('tpl_file', 'n'); |
|
826
|
|
|
$tpl = new XoopsTpl(); |
|
827
|
|
|
|
|
828
|
|
|
return $tpl->xoopsTouch('db:' . $file); |
|
829
|
|
|
} |
|
830
|
|
|
|
|
831
|
|
|
return false; |
|
832
|
|
|
} |
|
833
|
|
|
|
|
834
|
|
|
/** |
|
835
|
|
|
* Clear the module cache |
|
836
|
|
|
* |
|
837
|
|
|
* @param int $mid Module ID |
|
838
|
|
|
* @return void |
|
839
|
|
|
*/ |
|
840
|
|
|
function xoops_template_clear_module_cache($mid) |
|
841
|
|
|
{ |
|
842
|
|
|
$block_arr = XoopsBlock::getByModule($mid); |
|
843
|
|
|
$count = count($block_arr); |
|
844
|
|
|
if ($count > 0) { |
|
845
|
|
|
$xoopsTpl = new XoopsTpl(); |
|
846
|
|
|
$xoopsTpl->caching = 2; |
|
|
|
|
|
|
847
|
|
|
for ($i = 0; $i < $count; ++$i) { |
|
848
|
|
|
if ($block_arr[$i]->getVar('template') != '') { |
|
849
|
|
|
$xoopsTpl->clearCache('db:' . $block_arr[$i]->getVar('template'), 'blk_' . $block_arr[$i]->getVar('bid')); |
|
850
|
|
|
} |
|
851
|
|
|
} |
|
852
|
|
|
} |
|
853
|
|
|
} |
|
854
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths