1<?php 2/** 3 * AutoColor Plugin: Action component for admin notifications. 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Klaus Keusch <dev@klauskeusch.de> 7 */ 8 9if (!defined('DOKU_INC')) die(); 10 11class action_plugin_autocolor extends DokuWiki_Action_Plugin { 12 13 public function register(Doku_Event_Handler $controller) { 14 // Include this as soon as DokuWiki is ready. 15 $controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, 'checkConfigPage'); 16 } 17 18 /** 19 * Checks whether the configuration wiki page exists and alerts the admin if it does not. 20 */ 21 public function checkConfigPage(Doku_Event $event, $param) { 22 // DokuWiki security check: Is the current user an admin? 23 if (!auth_isadmin()) { 24 return; 25 } 26 27 // Retrieve the page name from the settings (e.g., "admin:autocolor") 28 $pageId = $this->getConf('config_page'); 29 30 if (!page_exists($pageId)) { 31 // DokuWiki's built-in msg() function generates the yellow/red banner from lang files. 32 // The parameter -1 indicates an error or warning. 33 $warnText = sprintf( 34 $this->getLang('missing_config'), 35 htmlspecialchars($pageId, ENT_QUOTES, 'UTF-8') 36 ); 37 msg($warnText, -1); 38 } 39 } 40}