xref: /plugin/struct/action/output.php (revision a8db59501b767d5350ff6483a74550ec9de50781)
182c064c1SAndreas Gohr<?php
282c064c1SAndreas Gohr/**
382c064c1SAndreas Gohr * DokuWiki Plugin struct (Action Component)
482c064c1SAndreas Gohr *
582c064c1SAndreas Gohr * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
682c064c1SAndreas Gohr * @author  Andreas Gohr, Michael Große <dokuwiki@cosmocode.de>
782c064c1SAndreas Gohr */
882c064c1SAndreas Gohr
982c064c1SAndreas Gohr// must be run within Dokuwiki
1082c064c1SAndreas Gohrif(!defined('DOKU_INC')) die();
1182c064c1SAndreas Gohr
1282c064c1SAndreas Gohr/**
1382c064c1SAndreas Gohr * Class action_plugin_struct_output
1482c064c1SAndreas Gohr *
1582c064c1SAndreas Gohr * This action component handles the automatic output of all schema data that has been assigned
1682c064c1SAndreas Gohr * to the current page by appending the appropriate instruction to the handler calls.
1782c064c1SAndreas Gohr *
1882c064c1SAndreas Gohr * The real output creation is done within the syntax component
1982c064c1SAndreas Gohr * @see syntax_plugin_struct_output
2082c064c1SAndreas Gohr */
2182c064c1SAndreas Gohrclass action_plugin_struct_output extends DokuWiki_Action_Plugin {
2282c064c1SAndreas Gohr
2382c064c1SAndreas Gohr    /**
2482c064c1SAndreas Gohr     * Registers a callback function for a given event
2582c064c1SAndreas Gohr     *
2682c064c1SAndreas Gohr     * @param Doku_Event_Handler $controller DokuWiki's event controller object
2782c064c1SAndreas Gohr     * @return void
2882c064c1SAndreas Gohr     */
2982c064c1SAndreas Gohr    public function register(Doku_Event_Handler $controller) {
3082c064c1SAndreas Gohr        $controller->register_hook('PARSER_HANDLER_DONE', 'AFTER', $this, 'handle_output');
3182c064c1SAndreas Gohr
3282c064c1SAndreas Gohr    }
3382c064c1SAndreas Gohr
3482c064c1SAndreas Gohr    /**
3582c064c1SAndreas Gohr     * Appends the instruction to render our syntax output component to each page
3682c064c1SAndreas Gohr     *
3782c064c1SAndreas Gohr     * @param Doku_Event $event
3882c064c1SAndreas Gohr     * @param $param
3982c064c1SAndreas Gohr     */
4082c064c1SAndreas Gohr    public function handle_output(Doku_Event &$event, $param) {
4182c064c1SAndreas Gohr        global $ACT;
425a1eab78SAndreas Gohr        global $ID;
43*a8db5950SAndreas Gohr        // blank $ACT happens when instructions are rendered in indexer
44*a8db5950SAndreas Gohr        if(!blank($ACT) &&  $ACT != 'show') return; //FIXME what about export_*?
4502481400SAndreas Gohr        if(!page_exists($ID)) return;
4682c064c1SAndreas Gohr
475a1eab78SAndreas Gohr        $pos = filesize(wikiFN($ID))+1;
4882c064c1SAndreas Gohr
4982c064c1SAndreas Gohr        $event->data->calls[] = array(
5082c064c1SAndreas Gohr            'plugin',
5182c064c1SAndreas Gohr            array(
525a1eab78SAndreas Gohr                'struct_output', array('pos'=>$pos), DOKU_LEXER_SPECIAL, ''
5382c064c1SAndreas Gohr            ),
5482c064c1SAndreas Gohr            $pos
5582c064c1SAndreas Gohr        );
5682c064c1SAndreas Gohr    }
5782c064c1SAndreas Gohr
5882c064c1SAndreas Gohr}
5982c064c1SAndreas Gohr
6082c064c1SAndreas Gohr// vim:ts=4:sw=4:et:
61