xref: /plugin/combo/action/historicalbreadcrumb.php (revision 37748cd8654635afbeca80942126742f0f4cc346)
1<?php
2
3/**
4 * Copyright (c) 2021. ComboStrap, Inc. and its affiliates. All Rights Reserved.
5 *
6 * This source code is licensed under the GPL license found in the
7 * COPYING  file in the root directory of this source tree.
8 *
9 * @license  GPL 3 (https://www.gnu.org/licenses/gpl-3.0.en.html)
10 * @author   ComboStrap <support@combostrap.com>
11 *
12 */
13
14use ComboStrap\Bootstrap;
15use ComboStrap\PluginUtility;
16use ComboStrap\HistoricalBreadcrumbMenuItem;
17
18require_once(__DIR__ . '/../ComboStrap/PluginUtility.php');
19
20/**
21 *
22 * https://en.wikipedia.org/wiki/Breadcrumb_navigation#Websites
23 */
24class action_plugin_combo_historicalbreadcrumb extends DokuWiki_Action_Plugin
25{
26
27
28    public function register(Doku_Event_Handler $controller)
29    {
30
31        /**
32         * Add a icon in the page tools menu
33         * https://www.dokuwiki.org/devel:event:menu_items_assembly
34         */
35        $controller->register_hook('MENU_ITEMS_ASSEMBLY', 'AFTER', $this, 'handle_breadcrumb_history');
36
37
38    }
39
40
41    public function handle_breadcrumb_history(Doku_Event $event, $param)
42    {
43
44        global $conf;
45
46        //check if enabled
47        if (!$conf['breadcrumbs']) return;
48
49        if(Bootstrap::getBootStrapMajorVersion()== Bootstrap::BootStrapFiveMajorVersion) {
50
51
52            /**
53             * The `view` property defines the menu that is currently built
54             * https://www.dokuwiki.org/devel:menus
55             * If this is not the site menu, return
56             */
57            if ($event->data['view'] != 'site') return;
58
59            /**
60             * Making popover active
61             */
62            PluginUtility::getSnippetManager()->attachJavascriptSnippetForRequest("popover");
63
64            /**
65             * Css
66             */
67            PluginUtility::getSnippetManager()->attachCssSnippetForRequest(HistoricalBreadcrumbMenuItem::HISTORICAL_BREADCRUMB_NAME);
68
69            array_splice($event->data['items'], -1, 0, array(new HistoricalBreadcrumbMenuItem()));
70
71        }
72
73    }
74
75
76
77
78}
79
80
81
82