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