xref: /dokuwiki/inc/toolbar.php (revision a989fef837bbeb01153f67fab49f0de2cd9e8b32)
1<?php
2/**
3 * Editing toolbar functions
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Andreas Gohr <andi@splitbrain.org>
7 */
8
9if(!defined('DOKU_INC')) die('meh.');
10require_once(DOKU_INC.'inc/JSON.php');
11
12
13/**
14 * Prepares and prints an JavaScript array with all toolbar buttons
15 *
16 * @todo add toolbar plugins
17 * @param  string $varname Name of the JS variable to fill
18 * @author Andreas Gohr <andi@splitbrain.org>
19 */
20function toolbar_JSdefines($varname){
21    global $ID;
22    global $conf;
23    global $lang;
24
25    $menu = array();
26
27    $evt = new Doku_Event('TOOLBAR_DEFINE', $menu);
28    if ($evt->advise_before()){
29
30        // build button array
31        $menu = array_merge($menu, array(
32           array(
33                'type'   => 'format',
34                'title'  => $lang['qb_bold'],
35                'icon'   => 'bold.png',
36                'key'    => 'b',
37                'open'   => '**',
38                'close'  => '**',
39                ),
40           array(
41                'type'   => 'format',
42                'title'  => $lang['qb_italic'],
43                'icon'   => 'italic.png',
44                'key'    => 'i',
45                'open'   => '//',
46                'close'  => '//',
47                ),
48           array(
49                'type'   => 'format',
50                'title'  => $lang['qb_underl'],
51                'icon'   => 'underline.png',
52                'key'    => 'u',
53                'open'   => '__',
54                'close'  => '__',
55                ),
56           array(
57                'type'   => 'format',
58                'title'  => $lang['qb_code'],
59                'icon'   => 'mono.png',
60                'key'    => 'c',
61                'open'   => "''",
62                'close'  => "''",
63                ),
64           array(
65                'type'   => 'format',
66                'title'  => $lang['qb_strike'],
67                'icon'   => 'strike.png',
68                'key'    => 'd',
69                'open'  => '<del>',
70                'close'   => '</del>',
71                ),
72           array(
73                'type'   => 'format',
74                'title'  => $lang['qb_h1'],
75                'icon'   => 'h1.png',
76                'key'    => '1',
77                'open'   => '====== ',
78                'close'  => ' ======\n',
79                ),
80           array(
81                'type'   => 'format',
82                'title'  => $lang['qb_h2'],
83                'icon'   => 'h2.png',
84                'key'    => '2',
85                'open'   => '===== ',
86                'close'  => ' =====\n',
87                ),
88           array(
89                'type'   => 'format',
90                'title'  => $lang['qb_h3'],
91                'icon'   => 'h3.png',
92                'key'    => '3',
93                'open'   => '==== ',
94                'close'  => ' ====\n',
95                ),
96           array(
97                'type'   => 'format',
98                'title'  => $lang['qb_h4'],
99                'icon'   => 'h4.png',
100                'key'    => '4',
101                'open'   => '=== ',
102                'close'  => ' ===\n',
103                ),
104           array(
105                'type'   => 'format',
106                'title'  => $lang['qb_h5'],
107                'icon'   => 'h5.png',
108                'key'    => '5',
109                'open'   => '== ',
110                'close'  => ' ==\n',
111                ),
112           array(
113                'type'   => 'format',
114                'title'  => $lang['qb_link'],
115                'icon'   => 'link.png',
116                'key'    => 'l',
117                'open'   => '[[',
118                'close'  => ']]',
119                ),
120           array(
121                'type'   => 'format',
122                'title'  => $lang['qb_extlink'],
123                'icon'   => 'linkextern.png',
124                'open'   => '[[',
125                'close'  => ']]',
126                'sample' => 'http://example.com|'.$lang['qb_extlink'],
127                ),
128           array(
129                'type'   => 'format',
130                'title'  => $lang['qb_ol'],
131                'icon'   => 'ol.png',
132                'open'   => '  - ',
133                'close'  => '\n',
134                ),
135           array(
136                'type'   => 'format',
137                'title'  => $lang['qb_ul'],
138                'icon'   => 'ul.png',
139                'open'   => '  * ',
140                'close'  => '\n',
141                ),
142           array(
143                'type'   => 'insert',
144                'title'  => $lang['qb_hr'],
145                'icon'   => 'hr.png',
146                'insert' => '\n----\n',
147                ),
148           array(
149                'type'   => 'mediapopup',
150                'title'  => $lang['qb_media'],
151                'icon'   => 'image.png',
152                'url'    => 'lib/exe/mediamanager.php?ns=',
153                'name'   => 'mediaselect',
154                'options'=> 'width=750,height=500,left=20,top=20,scrollbars=yes,resizable=yes',
155                ),
156          array(
157                'type'   => 'picker',
158                'title'  => $lang['qb_smileys'],
159                'icon'   => 'smiley.png',
160                'list'   => getSmileys(),
161                'icobase'=> 'smileys',
162               ),
163          array(
164                'type'   => 'picker',
165                'title'  => $lang['qb_chars'],
166                'icon'   => 'chars.png',
167                'list'   => explode(' ','À à Á á  â à ã Ä ä Ǎ ǎ Ă ă Å å Ā ā Ą ą Æ æ Ć ć Ç ç Č č Ĉ ĉ Ċ ċ Ð đ ð Ď ď È è É é Ê ê Ë ë Ě ě Ē ē Ė ė Ę ę Ģ ģ Ĝ ĝ Ğ ğ Ġ ġ Ĥ ĥ Ì ì Í í Î î Ï ï Ǐ ǐ Ī ī İ ı Į į Ĵ ĵ Ķ ķ Ĺ ĺ Ļ ļ Ľ ľ Ł ł Ŀ ŀ Ń ń Ñ ñ Ņ ņ Ň ň Ò ò Ó ó Ô ô Õ õ Ö ö Ǒ ǒ Ō ō Ő ő Œ œ Ø ø Ŕ ŕ Ŗ ŗ Ř ř Ś ś Ş ş Š š Ŝ ŝ Ţ ţ Ť ť Ù ù Ú ú Û û Ü ü Ǔ ǔ Ŭ ŭ Ū ū Ů ů ǖ ǘ ǚ ǜ Ų ų Ű ű Ŵ ŵ Ý ý Ÿ ÿ Ŷ ŷ Ź ź Ž ž Ż ż Þ þ ß Ħ ħ ¿ ¡ ¢ £ ¤ ¥ € ¦ § ª ¬ ¯ ° ± ÷ ‰ ¼ ½ ¾ ¹ ² ³ µ ¶ † ‡ · • º ∀ ∂ ∃ Ə ə ∅ ∇ ∈ ∉ ∋ ∏ ∑ ‾ − ∗ √ ∝ ∞ ∠ ∧ ∨ ∩ ∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤ ≥ ⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ◊ ℘ ℑ ℜ ℵ ♠ ♣ ♥ ♦ α β Γ γ Δ δ ε ζ η Θ θ ι κ Λ λ μ Ξ ξ Π π ρ Σ σ Τ τ υ Φ φ χ Ψ ψ Ω ω ★ ☆ ☎ ☚ ☛ ☜ ☝ ☞ ☟ ☹ ☺ ✔ ✘ × „ “ ” ‚ ‘ ’ « » ‹ › — – … ← ↑ → ↓ ↔ ⇐ ⇑ ⇒ ⇓ ⇔ © ™ ® ′ ″ [ ] { } ~ ( ) % § $ # | @'),
168               ),
169          array(
170                'type'   => 'signature',
171                'title'  => $lang['qb_sig'],
172                'icon'   => 'sig.png',
173                'key'    => 'y',
174               ),
175        ));
176    } // end event TOOLBAR_DEFINE default action
177    $evt->advise_after();
178    unset($evt);
179
180    // use JSON to build the JavaScript array
181    $json = new JSON();
182    print "var $varname = ".$json->encode($menu).";\n";
183}
184
185/**
186 * prepares the signature string as configured in the config
187 *
188 * @author Andreas Gohr <andi@splitbrain.org>
189 */
190function toolbar_signature(){
191  global $conf;
192  global $INFO;
193
194  $sig = $conf['signature'];
195  $sig = strftime($sig);
196  $sig = str_replace('@USER@',$_SERVER['REMOTE_USER'],$sig);
197  $sig = str_replace('@NAME@',$INFO['userinfo']['name'],$sig);
198  $sig = str_replace('@MAIL@',$INFO['userinfo']['mail'],$sig);
199  $sig = str_replace('@DATE@',strftime($conf['dformat']),$sig);
200  $sig = str_replace('\\\\n','\\n',addslashes($sig));
201  return $sig;
202}
203
204//Setup VIM: ex: et ts=4 enc=utf-8 :
205