Issues (195)

smarty-plugins/function.defaultsort.php (1 issue)

Severity
1
<?php
2
/******************************************************************************
3
 * Wikipedia Account Creation Assistance tool                                 *
4
 *                                                                            *
5
 * All code in this file is released into the public domain by the ACC        *
6
 * Development Team. Please see team.json for a list of contributors.         *
7
 ******************************************************************************/
8
9
/**
10
 * Sets up the cookie-based default sorting on request tables
11
 *
12
 * @param                          $params
13
 * @param Smarty_Internal_Template $template
14
 *
15
 * @return string
16
 */
17
function smarty_function_defaultsort($params, Smarty_Internal_Template $template)
0 ignored issues
show
The parameter $template 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

17
function smarty_function_defaultsort($params, /** @scrutinizer ignore-unused */ Smarty_Internal_Template $template)

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...
18
{
19
    if (empty($params['id'])) {
20
        return "";
21
    }
22
23
    $attr = 'data-sortname="' . htmlspecialchars($params['id'], ENT_QUOTES) . '"';
24
25
    if (empty($params['req'])) {
26
        return $attr;
27
    }
28
29
    if ($params['dir'] !== 'asc' && $params['dir'] !== 'desc') {
30
        $params['dir'] = 'asc';
31
    }
32
33
    $sort = '';
34
    if ($params['req'] === $params['id']) {
35
        $sort = ' data-defaultsort="' . htmlspecialchars($params['dir'], ENT_QUOTES) . '"';
36
    }
37
38
    return $attr . $sort;
39
}