xref: /plugin/struct/action/output.php (revision f94f4c4fafaabb034468b54ec3316549226c595b)
1<?php
2/**
3 * DokuWiki Plugin struct (Action Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Andreas Gohr, Michael Große <dokuwiki@cosmocode.de>
7 */
8
9// must be run within Dokuwiki
10if(!defined('DOKU_INC')) die();
11
12/**
13 * Class action_plugin_struct_output
14 *
15 * This action component handles the automatic output of all schema data that has been assigned
16 * to the current page by appending the appropriate instruction to the handler calls.
17 *
18 * The real output creation is done within the syntax component
19 * @see syntax_plugin_struct_output
20 */
21class action_plugin_struct_output extends DokuWiki_Action_Plugin {
22
23    /**
24     * Registers a callback function for a given event
25     *
26     * @param Doku_Event_Handler $controller DokuWiki's event controller object
27     * @return void
28     */
29    public function register(Doku_Event_Handler $controller) {
30        $controller->register_hook('PARSER_HANDLER_DONE', 'AFTER', $this, 'handle_output');
31
32    }
33
34    /**
35     * Appends the instruction to render our syntax output component to each page
36     *
37     * @param Doku_Event $event
38     * @param $param
39     */
40    public function handle_output(Doku_Event &$event, $param) {
41        global $ACT;
42        global $ID;
43        if($ACT != 'show') return; //FIXME what about export_*?
44        if(!page_exists($ID)) return;
45
46        $pos = filesize(wikiFN($ID))+1;
47
48        $event->data->calls[] = array(
49            'plugin',
50            array(
51                'struct_output', array('pos'=>$pos), DOKU_LEXER_SPECIAL, ''
52            ),
53            $pos
54        );
55    }
56
57}
58
59// vim:ts=4:sw=4:et:
60