Passed
Push — master ( 39d6b4...d15df8 )
by
unknown
07:31
created

smarty_compiler_xoimgurl()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
nc 4
nop 2
dl 0
loc 8
rs 10
c 1
b 0
f 0
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)
0 ignored issues
show
Unused Code introduced by
The parameter $smarty is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

37
function smarty_compiler_xoimgurl($params, /** @scrutinizer ignore-unused */ $smarty)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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