1<?php
2
3namespace dokuwiki\Menu\Item;
4
5/**
6 * Class Help
7 */
8class Help extends AbstractItem
9{
10
11    /** @inheritdoc */
12    public function __construct()
13    {
14        parent::__construct();
15
16        if (!in_array('help', explode(',', tpl_getConf('pageIcons')))) {
17            throw new \RuntimeException("help is not available");
18        }
19
20        unset($this->params['do']);
21
22        $help_id = page_findnearest('help', tpl_getConf('useACL'));
23
24        if (!$help_id) {
25            throw new \RuntimeException("help page not found");
26        }
27
28        $this->label     = hsc(p_get_first_heading($help_id));
29        $this->svg       = tpl_incdir() . 'images/menu/help.svg';
30        $this->id        = '#';
31        $this->help_id   = $help_id;
32        $this->help_link = wl($help_id, array('do' => 'export_xhtmlbody'));
33    }
34
35    public function getLinkAttributes($classprefix = 'menuitem ')
36    {
37        $attr = parent::getLinkAttributes($classprefix);
38
39        $attr['data-toggle']  = 'modal';
40        $attr['data-help-id'] = $this->help_id;
41        $attr['data-target']  = '.modal.help';
42        $attr['data-link']    = $this->help_link;
43
44        return $attr;
45    }
46}
47