-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaction.php
152 lines (146 loc) · 5.33 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
/**
* DokuWiki Plugin Typography; Action component
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Satoshi Sahara <[email protected]>
*/
class action_plugin_typography extends DokuWiki_Action_Plugin
{
/**
* register the event handlers
*/
public function register(Doku_Event_Handler $controller)
{
if (plugin_isdisabled('fontcolor')) {
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'fontColorToolbar', array());
}
if (plugin_isdisabled('fontsize2')) {
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'fontSizeToolbar', array());
}
if (plugin_isdisabled('fontfamily')) {
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'fontFamilyToolbar', array());
}
}
/**
* Adds FontColor toolbar button
* @see https://www.dokuwiki.org/plugin:fontcolor
*/
public function fontColorToolbar(Doku_Event $event, $param)
{
$title_note = '';
$colors = array(
'White' => '#ffffff',
'Yellow' => '#ffff00',
'Red' => '#ff0000',
'Orange' => '#ffa500',
'Salmon' => '#fa8072',
'Pink' => '#ffc0cb',
'Plum' => '#dda0dd',
'Purple' => '#800080',
'Fuchsia' => '#ff00ff',
'Silver' => '#c0c0c0',
'Aqua' => '#00ffff',
'Teal' => '#008080',
'Cornflower' => '#6495ed',
'Sky Blue' => '#87ceeb',
'Aquamarine' => '#7fffd4',
'Pale Green' => '#98fb98',
'Lime' => '#00ff00',
'Green' => '#008000',
'Olive' => '#808000',
'Indian Red' => '#cd5c5c',
'Khaki' => '#f0e68c',
'Powder Blue' => '#b0e0e6',
'Sandy Brown' => '#f4a460',
'Steel Blue' => '#4682b4',
'Thistle' => '#d8bfd8',
'Yellow Green' => '#9acd32',
'Dark Violet' => '#9400d3',
'Maroon' => '#800000'
);
$button = array(
'type' => 'picker',
'title' => $this->getLang('fc_picker') . $title_note,
'icon' => DOKU_REL.'lib/plugins/typography/images/fontcolor/picker.png',
'list' => array()
);
foreach ($colors as $colorName => $colorValue) {
$button['list'][] = array(
'type' => 'format',
'title' => $colorName,
'icon' => DOKU_REL
.'lib/plugins/typography/images/fontcolor/color-icon.php?color='
.substr($colorValue, 1),
'open' => '<fc ' . $colorValue . '>',
'close' => '</fc>'
);
}
$event->data[] = $button;
}
/**
* Adds FontFamily toolbar button
* @see https://www.dokuwiki.org/plugin:fontcfamily
*/
public function fontFamilyToolbar(Doku_Event $event, $param)
{
$options = array(
'serif' => 'serif',
'sans-serif' => 'sans-serif',
//'cursive' => 'cursive',
//'fantasy' => 'fantasy',
);
$button = array(
'type' => 'picker',
'title' => $this->getLang('ff_picker'),
'icon' => DOKU_REL.'lib/plugins/typography/images/fontfamily/picker.png',
'list' => array()
);
foreach ($options as $familyName => $familyValue) {
$button['list'][] = array(
'type' => 'format',
'title' => $this->getLang('ff_'.$familyName),
'sample' => $this->getLang('ff_'.$familyName.'_sample'),
'icon' => DOKU_REL.'lib/plugins/typography/images/fontfamily/'.$familyName.'.png',
'open' => '<ff '.$familyValue.'>',
'close' => '</ff>',
);
}
$event->data[] = $button;
}
/**
* Adds FontSize toolbar button
* @see https://www.dokuwiki.org/plugin:fontsize2
*/
public function fontSizeToolbar(Doku_Event $event, $param)
{
$options = array(
'xxs' => 'xx-small',
'xs' => 'x-small',
's' => 'small',
'm' => 'medium',
'l' => 'large',
'xl' => 'x-large',
'xxl' => 'xx-large',
'smaller' => 'smaller',
'larger' => 'larger'
);
$button = array(
'type' => 'picker',
'title' => $this->getLang('fs_picker'),
'icon' => DOKU_REL.'lib/plugins/typography/images/fontsize/picker.png',
'list' => array()
);
foreach ($options as $sizeName => $sizeValue) {
$button['list'][] = array(
'type' => 'format',
'title' => $this->getLang('fs_'.$sizeName),
'sample' => $this->getLang('fs_'.$sizeName.'_sample'),
'icon' => DOKU_REL.'lib/plugins/typography/images/fontsize/'.$sizeName.'.png',
'open' => '<fs '.$sizeValue.'>',
'close' => '</fs>',
);
}
$event->data[] = $button;
}
}