xref: /plugin/combo/action/hiddenpage.php (revision 85e82846b0a214bc35e62864fa49d9cad0723d0e)
1<?php
2
3
4use ComboStrap\PluginUtility;
5use ComboStrap\TplConstant;
6use ComboStrap\TplUtility;
7
8/**
9 * Class action_plugin_combo_hidden
10 * Hide page
11 *
12 *
13 * More on the official [[doku>config:hidepages|DokuWiki documentation]]
14 */
15class action_plugin_combo_hiddenpage extends DokuWiki_Action_Plugin
16{
17
18
19    const CANONICAL = "";
20
21    public function register(Doku_Event_Handler $controller)
22    {
23        /**
24         * https://www.dokuwiki.org/devel:event:pageutils_id_hidepage
25         */
26        $controller->register_hook('PAGEUTILS_ID_HIDEPAGE', 'BEFORE', $this, 'handleIsHidden', array());
27    }
28
29    function handleIsHidden(&$event, $param)
30    {
31        global $conf;
32
33        /**
34         * Caching the slot and private namespace
35         */
36        $pattern = "(" . $conf['sidebar'] . "|" . PluginUtility::COMBOSTRAP_NAMESPACE_NAME;
37        if ($conf['template'] == PluginUtility::TEMPLATE_STRAP_NAME) {
38            $loaded = PluginUtility::loadStrapUtilityTemplateIfPresentAndSameVersion();
39            if ($loaded) {
40
41                $pattern .= "|" . TplUtility::getFooterSlotPageName();
42                $pattern .= "|" . TplUtility::getSideKickSlotPageName();
43                $pattern .= "|" . TplUtility::getHeaderSlotPageName();
44
45            }
46        }
47        $pattern .= ")";
48        if (preg_match('/' . $pattern . '/ui', ':' . $event->data['id'])) {
49            $event->data['hidden'] = true;
50        }
51
52    }
53
54
55}
56