|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* xoImgUrl Smarty compiler plug-in |
|
4
|
|
|
* |
|
5
|
|
|
* See the enclosed file LICENSE for licensing information. If you did not |
|
6
|
|
|
* receive this file, get it at http://www.gnu.org/licenses/gpl-2.0.html |
|
7
|
|
|
* |
|
8
|
|
|
* @copyright (c) 2000-2022 XOOPS Project (https://xoops.org) |
|
9
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
|
10
|
|
|
* @author Skalpa Keo <[email protected]> |
|
11
|
|
|
* @package xos_opal |
|
12
|
|
|
* @subpackage xos_opal_Smarty |
|
13
|
|
|
* @since 2.0.14 |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Inserts the URL of a file resource customizable by themes |
|
18
|
|
|
* |
|
19
|
|
|
* This plug-in works like the {@link smarty_compiler_xoAppUrl() xoAppUrl} plug-in, |
|
20
|
|
|
* except that it is intended to generate the URL of resource files customizable by |
|
21
|
|
|
* themes. |
|
22
|
|
|
* |
|
23
|
|
|
* Here the current theme is asked to check if a custom version of the requested file exists, and |
|
24
|
|
|
* if one is found its URL is returned. Otherwise, the request will be passed to the |
|
25
|
|
|
* theme parents one by one. Ultimately, if no custom version has been found, the resource |
|
26
|
|
|
* default URL location will be returned. |
|
27
|
|
|
* |
|
28
|
|
|
* <b>Note:</b> the themes inheritance system can generate many filesystem accesses depending |
|
29
|
|
|
* on your themes configuration. Because of this, the use of the dynamic syntax with this plug-in |
|
30
|
|
|
* is not possible right now. |
|
31
|
|
|
* |
|
32
|
|
|
* @param string[] $params |
|
33
|
|
|
* @param Smarty $smarty |
|
34
|
|
|
* @return string |
|
35
|
|
|
*/ |
|
36
|
|
|
|
|
37
|
|
|
function smarty_compiler_xoimgurl($params, $smarty) |
|
|
|
|
|
|
38
|
|
|
{ |
|
39
|
|
|
global $xoops, $xoTheme; |
|
40
|
|
|
$arg = reset($params); |
|
41
|
|
|
$arg = trim($arg, " '\"\t\n\r\0\x0B"); |
|
42
|
|
|
$path = (isset($xoTheme) && is_object($xoTheme)) ? $xoTheme->resourcePath($arg) : $arg; |
|
43
|
|
|
//$xoops->events()->triggerEvent('debug.log', $path); |
|
44
|
|
|
return "<?php echo '" . addslashes($xoops->url($path)) . "'; ?>"; |
|
45
|
|
|
} |
|
46
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.