1<?php
2
3require_once(__DIR__ . "/../class/CallStackMenuItem.php");
4
5use ComboStrap\CallStackMenuItem;
6
7class action_plugin_dump_menu extends DokuWiki_Action_Plugin
8{
9
10
11    public function register(Doku_Event_Handler $controller)
12    {
13
14        /**
15         * Add a icon in the page tools menu
16         * https://www.dokuwiki.org/devel:event:menu_items_assembly
17         */
18        $controller->register_hook('MENU_ITEMS_ASSEMBLY', 'AFTER', $this, 'handle_page_tools');
19
20
21    }
22
23
24    public function handle_page_tools(Doku_Event $event, $param)
25    {
26
27        global $ID;
28
29        if (auth_quickaclcheck($ID) < AUTH_READ) {
30            return;
31        }
32
33        global $INFO;
34        if (!$INFO['isadmin']) {
35            return;
36        }
37
38        /**
39         * The `view` property defines the menu that is currently built
40         * https://www.dokuwiki.org/devel:menus
41         * If this is not the page menu, return
42         */
43        if ($event->data['view'] != 'page') return;
44
45        global $INFO;
46        if (!$INFO['exists']) {
47            return;
48        }
49        array_splice($event->data['items'], -1, 0, array(new CallStackMenuItem()));
50
51    }
52
53
54}
55
56
57
58