19d2d02ffSMichael Große<?php 29d2d02ffSMichael Große/** 3284f9fc3SMichael Große * DokuWiki Plugin structsection (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 9*15756b07SMichael Großeclass action_plugin_structsection extends DokuWiki_Action_Plugin 10*15756b07SMichael Große{ 119d2d02ffSMichael Große 129d2d02ffSMichael Große /** 139d2d02ffSMichael Große * Registers a callback function for a given event 149d2d02ffSMichael Große * 159d2d02ffSMichael Große * @param Doku_Event_Handler $controller DokuWiki's event controller object 169d2d02ffSMichael Große * @return void 179d2d02ffSMichael Große */ 18*15756b07SMichael Große public function register(Doku_Event_Handler $controller) 19*15756b07SMichael Große { 20*15756b07SMichael Große $controller->register_hook('PARSER_HANDLER_DONE', 'AFTER', $this, 'appendPluginOutputToPage'); 21*15756b07SMichael Große $controller->register_hook('PLUGIN_STRUCT_TYPECLASS_INIT', 'BEFORE', $this, 'registerTypeWithStructPlugin'); 229d2d02ffSMichael Große } 239d2d02ffSMichael Große 249d2d02ffSMichael Große /** 25*15756b07SMichael Große * Event handler for PARSER_HANDLER_DONE 269d2d02ffSMichael Große * 279d2d02ffSMichael Große * @param Doku_Event $event event object by reference 289d2d02ffSMichael Große * @param mixed $param [the parameters passed as fifth argument to register_hook() when this 299d2d02ffSMichael Große * handler was registered] 309d2d02ffSMichael Große * @return void 319d2d02ffSMichael Große */ 32*15756b07SMichael Große final public function appendPluginOutputToPage(Doku_Event $event, $param) 33*15756b07SMichael Große { 346b380169SMichael Große /** @var helper_plugin_struct $struct */ 356b380169SMichael Große $struct = plugin_load('helper', 'struct'); 366b380169SMichael Große if (!$struct) { 376b380169SMichael Große return; 386b380169SMichael Große } 396b380169SMichael Große 406b380169SMichael Große global $ACT; 416b380169SMichael Große 426b380169SMichael Große if (act_clean($ACT) != 'show') { 436b380169SMichael Große dbglog($ACT, __FILE__ .': '.__LINE__); 446b380169SMichael Große return; 456b380169SMichael Große } 466b380169SMichael Große 476b380169SMichael Große $last = end($event->data->calls); 486b380169SMichael Große $pos = $last[2]; 496b380169SMichael Große 506b380169SMichael Große $event->data->calls[] = array( 516b380169SMichael Große 'plugin', 526b380169SMichael Große array( 53284f9fc3SMichael Große 'structsection', array('pos' => $pos), DOKU_LEXER_SPECIAL, '', 546b380169SMichael Große ), 556b380169SMichael Große $pos, 566b380169SMichael Große ); 576b380169SMichael Große } 586b380169SMichael Große 59*15756b07SMichael Große /** 60*15756b07SMichael Große * Event handler for PLUGIN_STRUCT_TYPECLASS_INIT 61*15756b07SMichael Große * 62*15756b07SMichael Große * @param Doku_Event $event 63*15756b07SMichael Große * @param $param 64*15756b07SMichael Große */ 65*15756b07SMichael Große final public function registerTypeWithStructPlugin(Doku_Event $event, $param) 66*15756b07SMichael Große { 67284f9fc3SMichael Große $event->data['Section'] = 'dokuwiki\\plugin\\structsection\\types\\Section'; 689d2d02ffSMichael Große } 699d2d02ffSMichael Große 709d2d02ffSMichael Große} 719d2d02ffSMichael Große 729d2d02ffSMichael Große// vim:ts=4:sw=4:et: 73