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