splitbrain/dokuwiki — pull request #471 by hafron (2013-12-10 11:04:35+00:00)
Title: TPL_ACTION_GET event

I've add new event to dokuwiki(TPL_ACTION_GET) which allows you to create own actions to tpl_action function. Together with my previous pull request(https://github.com/splitbrain/dokuwiki/pull/470), you can add own actions to sitetools menu. Example:

class action_plugin_bds extends DokuWiki_Action_Plugin {

/**
* Register its handlers with the DokuWiki's event controller
*/
public function register(Doku_Event_Handler $controller) {
$controller->register_hook('TEMPLATE_SITETOOLS_DISPLAY', 'BEFORE', $this,
'add_menu_item');
$controller->register_hook('TPL_ACTION_GET', 'BEFORE', $this,
'add_action');
}

public function add_menu_item(&$event, $param) {
global $lang;
$lang['btn_bds'] = $this->getLang('bds');
$event->data['items']['bds'] = tpl_action('bds', 1, 'li', 1);
}
public function add_action(&$event, $param) {
$data = &$event->data;
if ($data['type'] != 'bds')
return;

$event->preventDefault();
}
}