xref: /plugin/combo/action/analytics.php (revision 977ce05d19d8dab0a70c9a27f8da0b7039299e82)
1<?php
2
3use Combostrap\AnalyticsMenuItem;
4use ComboStrap\Identity;
5use ComboStrap\Page;
6
7/**
8 * Copyright (c) 2021. ComboStrap, Inc. and its affiliates. All Rights Reserved.
9 *
10 * This source code is licensed under the GPL license found in the
11 * COPYING  file in the root directory of this source tree.
12 *
13 * @license  GPL 3 (https://www.gnu.org/licenses/gpl-3.0.en.html)
14 * @author   ComboStrap <support@combostrap.com>
15 *
16 */
17
18
19require_once(__DIR__ . '/../ComboStrap/PluginUtility.php');
20
21/**
22 * Class action_plugin_combo_analytics
23 * Update the analytics data
24 */
25class action_plugin_combo_analytics extends DokuWiki_Action_Plugin
26{
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, 'handle_rail_bar');
38
39
40    }
41
42
43    public function handle_rail_bar(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        if (!$INFO['exists']) {
59            return;
60        }
61        array_splice($event->data['items'], -1, 0, array(new AnalyticsMenuItem()));
62
63    }
64
65
66}
67
68
69
70