1<?php
2
3use ComboStrap\BacklinkMenuItem;
4use ComboStrap\Event;
5use ComboStrap\FileSystems;
6use ComboStrap\Identity;
7use ComboStrap\LinkMarkup;
8use ComboStrap\Meta\Store\MetadataDokuWikiStore;
9use ComboStrap\Mime;
10use ComboStrap\MarkupPath;
11use ComboStrap\PagePath;
12use ComboStrap\PluginUtility;
13use ComboStrap\Reference;
14use ComboStrap\References;
15
16
17require_once(__DIR__ . '/../ComboStrap/PluginUtility.php');
18
19/**
20 * Handle the slot manager menu item
21 */
22class action_plugin_combo_slotmanagermenuitem extends DokuWiki_Action_Plugin
23{
24
25
26    const CANONICAL = "edit-page-menu";
27
28
29    public function register(Doku_Event_Handler $controller)
30    {
31
32
33        /**
34         * Add a icon in the page tools menu
35         * https://www.dokuwiki.org/devel:event:menu_items_assembly
36         */
37        $controller->register_hook('MENU_ITEMS_ASSEMBLY', 'AFTER', $this, 'addMenuItem');
38
39
40    }
41
42    function addMenuItem(Doku_Event $event, $param)
43    {
44
45
46        if (!Identity::isWriter()) {
47            return;
48        }
49
50        /**
51         * The `view` property defines the menu that is currently built
52         * https://www.dokuwiki.org/devel:menus
53         * If this is not the page menu, return
54         */
55        if ($event->data['view'] != 'page') return;
56
57        $menuItems = &$event->data["items"];
58        foreach ($menuItems as $key => $menuItem) {
59            if ($menuItem instanceof \dokuwiki\Menu\Item\Edit) {
60                array_splice($menuItems, $key + 1, 0, [new \ComboStrap\SlotManagerMenuItem()]);
61                break;
62            }
63        }
64
65
66    }
67
68
69}
70
71
72
73