1<?php
2/**
3 * Action Component
4 * Add a button in the edit toolbar
5 *
6 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
7 * @author     Nicolas GERARD
8 */
9
10if (!defined('DOKU_INC')) die();
11require_once(__DIR__ . '/../webcomponent.php');
12
13
14class action_plugin_webcomponent_toolbar extends DokuWiki_Action_Plugin {
15
16    /**
17     * register the event handlers
18     *
19     * @author Nicolas GERARD
20     */
21    function register(Doku_Event_Handler $controller){
22        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handle_toolbar', array ());
23    }
24
25    function handle_toolbar(&$event, $param) {
26        $unitShortcutKey = $this->getConf('UnitShortCutKey');
27
28        $event->data[] = array(
29            'type'   => 'format',
30            'title'  => $this->getLang('DocBlockButtonTitle').' ('.$this->getLang('AccessKey').': '.$unitShortcutKey.')',
31            'icon'   => '../../plugins/'.webcomponent::PLUGIN_NAME.'/images/docblock.png',
32            'open'   => '<unit name="default">\n<file lang path>\n</file>\n\t<code lang>',
33            'close'  => '\n\t</code>\n\tt<console>\n\t</console></unit>\n',
34            'key'    => $unitShortcutKey
35        );
36
37
38    }
39
40}
41
42