1<?php
2/**
3 * @author: Myron Turner <turnermm03@shaw.ca>
4 * @license GPLv2 (http://www.gnu.org/licenses/gpl2.html)
5 * @adds and/or deletes characters in the Special Chars picker
6 */
7
8// must be run within Dokuwiki
9if (!defined('DOKU_INC')) die();
10
11//require_once DOKU_PLUGIN.'action.php';
12
13class action_plugin_charpicker extends DokuWiki_Action_Plugin {
14     public function register(Doku_Event_Handler $controller) {
15      $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'check_toolbar');
16    }
17
18
19     public function check_toolbar( &$event, $param) {
20       global $lang;
21       $title = $lang['qb_chars'];
22       $test= array('À','à','Á','á','Â','â','Ã','ã','Ä','ä','A','a','A','a','Å','å','A','a','A','a','Æ','æ','C','c','Ç','ç','C','c','Ò','ò','Ó','ó','Ô','¢','£','¤','¥','€','¦','§','µ','¶','†','‡','·','•','º');
23
24         $add_chars = $this->getConf('chars');
25         if(!$add_chars) {
26             $add_chars = '‰';
27         }
28         $add_chars = str_replace(' ',"",$add_chars);
29         $add_chars = explode(',',$add_chars);
30         $del_chars = $this->getConf('del_chars');
31         if(!$del_chars) {
32             $del_chars = '‰';
33         }
34         $del_chars = str_replace(' ',"",$del_chars);
35         $del_chars = explode(',',$del_chars);
36
37        for($i=0;$i<count($event->data); $i++) {
38            if($event->data[$i]['type']=='picker') {
39                if(preg_match("/$title/i", $event->data[$i]['title'])){
40                     if($this->getConf('del_all')) {
41                         $event->data[$i]['list'] =  array();
42                      }
43                     else {
44                       $event->data[$i]['list'] = array_diff($event->data[$i]['list'],$del_chars);
45                     }
46                    $event->data[$i]['list'] = array_merge($event->data[$i]['list'],$add_chars);
47                    break;
48                   }
49            }
50        }
51
52     }
53
54
55}
56
57// vim:ts=4:sw=4:et:
58