1.12KiB; PHP | 2020-08-26 15:35:48+02 | SLOC 30
1
<?php
2
3
namespace dokuwiki\Menu\Item;
4
5
/**
6
 * Class Discussion
7
 */
8
class Discussion extends AbstractItem
9
{
10
11
    /** @inheritdoc */
12 9
    public function __construct()
13
    {
14
15
        parent::__construct();
16
17
        if (!tpl_getConf('showDiscussion')) {
18
            throw new \RuntimeException("discussion is not available");
19
        }
20
21
        unset($this->params['do']);
22
23
        $discuss_page     = str_replace('@ID@', $this->id, tpl_getConf('discussionPage'));
24
        $discuss_page_raw = str_replace('@ID@', '', tpl_getConf('discussionPage'));
25
        $is_discuss_page  = strpos($this->id, $discuss_page_raw) !== false;
26
        $back_id          = str_replace($discuss_page_raw, '', $this->id);
27
28
        if ($is_discuss_page) {
29
            $this->label = tpl_getLang('back_to_article');
30
            $this->id    = cleanID($back_id);
31
            $this->svg   = tpl_incdir() . 'images/menu/file-document-box-outline.svg';
32 1
        } else {
ElseExpression The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. (kritika/PHPMD) Filter like this
33
            $this->label = tpl_getLang('discussion');
34
            $this->id    = cleanID($discuss_page);
35
            $this->svg   = tpl_incdir() . 'images/menu/comment-text-multiple.svg';
36
        }
37
38
    }
39
40
}