1<?php
2/**
3 * Action Plugin: Inserts a button into the toolbar to add file tags
4 *
5 * @author Georg Schmidt, Heiko Barth, Davide Rolando
6 *
7 */
8
9if (!defined('DOKU_INC')) die();
10if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
11require_once (DOKU_PLUGIN . 'action.php');
12
13class action_plugin_codebuttonmod1 extends DokuWiki_Action_Plugin {
14
15    /**
16     * Register the eventhandlers
17     */
18    function register(Doku_Event_Handler $controller) {
19        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', array ());
20		$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button_copy', array ());
21		$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button_inline', array ());
22		$controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this,'_hookjs');
23    }
24
25    /**
26     * Insert a toolbar button
27     */
28    function insert_button(& $event, $param) {
29        $event->data[] = array (
30            'type' => 'format',
31            'title' => $this->getLang('insertcode'),
32            'icon' => '../../plugins/codebuttonmod1/image/code.png',
33            'open' => '<code | download>\n',
34            'close' => '\n</code>',
35        );
36    }
37
38	/**
39     * Insert a toolbar button
40     */
41    function insert_button_inline(& $event, $param) {
42        $event->data[] = array (
43            'type' => 'format',
44            'title' => $this->getLang('insertcodeinline'),
45            'icon' => '../../plugins/codebuttonmod1/image/inline-button+.png',
46            'open' => "''%%",
47            'close' => "%%''",
48        );
49    }
50
51    /**
52     * Insert a toolbar button
53     */
54    function insert_button_copy(& $event, $param) {
55        $event->data[] = array (
56            'type' => 'format',
57            'title' => $this->getLang('insertcodecopy'),
58            'icon' => '../../plugins/codebuttonmod1/image/copy_code_small.png',
59            'open' => '<code>\n',
60            'close' => '\n</code>',
61        );
62    }
63
64
65
66    /**
67     * Hook js script into page headers.
68     *
69     * @author Samuele Tognini <samuele@cli.di.unipi.it>
70     */
71    public function _hookjs(Doku_Event $event, $param) {
72        $event->data['script'][] = array(
73                            'type'    => 'text/javascript',
74                            'charset' => 'utf-8',
75                            '_data'   => '',
76                            'src'     => DOKU_BASE.'lib/plugins/codebuttonmod1/'.'src/codebutton.js'
77							);
78							#'src'     => DOKU_PLUGIN.'src/codebutton.js');
79    }
80}
81
82?>