1<?php
2
3use dokuwiki\Extension\ActionPlugin;
4use dokuwiki\Extension\EventHandler;
5use dokuwiki\Extension\Event;
6
7/**
8 * Action Plugin: Inserts a button into the toolbar to add file tags
9 *
10 * @author Simon Jacob, Gina Haeussge
11 */
12
13class action_plugin_codebuttonmodbash extends ActionPlugin {
14
15    /**
16     * Register the event handlers
17     *
18     * @param EventHandler $controller DokuWiki's event controller object
19     */
20    public function register(EventHandler $controller) {
21        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', []);
22    }
23
24    /**
25     * Inserts the toolbar button
26     *
27     * @param Event $event event object
28     * @param mixed $param [the parameters passed as fifth argument to
29     *                      register_hook() when this handler was registered,
30     *                      here just an empty array..]
31     */
32    public function insert_button(Event $event, $param) {
33
34        $codeStr = $this->getConf('codeStr');
35        $insert = $this->getLang('insert');
36
37        $event->data[] = [
38            'type' => 'format',
39            'title' => $insert.': <code '.$codeStr.'>...</code>',
40            'icon' => '../../plugins/codebuttonmodbash/codebash.png',
41            'open' => '<code '.$codeStr.'>\n',
42            'close' => '\n</code>',
43        ];
44    }
45}
46