1<?php 2/** 3 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 4 * @author Esther Brunner <wikidesign@gmail.com> 5 */ 6 7class action_plugin_creole extends DokuWiki_Action_Plugin { 8 9 /** 10 * register the eventhandlers 11 */ 12 function register(Doku_Event_Handler $controller) { 13 $controller->register_hook('TOOLBAR_DEFINE', 14 'AFTER', 15 $this, 16 'define_toolbar', 17 array()); 18 } 19 20 /** 21 * modifiy the toolbar JS defines 22 * 23 * @author Esther Brunner <wikidesign@gmail.com> 24 */ 25 function define_toolbar(&$event, $param) { 26 // return false; 27 if ($this->getConf('precedence') != 'creole') return false; // leave untouched 28 29 $c = count($event->data); 30 for ($i = 0; $i <= $c; $i++) { 31 if ($event->data[$i]['type'] == 'format') { 32 33 // headers 34 if (preg_match("/h(\d)\.png/", $event->data[$i]['icon'], $match)) { 35 $markup = substr('======', 0, $match[1]); 36 $event->data[$i]['open'] = $markup." "; 37 $event->data[$i]['close'] = " ".$markup."\\n"; 38 39 // ordered lists 40 } elseif ($event->data[$i]['icon'] == 'ol.png') { 41 $event->data[$i]['open'] = "# "; 42 43 // unordered lists 44 } elseif ($event->data[$i]['icon'] == 'ul.png') { 45 $event->data[$i]['open'] = "* "; 46 } 47 } 48 } 49 50 return true; 51 } 52} 53// vim:ts=4:sw=4:et:enc=utf-8: 54