1<?php
2
3namespace dokuwiki\plugin\stale;
4
5use dokuwiki\Menu\Item\AbstractItem;
6use helper_plugin_stale;
7
8/**
9 * Class MenuItem
10 *
11 * Implements the stale button
12 * https://www.dokuwiki.org/devel:menus:example
13 */
14class StaleMenuItem extends AbstractItem
15{
16
17
18    /**
19     * The first compile time, the javascript may not
20     * work, we send the user to the admin page
21     *
22     * Abstract item does not use the getter method
23     * we override then the variable
24     *
25     * @return array
26     */
27    protected $params =  array(
28            "do" => "admin",
29            "page" => helper_plugin_stale::PLUGIN_NAME
30        );
31
32
33    const MENU_HTML_ELEMENT_ID = 'plugin_' . helper_plugin_stale::PLUGIN_NAME;
34
35
36    public function getLinkAttributes($classprefix = 'menuitem ')
37    {
38        $linkAttributes = parent::getLinkAttributes($classprefix);
39
40        /**
41         * A class and not an id
42         * because a menu item can be found twice on
43         * a page (For instance if you want to display it in a layout at a
44         * breakpoint and at another in another breakpoint
45         */
46        $linkAttributes['class'] = self::MENU_HTML_ELEMENT_ID;
47
48        return $linkAttributes;
49    }
50
51    public function getType()
52    {
53        return "admin";
54    }
55
56
57
58
59    public function getTitle()
60    {
61        $stale = plugin_load('helper', helper_plugin_stale::PLUGIN_NAME);
62        return $stale->getLang('menu');
63    }
64
65    public function getLabel()
66    {
67        $stale = plugin_load('helper', helper_plugin_stale::PLUGIN_NAME);
68        return $stale->getLang("menuItemLabel");
69    }
70
71
72    public function getSvg()
73    {
74        /** @var helper_plugin_stale $stale */
75        $stale = plugin_load('helper', helper_plugin_stale::PLUGIN_NAME);
76        return $stale->getIcon();
77    }
78}
79