-
Notifications
You must be signed in to change notification settings - Fork 20
/
action.php
79 lines (71 loc) · 3.01 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
<?php
/**
* Folded plugin: enables folded text font size with syntax ++ text ++
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Michael Hamann <[email protected]>
*/
/**
* Action part: makes the show/hide strings available in the browser
*/
class action_plugin_folded extends DokuWiki_Action_Plugin {
/**
* Register the handle function in the controller
*
* @param Doku_event_handler $controller The event controller
*/
function register(Doku_Event_Handler $controller) {
$controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, 'addhidereveal');
$controller->register_hook('TEMPLATE_PAGETOOLS_DISPLAY', 'BEFORE', $this, 'add_button', array());
$controller->register_hook('MENU_ITEMS_ASSEMBLY', 'AFTER', $this, 'add_button_new', array());
}
/**
* Add the hide and reveal strings to $JSINFO so it can be used in the javascript
*
* @param Doku_Event $event The event
* @param array $params The parameters for the event
*/
function addhidereveal($event, $params) {
global $JSINFO;
$hide = $this->getConf('hide') ? $this->getConf('hide') : $this->getLang('hide');
$reveal = $this->getConf('reveal') ? $this->getConf('reveal') : $this->getLang('reveal');
$JSINFO['plugin_folded'] = array(
'hide' => $hide,
'reveal' => $reveal
);
}
/**
* Add 'fold/unfold all'-button to pagetools
*
* @param Doku_Event $event
* @param mixed $param not defined
*/
public function add_button(&$event, $param) {
global $ID, $REV;
if($this->getConf('show_fold_unfold_all_button') && $event->data['view'] == 'main') {
$params = array('do' => 'fold_unfold_all');
if($REV) $params['rev'] = $REV;
// insert button at position before last (up to top)
$event->data['items'] = array_slice($event->data['items'], 0, -1, true) +
array('fold_unfold_all' =>
'<li>'
.'<a href="javascript:void(0);" class="fold_unfold_all" onclick="fold_unfold_all();" rel="nofollow" title="'.$this->getLang('fold_unfold_all_button').'">'
.'<span>'.$this->getLang('fold_unfold_all_button').'</span>'
.'</a>'
.'</li>'
) +
array_slice($event->data['items'], -1 , 1, true);
}
}
/**
* Add 'fold/unfold all'-button to pagetools, new SVG based mechanism
*
* @param Doku_Event $event
*/
public function add_button_new(Doku_Event $event) {
if($event->data['view'] != 'page') return;
if($this->getConf('show_fold_unfold_all_button')) {
array_splice($event->data['items'], -1, 0, [new \dokuwiki\plugin\folded\MenuItemFolded()]);
}
}
}