19d2d02ffSMichael Große<?php 29d2d02ffSMichael Große/** 39d2d02ffSMichael Große * DokuWiki Plugin structwiki (Action Component) 49d2d02ffSMichael Große * 59d2d02ffSMichael Große * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 69d2d02ffSMichael Große * @author Michael Große <mic.grosse@googlemail.com> 79d2d02ffSMichael Große */ 89d2d02ffSMichael Große 99d2d02ffSMichael Große// must be run within Dokuwiki 109d2d02ffSMichael Großeif (!defined('DOKU_INC')) die(); 119d2d02ffSMichael Große 129d2d02ffSMichael Großeclass action_plugin_structwiki extends DokuWiki_Action_Plugin { 139d2d02ffSMichael Große 149d2d02ffSMichael Große /** 159d2d02ffSMichael Große * Registers a callback function for a given event 169d2d02ffSMichael Große * 179d2d02ffSMichael Große * @param Doku_Event_Handler $controller DokuWiki's event controller object 189d2d02ffSMichael Große * @return void 199d2d02ffSMichael Große */ 209d2d02ffSMichael Große public function register(Doku_Event_Handler $controller) { 21*6b380169SMichael Große $controller->register_hook('PARSER_HANDLER_DONE', 'AFTER', $this, 'handle_parser_done'); 22*6b380169SMichael Große $controller->register_hook('PLUGIN_STRUCT_TYPECLASS_INIT', 'BEFORE', $this, 'handle_init'); 239d2d02ffSMichael Große } 249d2d02ffSMichael Große 259d2d02ffSMichael Große /** 269d2d02ffSMichael Große * [Custom event handler which performs action] 279d2d02ffSMichael Große * 289d2d02ffSMichael Große * @param Doku_Event $event event object by reference 299d2d02ffSMichael Große * @param mixed $param [the parameters passed as fifth argument to register_hook() when this 309d2d02ffSMichael Große * handler was registered] 319d2d02ffSMichael Große * @return void 329d2d02ffSMichael Große */ 339d2d02ffSMichael Große 34*6b380169SMichael Große public function handle_parser_done(Doku_Event $event, $param) { 35*6b380169SMichael Große /** @var helper_plugin_struct $struct */ 36*6b380169SMichael Große $struct = plugin_load('helper', 'struct'); 37*6b380169SMichael Große if (!$struct) { 38*6b380169SMichael Große return; 39*6b380169SMichael Große } 40*6b380169SMichael Große 41*6b380169SMichael Große global $ACT; 42*6b380169SMichael Große 43*6b380169SMichael Große if (act_clean($ACT) != 'show') { 44*6b380169SMichael Große dbglog($ACT, __FILE__ .': '.__LINE__); 45*6b380169SMichael Große return; 46*6b380169SMichael Große } 47*6b380169SMichael Große 48*6b380169SMichael Große $last = end($event->data->calls); 49*6b380169SMichael Große $pos = $last[2]; 50*6b380169SMichael Große 51*6b380169SMichael Große $event->data->calls[] = array( 52*6b380169SMichael Große 'plugin', 53*6b380169SMichael Große array( 54*6b380169SMichael Große 'structwiki', array('pos' => $pos), DOKU_LEXER_SPECIAL, '', 55*6b380169SMichael Große ), 56*6b380169SMichael Große $pos, 57*6b380169SMichael Große ); 58*6b380169SMichael Große } 59*6b380169SMichael Große 60*6b380169SMichael Große public function handle_init(Doku_Event &$event, $param) { 61*6b380169SMichael Große $event->data['Section'] = 'dokuwiki\\plugin\\structwiki\\types\\Section'; 629d2d02ffSMichael Große } 639d2d02ffSMichael Große 649d2d02ffSMichael Große} 659d2d02ffSMichael Große 669d2d02ffSMichael Große// vim:ts=4:sw=4:et: 67