1<?php
2
3
4use ComboStrap\ExceptionCompile;
5use ComboStrap\PluginUtility;
6use ComboStrap\Site;
7use ComboStrap\SlotSystem;
8use ComboStrap\TplUtility;
9
10/**
11 * Class action_plugin_combo_hidden
12 * Hide page
13 *
14 *
15 * More on the official [[doku>config:hidepages|DokuWiki documentation]]
16 */
17class action_plugin_combo_hiddenpage extends DokuWiki_Action_Plugin
18{
19
20
21    const CANONICAL = "";
22
23    public function register(Doku_Event_Handler $controller)
24    {
25        /**
26         * https://www.dokuwiki.org/devel:event:pageutils_id_hidepage
27         */
28        $controller->register_hook('PAGEUTILS_ID_HIDEPAGE', 'BEFORE', $this, 'handleIsHidden', array());
29    }
30
31    function handleIsHidden(&$event, $param)
32    {
33
34
35        /**
36         * Caching the slot and private namespace
37         */
38        $namesToHide = [];
39        $namesToHide[] = SlotSystem::getSidebarName();
40        $namesToHide[] = SlotSystem::getPageHeaderSlotName();
41        $namesToHide[] = PluginUtility::COMBOSTRAP_NAMESPACE_NAME;
42        $namesToHide[] = SlotSystem::getPageFooterSlotName();
43        $namesToHide[] = SlotSystem::getMainSideSlotName();
44        $namesToHide[] = SlotSystem::getMainFooterSlotName();
45        $namesToHide[] = SlotSystem::getMainHeaderSlotName();
46        // Remove empty string elements
47        $namesToHidenotEmpty = array_filter($namesToHide, function ($value) {
48            return trim($value) !== '';
49        });
50        $pattern = "(" . implode('|', $namesToHidenotEmpty) . ")";
51        if (preg_match('/' . $pattern . '/ui', ':' . $event->data['id'])) {
52            $event->data['hidden'] = true;
53        }
54
55    }
56
57
58}
59