1<?php 2 3 4use ComboStrap\ExceptionCombo; 5use ComboStrap\PluginUtility; 6use ComboStrap\Site; 7use ComboStrap\TplConstant; 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 global $conf; 34 35 /** 36 * Caching the slot and private namespace 37 */ 38 $pattern = "(" . $conf['sidebar'] . "|" . PluginUtility::COMBOSTRAP_NAMESPACE_NAME; 39 if ($conf['template'] == PluginUtility::TEMPLATE_STRAP_NAME) { 40 try { 41 Site::loadStrapUtilityTemplateIfPresentAndSameVersion(); 42 } catch (ExceptionCombo $e) { 43 return; 44 } 45 46 $pattern .= "|" . TplUtility::getFooterSlotPageName(); 47 $pattern .= "|" . TplUtility::getSideKickSlotPageName(); 48 $pattern .= "|" . TplUtility::getHeaderSlotPageName(); 49 $pattern .= "|" . TplUtility::getMainFooterSlotName(); 50 $pattern .= "|" . TplUtility::getMainHeaderSlotName(); 51 52 } 53 $pattern .= ")"; 54 if (preg_match('/' . $pattern . '/ui', ':' . $event->data['id'])) { 55 $event->data['hidden'] = true; 56 } 57 58 } 59 60 61} 62