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

smarty_compiler_xoappurl()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
nc 2
nop 2
dl 0
loc 10
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 * xoAppUrl 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
 * Build application relative URL
18
 *
19
 * This plug-in allows you to generate a module location URL. It uses any URL rewriting
20
 * mechanism and rules you'll have configured for the system.
21
 *
22
 * // Generate a URL using a physical path
23
 * <{xoAppUrl 'modules/something/yourpage.php'}>
24
 *
25
 * The path should be in a form understood by Xoops::url()
26
 *
27
 * @param string[] $params
28
 * @param Smarty   $smarty
29
 * @return string
30
 */
31
function smarty_compiler_xoappurl($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

31
function smarty_compiler_xoappurl($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...
32
{
33
    global $xoops;
34
    $arg = reset($params);
35
    $url = trim($arg, " '\"\t\n\r\0\x0B");
36
37
    if (strpos($url, '/') === 0) {
38
        $url = 'www' . $url;
39
    }
40
    return "<?php echo '" . addslashes(htmlspecialchars($xoops->url($url), ENT_QUOTES | ENT_HTML5)) . "'; ?>";
41
}
42