1<?php
2/**
3 * Table editing plugin. Allows to manipulate with table columns order.
4 *
5 * @author Bohumir Zamecnik <bohumir@zamecnik.org>
6 */
7
8if (!defined('DOKU_INC')) die();
9if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
10require_once (DOKU_PLUGIN . 'action.php');
11
12class action_plugin_tableedit extends DokuWiki_Action_Plugin {
13
14    /**
15     * Return some info
16     */
17    function getInfo() {
18        return array (
19            'author' => 'Bohumir Zamecnik',
20            'email' => 'bohumir@zamecnik.org',
21            'date' => '2008-11-23',
22            'name' => 'Table editing plugin',
23            'desc' => 'Allows to manipulate with table columns order',
24            'url' => 'http://zamecnik.org/',
25        );
26    }
27
28    /**
29     * Register the eventhandlers
30     */
31    function register(&$controller) {
32        $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE',  $this, '_hookjs');
33        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', array ());
34    }
35
36    /**
37     * Hook js script into page headers.
38     */
39    function _hookjs(&$event, $param) {
40        $event->data["script"][] = array (
41          "type" => "text/javascript",
42          "charset" => "utf-8",
43          "_data" => "",
44          "src" => DOKU_BASE."lib/plugins/tableedit/tableedit.js"
45        );
46    }
47
48
49    /**
50     * Inserts the toolbar button
51     */
52    function insert_button(& $event, $param) {
53        $event->data[] = array (
54            'type' => 'tableedit',
55            'title' => $this->getLang('qb_tableedit'),
56            'icon' => '../../plugins/tableedit/tableedit.png',
57            'prompt' => $this->getLang('new_columns_order'),
58        );
59    }
60}
61