1<?php
2/**
3 * DokuWiki Plugin structrowcolor (Action Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Szymon Olewniczak <it@rid.pl>
7 */
8
9// must be run within Dokuwiki
10if (!defined('DOKU_INC')) {
11    die();
12}
13
14class action_plugin_structat_struct extends DokuWiki_Action_Plugin
15{
16
17    /**
18     * Registers a callback function for a given event
19     *
20     * @param Doku_Event_Handler $controller DokuWiki's event controller object
21     *
22     * @return void
23     */
24    public function register(Doku_Event_Handler $controller)
25    {
26        $controller->register_hook('PLUGIN_STRUCT_CONFIGPARSER_UNKNOWNKEY', 'BEFORE', $this, 'handle_plugin_struct_configparser_unknownkey');
27    }
28
29    /**
30     * [Custom event handler which performs action]
31     *
32     * Called for event:
33     *
34     * @param Doku_Event $event  event object by reference
35     *
36     * @return void
37     */
38    public function handle_plugin_struct_configparser_unknownkey(Doku_Event $event)
39    {
40        $data = $event->data;
41        $key = $data['key'];
42        if ($key != 'at') return;
43
44        $event->preventDefault();
45        $event->stopPropagation();
46
47        $val = $data['val'];
48        switch ($key) {
49            case 'at':
50                $val = trim($val);
51                break;
52        }
53        $data['config'][$key] = $val;
54    }
55}
56
57