Only take action during the generation of the page menu
This commit is contained in:
parent
8bd362aa01
commit
4ca920f729
1 changed files with 6 additions and 2 deletions
|
@ -17,7 +17,7 @@ class action_plugin_tabpage extends DokuWiki_Action_Plugin {
|
||||||
*
|
*
|
||||||
* @param Doku_Event_Handler $controller
|
* @param Doku_Event_Handler $controller
|
||||||
*/
|
*/
|
||||||
public function register(Doku_Event_Handler $controller) {
|
public function register(Doku_Event_Handler $controller) : void {
|
||||||
$controller->register_hook('MENU_ITEMS_ASSEMBLY', 'AFTER', $this, 'addMenuItem');
|
$controller->register_hook('MENU_ITEMS_ASSEMBLY', 'AFTER', $this, 'addMenuItem');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class action_plugin_tabpage extends DokuWiki_Action_Plugin {
|
||||||
*
|
*
|
||||||
* @param Doku_Event $event
|
* @param Doku_Event $event
|
||||||
*/
|
*/
|
||||||
public function addMenuItem(Doku_Event $event) {
|
public function addMenuItem(Doku_Event $event) : void {
|
||||||
// Check that this method has been called in the expected context
|
// Check that this method has been called in the expected context
|
||||||
if ( $event->name !== 'MENU_ITEMS_ASSEMBLY' ) {
|
if ( $event->name !== 'MENU_ITEMS_ASSEMBLY' ) {
|
||||||
$message = "Tabpage plugin error:";
|
$message = "Tabpage plugin error:";
|
||||||
|
@ -34,6 +34,10 @@ class action_plugin_tabpage extends DokuWiki_Action_Plugin {
|
||||||
$message .= ", but it has been called by \"$event->name\".";
|
$message .= ", but it has been called by \"$event->name\".";
|
||||||
throw new Exception($message);
|
throw new Exception($message);
|
||||||
}
|
}
|
||||||
|
// Only add content to the page menu
|
||||||
|
if ( $event->data['view'] !== 'page' ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
trigger_error('addMenuItem() not implemented in '.get_class($this), E_USER_WARNING);
|
trigger_error('addMenuItem() not implemented in '.get_class($this), E_USER_WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue