1<?php 2 3 4require_once(__DIR__ . '/../ComboStrap/PluginUtility.php'); 5 6use ComboStrap\BrandingColors; 7use ComboStrap\ColorSystem; 8use ComboStrap\ExecutionContext; 9use ComboStrap\PluginUtility; 10use ComboStrap\Site; 11 12 13/** 14 */ 15class action_plugin_combo_docss extends DokuWiki_Action_Plugin 16{ 17 18 19 public function register(Doku_Event_Handler $controller) 20 { 21 22 /** 23 * See {@link \ComboStrap\SnippetSystem::attachCssInternalStylesheet()} 24 * for more explanation on the choice of the event 25 */ 26 $controller->register_hook('ACTION_HEADERS_SEND', 'BEFORE', $this, 'handleCssForDoAction'); 27 28 } 29 30 /** 31 * @param Doku_Event $event 32 */ 33 public function handleCssForDoAction(Doku_Event &$event) 34 { 35 if (!Site::isStrapTemplate()) { 36 return; 37 } 38 global $ACT; 39 switch ($ACT) { 40 case "media": 41 PluginUtility::getSnippetManager()->attachCssInternalStylesheet("do-media"); 42 break; 43 case "edit": 44 case "preview": 45 PluginUtility::getSnippetManager()->attachCssInternalStylesheet("do-edit"); 46 break; 47 case "admin": 48 $defaultColor = "black"; 49 $config = ExecutionContext::getActualOrCreateFromEnv()->getConfig(); 50 $iconColor = $config->getPrimaryColorOrDefault($defaultColor); 51 $colorText = ColorSystem::toTextColor($iconColor); 52 $css = <<<EOF 53ul.admin_tasks, ul.admin_plugins { 54 list-style: none; 55} 56ul.admin_tasks li, ul.admin_plugins li{ 57 margin: 0.5rem; 58} 59ul.admin_tasks a, ul.admin_plugins a { 60 text-decoration: none; 61 color: black 62} 63ul.admin_tasks a:hover, ul.admin_plugins a:hover{ 64 text-decoration: underline; 65 color: {$colorText->toRgbHex()}; 66} 67.icon svg { 68 color: {$iconColor->toRgbHex()}; 69 fill: {$iconColor->toRgbHex()}; 70} 71EOF; 72 PluginUtility::getSnippetManager()->attachCssInternalStylesheet("do-admin", $css); 73 break; 74 } 75 76 77 } 78 79 80} 81