Failed Conditions
Pull Request — master (#3198)
by
unknown
03:06
created

Index   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 115
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 115
rs 10
c 0
b 0
f 0
wmc 15
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A show() 0 23 3
A formatListItem() 0 22 5
B tagListItem() 0 21 6
1
<?php
2
3
namespace dokuwiki\Ui;
4
5
use dokuwiki\Extension\Event;
6
use dokuwiki\Form\Form;
7
8
/**
9
 * DokuWiki Index Interface
10
 *
11
 * @package dokuwiki\Ui
12
 */
13
class Index extends Ui
14
{
15
    protected $ns;
16
17
    /** 
18
     * Index Ui constructor
19
     *
20
     * @param string $ns  namespace
21
    */
22
    public function __construct($ns = '')
23
    {
24
        $this->ns = $ns;
25
    }
26
27
28
    /**
29
     * Display page index
30
     *
31
     * @author   Andreas Gohr <[email protected]>
32
     *
33
     * @param string $ns
0 ignored issues
show
Bug introduced by
There is no parameter named $ns. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
34
     * @return void
35
     */
36
    public function show()
37
    {
38
        global $conf;
39
        global $ID;
40
41
        $ns  = cleanID($this->ns);
42
        if (empty($ns)){
43
            $ns = getNS($ID);
44
            if ($ns === false) $ns = '';
45
        }
46
        $ns  = utf8_encodeFN(str_replace(':', '/', $ns));
47
48
        // print intro
49
        print p_locale_xhtml('index');
50
51
        print '<div id="index__tree" class="index__tree">';
52
53
        $data = array();
54
        search($data, $conf['datadir'], 'search_index', array('ns' => $ns));
55
        print html_buildlist($data, 'idx', [$this,'formatListItem'], [$this,'tagListItem']);
56
57
        print '</div>'.DOKU_LF;
58
    }
59
60
    /**
61
     * Index item formatter
62
     *
63
     * User function for html_buildlist()
64
     *
65
     * @author Andreas Gohr <[email protected]>
66
     *
67
     * @param array $item
68
     * @return string
69
     */
70
    public function formatListItem($item)    // RENAMED from html_list_index()
71
    {
72
        global $ID, $conf;
73
74
        // prevent searchbots needlessly following links
75
        $nofollow = ($ID != $conf['start'] || $conf['sitemap']) ? 'rel="nofollow"' : '';
76
77
        $html = '';
78
        $base = ':'.$item['id'];
79
        $base = substr($base, strrpos($base,':') +1);
80
        if ($item['type'] == 'd') {
81
            // FS#2766, no need for search bots to follow namespace links in the index
82
            $link = wl($ID, 'idx='. rawurlencode($item['id']));
83
            $html .= '<a href="'. $link .'" title="'. $item['id'] .'" class="idx_dir"' . $nofollow .'><strong>';
84
            $html .= $base;
85
            $html .= '</strong></a>';
86
        } else {
87
            // default is noNSorNS($id), but we want noNS($id) when useheading is off FS#2605
88
            $html .= html_wikilink(':'.$item['id'], useHeading('navigation') ? null : noNS($item['id']));
89
        }
90
        return $html;
91
    }
92
93
    /**
94
     * Index List item
95
     *
96
     * This user function is used in html_buildlist to build the
97
     * <li> tags for namespaces when displaying the page index
98
     * it gives different classes to opened or closed "folders"
99
     *
100
     * @author Andreas Gohr <[email protected]>
101
     *
102
     * @param array $item
103
     * @return string html
104
     */
105
    public function tagListItem($item)    // RENAMED from html_li_index()
106
    {
107
        global $INFO;
108
        global $ACT;
109
110
        $class = '';
111
        $id = '';
112
113
        if ($item['type'] == 'f') {
114
            // scroll to the current item
115
            if (isset($INFO) && $item['id'] == $INFO['id'] && $ACT == 'index') {
116
                $id = ' id="scroll__here"';
117
                $class = ' bounce';
118
            }
119
            return '<li class="level'.$item['level'].$class.'" '.$id.'>';
120
        } elseif ($item['open']) {
121
            return '<li class="open">';
122
        } else {
123
            return '<li class="closed">';
124
        }
125
    }
126
127
}
128