43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* Tabpage plugin: Shows links to children pages as tabs on parent page
|
|
*
|
|
* @license BSD 2-Clause
|
|
* @author Antoine Le Gonidec <vv221.dokuwiki@dotslashplay.it>
|
|
*/
|
|
|
|
// must be run within Dokuwiki
|
|
if ( ! defined('DOKU_INC') ) {
|
|
die();
|
|
}
|
|
|
|
class action_plugin_tabpage extends DokuWiki_Action_Plugin {
|
|
/**
|
|
* Registers a callback function for a given event
|
|
*
|
|
* @param Doku_Event_Handler $controller
|
|
*/
|
|
public function register(Doku_Event_Handler $controller) : void {
|
|
$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) : void {
|
|
// 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);
|
|
}
|
|
// 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);
|
|
}
|
|
}
|