-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.php
More file actions
81 lines (76 loc) · 3.03 KB
/
Copy pathaction.php
File metadata and controls
81 lines (76 loc) · 3.03 KB
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
<?php
/**
* DokuWiki Plugin dwtimeline (Action Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author saggi <saggi@gmx.de>
*/
use dokuwiki\Extension\ActionPlugin;
use dokuwiki\Extension\Event;
use dokuwiki\Extension\EventHandler;
class action_plugin_dwtimeline extends ActionPlugin
{
/**
* Register the eventhandlers
*/
public function register(EventHandler $controller)
{
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insertButton', []);
}
/**
* Inserts the toolbar button
*/
public function insertButton(Event $event, $param)
{
$event->data[] = [
'type' => 'picker',
'title' => $this->getLang('tl-picker'),
'icon' => '../../plugins/dwtimeline/icons/timeline_picker.png',
'list' => [
[
'type' => 'format',
'title' => $this->getLang('tl-button'),
'icon' => '../../plugins/dwtimeline/icons/timeline_marker.png',
'open' => $this->buildSkeleton('complete'),
'sample' => $this->getLang('ms-content'),
'close' => '\n</milestone>\n</dwtimeline title="' . $this->getLang('tl-end') . '">',
],
[
'type' => 'format',
'title' => $this->getLang('ms-button'),
'icon' => '../../plugins/dwtimeline/icons/page_white_code.png',
'open' => $this->buildSkeleton('milestone'),
'sample' => $this->getLang('ms-content'),
'close' => '\n</milestone>',
],
]
];
}
private function buildSkeleton($skeletontype, $data = null)
{
switch ($skeletontype) {
case 'complete':
$skeleton = '<dwtimeline align="' . $this->getConf('align') . '" title="';
$skeleton .= $this->getLang('tl-title') . '" description="' . $this->getLang('tl-desc') . '">\n';
$skeleton .= $this->buildSkeleton('milestone');
$skeleton .= $this->getLang('ms-content') . '\n';
$skeleton .= '</milestone>\n';
$skeleton .= $this->buildSkeleton('milestone', '02');
break;
case 'milestone':
if (!$data) {
$data = $this->getLang('ms-data');
}
$skeleton = '<milestone title="' . $this->getLang('ms-title') . '" description="';
$skeleton .= $this->getLang('ms-desc') . '" ';
$skeleton .= 'data="' . $data . '" backcolor="' . $this->getLang('ms-backcolor') . '">\n';
break;
default:
$skeleton = '<dwtimeline title="' . $this->getLang('tl-title') . '" description="';
$skeleton .= $this->getLang('tl-desc') . '">\n';
$skeleton .= $this->buildSkeleton('milestone');
break;
}
return $skeleton;
}
}