1<?php
2/**
3 * AutoIndentControl Plugin for DokuWiki / action.php
4 *
5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author  Kazutaka Miyasaka <kazmiya@gmail.com>
7 */
8
9// must be run within DokuWiki
10if (!defined('DOKU_INC')) {
11    die();
12}
13
14if (!defined('DOKU_PLUGIN')) {
15    define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
16}
17
18require_once DOKU_PLUGIN . 'action.php';
19
20class action_plugin_autoindentcontrol extends DokuWiki_Action_Plugin
21{
22    /**
23     * Returns some info
24     */
25    function getInfo()
26    {
27        return confToHash(DOKU_PLUGIN . 'autoindentcontrol/plugin.info.txt');
28    }
29
30    /**
31     * Registers an event handler
32     */
33    function register(&$controller)
34    {
35        $controller->register_hook(
36            'DOKUWIKI_STARTED', 'AFTER', $this, 'exportToJSINFO'
37        );
38    }
39
40    /**
41     * Exports configuration settings to $JSINFO
42     */
43    function exportToJSINFO(&$event)
44    {
45        global $JSINFO;
46
47        $JSINFO['plugin_autoindentcontrol'] = array(
48            'defaultOFF' => (boolean) !$this->getConf('default_behavior'),
49            'showToggle' => (boolean) $this->getConf('show_toggle_switch'),
50            'isLemming'  => (boolean) !function_exists('valid_input_set'),
51        );
52    }
53}
54