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 915756b07SMichael Großeclass action_plugin_structsection extends DokuWiki_Action_Plugin 1015756b07SMichael 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 */ 1815756b07SMichael Große public function register(Doku_Event_Handler $controller) 1915756b07SMichael Große { 2015756b07SMichael Große $controller->register_hook('PARSER_HANDLER_DONE', 'AFTER', $this, 'appendPluginOutputToPage'); 2115756b07SMichael Große $controller->register_hook('PLUGIN_STRUCT_TYPECLASS_INIT', 'BEFORE', $this, 'registerTypeWithStructPlugin'); 229d2d02ffSMichael Große } 239d2d02ffSMichael Große 249d2d02ffSMichael Große /** 2515756b07SMichael 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 */ 3215756b07SMichael Große final public function appendPluginOutputToPage(Doku_Event $event, $param) 3315756b07SMichael Große { 341d58a283SMichael Große static $instructionsAdded = false; 351d58a283SMichael Große 366b380169SMichael Große /** @var helper_plugin_struct $struct */ 376b380169SMichael Große $struct = plugin_load('helper', 'struct'); 386b380169SMichael Große if (!$struct) { 396b380169SMichael Große return; 406b380169SMichael Große } 416b380169SMichael Große 426b380169SMichael Große global $ACT; 436b380169SMichael Große 446b380169SMichael Große if (act_clean($ACT) != 'show') { 456b380169SMichael Große dbglog($ACT, __FILE__ .': '.__LINE__); 466b380169SMichael Große return; 476b380169SMichael Große } 486b380169SMichael Große 491d58a283SMichael Große if ($instructionsAdded) { 501d58a283SMichael Große return; 511d58a283SMichael Große } 521d58a283SMichael Große 531d58a283SMichael Große $instructionsAdded = true; 541d58a283SMichael Große 556b380169SMichael Große $last = end($event->data->calls); 56*78317c4bSMichael Große 57*78317c4bSMichael Große $INSTRUCTION_POSITION_INDEX = 2; 58*78317c4bSMichael Große $pos = $last[$INSTRUCTION_POSITION_INDEX]; 596b380169SMichael Große 606b380169SMichael Große $event->data->calls[] = array( 616b380169SMichael Große 'plugin', 626b380169SMichael Große array( 63284f9fc3SMichael Große 'structsection', array('pos' => $pos), DOKU_LEXER_SPECIAL, '', 646b380169SMichael Große ), 656b380169SMichael Große $pos, 666b380169SMichael Große ); 676b380169SMichael Große } 686b380169SMichael Große 6915756b07SMichael Große /** 7015756b07SMichael Große * Event handler for PLUGIN_STRUCT_TYPECLASS_INIT 7115756b07SMichael Große * 7215756b07SMichael Große * @param Doku_Event $event 7315756b07SMichael Große * @param $param 7415756b07SMichael Große */ 7515756b07SMichael Große final public function registerTypeWithStructPlugin(Doku_Event $event, $param) 7615756b07SMichael Große { 77284f9fc3SMichael Große $event->data['Section'] = 'dokuwiki\\plugin\\structsection\\types\\Section'; 789d2d02ffSMichael Große } 799d2d02ffSMichael Große 809d2d02ffSMichael Große} 819d2d02ffSMichael Große 829d2d02ffSMichael Große// vim:ts=4:sw=4:et: 83