1<?php
2
3
4use ComboStrap\Api\ApiRouter;
5use ComboStrap\Identity;
6use ComboStrap\QualityMenuItem;
7
8require_once(__DIR__ . '/../vendor/autoload.php');
9
10/**
11 *
12 * Show a quality message
13 *
14 *
15 *
16 */
17class action_plugin_combo_qualitymessage extends DokuWiki_Action_Plugin
18{
19
20
21    function __construct()
22    {
23        // enable direct access to language strings
24        // ie $this->lang
25        $this->setupLocale();
26    }
27
28
29    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
43    function addMenuItem(Doku_Event $event, $param)
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        global $INFO;
58        $exists = $INFO['exists'] ?? null;
59        if (!$exists) {
60            return;
61        }
62        array_splice($event->data['items'], -1, 0, array(new QualityMenuItem()));
63
64    }
65
66
67}
68