-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathaction.php
53 lines (45 loc) · 1.56 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
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Esther Brunner <wikidesign@gmail.com>
*/
class action_plugin_creole extends DokuWiki_Action_Plugin {
/**
* register the eventhandlers
*/
function register(Doku_Event_Handler $controller) {
$controller->register_hook('TOOLBAR_DEFINE',
'AFTER',
$this,
'define_toolbar',
array());
}
/**
* modifiy the toolbar JS defines
*
* @author Esther Brunner <wikidesign@gmail.com>
*/
function define_toolbar(&$event, $param) {
// return false;
if ($this->getConf('precedence') != 'creole') return false; // leave untouched
$c = count($event->data);
for ($i = 0; $i <= $c; $i++) {
if ($event->data[$i]['type'] == 'format') {
// headers
if (preg_match("/h(\d)\.png/", $event->data[$i]['icon'], $match)) {
$markup = substr('======', 0, $match[1]);
$event->data[$i]['open'] = $markup." ";
$event->data[$i]['close'] = " ".$markup."\\n";
// ordered lists
} elseif ($event->data[$i]['icon'] == 'ol.png') {
$event->data[$i]['open'] = "# ";
// unordered lists
} elseif ($event->data[$i]['icon'] == 'ul.png') {
$event->data[$i]['open'] = "* ";
}
}
}
return true;
}
}
// vim:ts=4:sw=4:et:enc=utf-8: