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