diff --git a/action.php b/action.php index 3b5d4a9..88d04bc 100644 --- a/action.php +++ b/action.php @@ -18,6 +18,22 @@ class action_plugin_tabpage extends DokuWiki_Action_Plugin { * @param Doku_Event_Handler $controller */ public function register(Doku_Event_Handler $controller) { - trigger_error('register() not implemented in '.get_class($this), E_USER_WARNING); + $controller->register_hook('MENU_ITEMS_ASSEMBLY', 'AFTER', $this, 'addMenuItem'); + } + + /** + * Add new items to the page menu + * + * @param Doku_Event $event + */ + public function addMenuItem(Doku_Event $event) { + // Check that this method has been called in the expected context + if ( $event->name !== 'MENU_ITEMS_ASSEMBLY' ) { + $message = "Tabpage plugin error:"; + $message .= "addMenuItem method should only be called by \"MENU_ITEMS_ASSEMBLY\" event"; + $message .= ", but it has been called by \"$event->name\"."; + throw new Exception($message); + } + trigger_error('addMenuItem() not implemented in '.get_class($this), E_USER_WARNING); } }