-
Notifications
You must be signed in to change notification settings - Fork 22
/
action.php
90 lines (80 loc) · 2.46 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
83
84
85
86
87
88
89
90
<?php
/**
* Bootstrap Wrapper Action Plugin
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Giuseppe Di Terlizzi <[email protected]>
* @copyright (C) 2015-2020, Giuseppe Di Terlizzi
*/
/**
* Bootstrap Wrapper Action Plugin
*
* Add external CSS file to DokuWiki
*/
class action_plugin_bootswrapper extends DokuWiki_Action_Plugin
{
/**
* Syntax with section edit
*
* @var array
*/
private $section_edit_buttons = array(
'plugin_bootswrapper_pane',
'plugin_bootswrapper_panel',
);
/**
* Register events
*
* @param Doku_Event_Handler $controller
*/
public function register(Doku_Event_Handler $controller)
{
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, '_insert_button');
$controller->register_hook('HTML_SECEDIT_BUTTON', 'BEFORE', $this, '_secedit_button');
$controller->register_hook('HTML_EDIT_FORMSELECTION', 'BEFORE', $this, '_editform'); // deprecated
$controller->register_hook('EDIT_FORM_ADDTEXTAREA', 'BEFORE', $this, '_editform'); // replacement
}
/**
* Edit Form
*
* @param Doku_Event &$event
*/
public function _editform(Doku_Event $event)
{
if (!in_array($event->data['target'], $this->section_edit_buttons)) {
return;
}
$event->data['target'] = 'section';
return;
}
/**
* Set Section Edit button
*
* @param Doku_Event &$event
*/
public function _secedit_button(Doku_Event $event)
{
global $lang;
if (!in_array($event->data['target'], $this->section_edit_buttons)) {
return;
}
$event->data['name'] = $lang['btn_secedit'] . ' - ' . ucfirst(str_replace('plugin_bootswrapper_', '', $event->data['target']));
}
/**
* Set toolbar button in edit mode
*
* @param Doku_Event &$event
*/
public function _insert_button(Doku_Event $event, $param)
{
$event->data[] = array(
'type' => 'mediapopup',
'title' => 'Bootstrap Wrapper',
'icon' => '../../plugins/bootswrapper/images/bootstrap.png',
'url' => 'lib/plugins/bootswrapper/exe/popup.php?ns=',
'name' => 'bootstrap-wrapper',
'options' => 'width=800,height=600,left=20,top=20,toolbar=no,menubar=no,scrollbars=yes,resizable=yes',
'block' => false,
);
}
}