1<?php
2/**
3 * AcMenu plugin: an accordion menu for namespaces and relative pages.
4 *
5 * action.php: methods used by Acmenu plugin that interact with DokuWiki events.
6 *
7 * @author Torpedo <dcstoyanov@gmail.com>
8 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
9 * @package action
10 */
11
12/**
13 * Defines the methods used by AcMenu plugin to interact with DokuWiki's events.
14 *
15 * @package action_pycode
16 */
17class action_plugin_acmenu extends DokuWiki_Action_Plugin
18{
19
20    /**
21     * Register the event handlers
22     */
23    function register(Doku_Event_Handler $controller)
24    {
25        $controller->register_hook("DOKUWIKI_STARTED", "AFTER",  $this, "_add_user_conf", array());
26    }
27
28    /**
29     * Add some user's configuration to the $JSINFO variable.
30     *
31     * @param object $event
32     *      the event object
33     * @param array $param
34     *      data passed when this handler was registered
35     */
36    function _add_user_conf(Doku_Event $event, $param)
37    {
38        global $conf;
39        global $INFO;
40        global $JSINFO;
41        $JSINFO["plugin_acmenu"]["doku_base"] = DOKU_BASE;
42        $JSINFO["plugin_acmenu"]["doku_url"] = DOKU_URL;
43        $JSINFO["plugin_acmenu"]["doku_script"] = DOKU_SCRIPT;
44        $JSINFO["plugin_acmenu"]["start"] = $conf["start"];
45        $JSINFO["plugin_acmenu"]["useslash"] = $conf["useslash"];
46        $JSINFO["plugin_acmenu"]["canonical"] = $conf["canonical"];
47        $JSINFO["plugin_acmenu"]["userewrite"] = $conf["userewrite"];
48        // namespace genealogy doesn't exist for an id deleated
49        if(isset($INFO["meta"]["plugin"]["plugin_acmenu"]["sub_ns"])) {
50            $JSINFO["plugin_acmenu"]["sub_ns"] = $INFO["meta"]["plugin"]["plugin_acmenu"]["sub_ns"];
51        }
52    }
53}
54