xref: /dokuwiki/inc/toolbar.php (revision 56dfcc12d4d4b326fc393a8271da0cf8374d3a11)
120d062caSAndreas Gohr<?php
220d062caSAndreas Gohr/**
320d062caSAndreas Gohr * Editing toolbar functions
420d062caSAndreas Gohr *
520d062caSAndreas Gohr * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
620d062caSAndreas Gohr * @author     Andreas Gohr <andi@splitbrain.org>
720d062caSAndreas Gohr */
820d062caSAndreas Gohr
9fa8adffeSAndreas Gohrif(!defined('DOKU_INC')) die('meh.');
1020d062caSAndreas Gohrrequire_once(DOKU_INC.'inc/JSON.php');
1120d062caSAndreas Gohr
1220d062caSAndreas Gohr
1320d062caSAndreas Gohr/**
1420d062caSAndreas Gohr * Prepares and prints an JavaScript array with all toolbar buttons
1520d062caSAndreas Gohr *
1620d062caSAndreas Gohr * @todo add toolbar plugins
1720d062caSAndreas Gohr * @param  string $varname Name of the JS variable to fill
1820d062caSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
1920d062caSAndreas Gohr */
2020d062caSAndreas Gohrfunction toolbar_JSdefines($varname){
2120d062caSAndreas Gohr    global $ID;
2220d062caSAndreas Gohr    global $conf;
2320d062caSAndreas Gohr    global $lang;
2420d062caSAndreas Gohr
258b3b5ebbSEsther Brunner    $menu = array();
268b3b5ebbSEsther Brunner
278b3b5ebbSEsther Brunner    $evt = new Doku_Event('TOOLBAR_DEFINE', $menu);
288b3b5ebbSEsther Brunner    if ($evt->advise_before()){
298b3b5ebbSEsther Brunner
3020d062caSAndreas Gohr        // build button array
318b3b5ebbSEsther Brunner        $menu = array_merge($menu, array(
3220d062caSAndreas Gohr           array(
3320d062caSAndreas Gohr                'type'   => 'format',
3420d062caSAndreas Gohr                'title'  => $lang['qb_bold'],
3520d062caSAndreas Gohr                'icon'   => 'bold.png',
3620d062caSAndreas Gohr                'key'    => 'b',
3720d062caSAndreas Gohr                'open'   => '**',
3820d062caSAndreas Gohr                'close'  => '**',
3920d062caSAndreas Gohr                ),
4020d062caSAndreas Gohr           array(
4120d062caSAndreas Gohr                'type'   => 'format',
4220d062caSAndreas Gohr                'title'  => $lang['qb_italic'],
4320d062caSAndreas Gohr                'icon'   => 'italic.png',
4420d062caSAndreas Gohr                'key'    => 'i',
4520d062caSAndreas Gohr                'open'   => '//',
4620d062caSAndreas Gohr                'close'  => '//',
4720d062caSAndreas Gohr                ),
4820d062caSAndreas Gohr           array(
4920d062caSAndreas Gohr                'type'   => 'format',
5020d062caSAndreas Gohr                'title'  => $lang['qb_underl'],
5120d062caSAndreas Gohr                'icon'   => 'underline.png',
5220d062caSAndreas Gohr                'key'    => 'u',
5320d062caSAndreas Gohr                'open'   => '__',
5420d062caSAndreas Gohr                'close'  => '__',
5520d062caSAndreas Gohr                ),
5620d062caSAndreas Gohr           array(
5720d062caSAndreas Gohr                'type'   => 'format',
5820d062caSAndreas Gohr                'title'  => $lang['qb_code'],
5920d062caSAndreas Gohr                'icon'   => 'mono.png',
6020d062caSAndreas Gohr                'key'    => 'c',
6120d062caSAndreas Gohr                'open'   => "''",
6220d062caSAndreas Gohr                'close'  => "''",
6320d062caSAndreas Gohr                ),
6420d062caSAndreas Gohr           array(
6520d062caSAndreas Gohr                'type'   => 'format',
6620d062caSAndreas Gohr                'title'  => $lang['qb_strike'],
6720d062caSAndreas Gohr                'icon'   => 'strike.png',
6820d062caSAndreas Gohr                'key'    => 'd',
6920d062caSAndreas Gohr                'open'  => '<del>',
70b0bf105aSAndreas Gohr                'close'   => '</del>',
7120d062caSAndreas Gohr                ),
72a2be6cd9SAndreas Gohr
73a2be6cd9SAndreas Gohr
74a2be6cd9SAndreas Gohr           array(
75a2be6cd9SAndreas Gohr                'type'   => 'autohead',
76a2be6cd9SAndreas Gohr                'title'  => $lang['qb_hplus'],
77a2be6cd9SAndreas Gohr                'icon'   => 'hplus.png',
78a2be6cd9SAndreas Gohr                'key'    => '',
79a2be6cd9SAndreas Gohr                'text'   => $lang['qb_h'],
80a2be6cd9SAndreas Gohr                'mod'    => -1
81a2be6cd9SAndreas Gohr               ),
82a2be6cd9SAndreas Gohr           array(
83a2be6cd9SAndreas Gohr                'type'   => 'autohead',
84a2be6cd9SAndreas Gohr                'title'  => $lang['qb_hequal'],
85a2be6cd9SAndreas Gohr                'icon'   => 'hequal.png',
86a2be6cd9SAndreas Gohr                'key'    => '',
87a2be6cd9SAndreas Gohr                'text'   => $lang['qb_h'],
88a2be6cd9SAndreas Gohr                'mod'    => 0
89a2be6cd9SAndreas Gohr               ),
90a2be6cd9SAndreas Gohr           array(
91a2be6cd9SAndreas Gohr                'type'   => 'autohead',
92a2be6cd9SAndreas Gohr                'title'  => $lang['qb_hminus'],
93a2be6cd9SAndreas Gohr                'icon'   => 'hminus.png',
94a2be6cd9SAndreas Gohr                'key'    => '',
95a2be6cd9SAndreas Gohr                'text'   => $lang['qb_h'],
96a2be6cd9SAndreas Gohr                'mod'    => 1
97a2be6cd9SAndreas Gohr               ),
98a2be6cd9SAndreas Gohr
99a2be6cd9SAndreas Gohr           array(
100a2be6cd9SAndreas Gohr                'type'   => 'picker',
101a2be6cd9SAndreas Gohr                'title'  => $lang['qb_hs'],
102a2be6cd9SAndreas Gohr                'icon'   => 'h.png',
103a2be6cd9SAndreas Gohr                'list'   => array(
10420d062caSAndreas Gohr                               array(
10520d062caSAndreas Gohr                                    'type'   => 'format',
10620d062caSAndreas Gohr                                    'title'  => $lang['qb_h1'],
10720d062caSAndreas Gohr                                    'icon'   => 'h1.png',
10820d062caSAndreas Gohr                                    'key'    => '1',
10920d062caSAndreas Gohr                                    'open'   => '====== ',
11020d062caSAndreas Gohr                                    'close'  => ' ======\n',
11120d062caSAndreas Gohr                                    ),
11220d062caSAndreas Gohr                               array(
11320d062caSAndreas Gohr                                    'type'   => 'format',
11420d062caSAndreas Gohr                                    'title'  => $lang['qb_h2'],
11520d062caSAndreas Gohr                                    'icon'   => 'h2.png',
11620d062caSAndreas Gohr                                    'key'    => '2',
11720d062caSAndreas Gohr                                    'open'   => '===== ',
11820d062caSAndreas Gohr                                    'close'  => ' =====\n',
11920d062caSAndreas Gohr                                    ),
12020d062caSAndreas Gohr                               array(
12120d062caSAndreas Gohr                                    'type'   => 'format',
12220d062caSAndreas Gohr                                    'title'  => $lang['qb_h3'],
12320d062caSAndreas Gohr                                    'icon'   => 'h3.png',
12420d062caSAndreas Gohr                                    'key'    => '3',
12520d062caSAndreas Gohr                                    'open'   => '==== ',
12620d062caSAndreas Gohr                                    'close'  => ' ====\n',
12720d062caSAndreas Gohr                                    ),
12820d062caSAndreas Gohr                               array(
12920d062caSAndreas Gohr                                    'type'   => 'format',
13020d062caSAndreas Gohr                                    'title'  => $lang['qb_h4'],
13120d062caSAndreas Gohr                                    'icon'   => 'h4.png',
13220d062caSAndreas Gohr                                    'key'    => '4',
13320d062caSAndreas Gohr                                    'open'   => '=== ',
13420d062caSAndreas Gohr                                    'close'  => ' ===\n',
13520d062caSAndreas Gohr                                    ),
13620d062caSAndreas Gohr                               array(
13720d062caSAndreas Gohr                                    'type'   => 'format',
13820d062caSAndreas Gohr                                    'title'  => $lang['qb_h5'],
13920d062caSAndreas Gohr                                    'icon'   => 'h5.png',
14020d062caSAndreas Gohr                                    'key'    => '5',
14120d062caSAndreas Gohr                                    'open'   => '== ',
14220d062caSAndreas Gohr                                    'close'  => ' ==\n',
14320d062caSAndreas Gohr                                    ),
144a2be6cd9SAndreas Gohr                            )
145a2be6cd9SAndreas Gohr                ),
146a2be6cd9SAndreas Gohr
14720d062caSAndreas Gohr           array(
148*56dfcc12SAndreas Gohr                'type'   => 'linkwiz',
14920d062caSAndreas Gohr                'title'  => $lang['qb_link'],
15020d062caSAndreas Gohr                'icon'   => 'link.png',
15120d062caSAndreas Gohr                'key'    => 'l',
15220d062caSAndreas Gohr                'open'   => '[[',
15320d062caSAndreas Gohr                'close'  => ']]',
15420d062caSAndreas Gohr                ),
15520d062caSAndreas Gohr           array(
15620d062caSAndreas Gohr                'type'   => 'format',
157*56dfcc12SAndreas Gohr                'title'  => $lang['qb_link'],
158*56dfcc12SAndreas Gohr                'icon'   => 'link.png',
159*56dfcc12SAndreas Gohr                'key'    => '',
160*56dfcc12SAndreas Gohr                'open'   => '[[',
161*56dfcc12SAndreas Gohr                'close'  => ']]',
162*56dfcc12SAndreas Gohr                ),
163*56dfcc12SAndreas Gohr           array(
164*56dfcc12SAndreas Gohr                'type'   => 'format',
16520d062caSAndreas Gohr                'title'  => $lang['qb_extlink'],
16620d062caSAndreas Gohr                'icon'   => 'linkextern.png',
16720d062caSAndreas Gohr                'open'   => '[[',
16820d062caSAndreas Gohr                'close'  => ']]',
16920d062caSAndreas Gohr                'sample' => 'http://example.com|'.$lang['qb_extlink'],
17020d062caSAndreas Gohr                ),
17120d062caSAndreas Gohr           array(
172201ea5f3SAndreas Gohr                'type'   => 'formatln',
17320d062caSAndreas Gohr                'title'  => $lang['qb_ol'],
17420d062caSAndreas Gohr                'icon'   => 'ol.png',
17520d062caSAndreas Gohr                'open'   => '  - ',
176201ea5f3SAndreas Gohr                'close'  => '',
177a4b53097SAndreas Gohr                'key'    => '-',
17820d062caSAndreas Gohr                ),
17920d062caSAndreas Gohr           array(
180201ea5f3SAndreas Gohr                'type'   => 'formatln',
18120d062caSAndreas Gohr                'title'  => $lang['qb_ul'],
18220d062caSAndreas Gohr                'icon'   => 'ul.png',
18320d062caSAndreas Gohr                'open'   => '  * ',
184201ea5f3SAndreas Gohr                'close'  => '',
185a4b53097SAndreas Gohr                'key'    => '.',
18620d062caSAndreas Gohr                ),
18720d062caSAndreas Gohr           array(
18820d062caSAndreas Gohr                'type'   => 'insert',
18920d062caSAndreas Gohr                'title'  => $lang['qb_hr'],
19020d062caSAndreas Gohr                'icon'   => 'hr.png',
191d27d0a5aSGina Haeussge                'insert' => '\n----\n',
19220d062caSAndreas Gohr                ),
19320d062caSAndreas Gohr           array(
194c591aabeSAndreas Gohr                'type'   => 'mediapopup',
19520d062caSAndreas Gohr                'title'  => $lang['qb_media'],
19620d062caSAndreas Gohr                'icon'   => 'image.png',
197de4e429dSAndreas Gohr                'url'    => 'lib/exe/mediamanager.php?ns=',
19820d062caSAndreas Gohr                'name'   => 'mediaselect',
1993df72098SAndreas Gohr                'options'=> 'width=750,height=500,left=20,top=20,scrollbars=yes,resizable=yes',
20020d062caSAndreas Gohr                ),
20120d062caSAndreas Gohr          array(
20220d062caSAndreas Gohr                'type'   => 'picker',
20320d062caSAndreas Gohr                'title'  => $lang['qb_smileys'],
20420d062caSAndreas Gohr                'icon'   => 'smiley.png',
20520d062caSAndreas Gohr                'list'   => getSmileys(),
20620d062caSAndreas Gohr                'icobase'=> 'smileys',
20720d062caSAndreas Gohr               ),
20820d062caSAndreas Gohr          array(
20920d062caSAndreas Gohr                'type'   => 'picker',
21020d062caSAndreas Gohr                'title'  => $lang['qb_chars'],
21120d062caSAndreas Gohr                'icon'   => 'chars.png',
21203c89b24SAndreas Gohr                'list'   => explode(' ','À à Á á  â à ã Ä ä Ǎ ǎ Ă ă Å å Ā ā Ą ą Æ æ Ć ć Ç ç Č č Ĉ ĉ Ċ ċ Ð đ ð Ď ď È è É é Ê ê Ë ë Ě ě Ē ē Ė ė Ę ę Ģ ģ Ĝ ĝ Ğ ğ Ġ ġ Ĥ ĥ Ì ì Í í Î î Ï ï Ǐ ǐ Ī ī İ ı Į į Ĵ ĵ Ķ ķ Ĺ ĺ Ļ ļ Ľ ľ Ł ł Ŀ ŀ Ń ń Ñ ñ Ņ ņ Ň ň Ò ò Ó ó Ô ô Õ õ Ö ö Ǒ ǒ Ō ō Ő ő Œ œ Ø ø Ŕ ŕ Ŗ ŗ Ř ř Ś ś Ş ş Š š Ŝ ŝ Ţ ţ Ť ť Ù ù Ú ú Û û Ü ü Ǔ ǔ Ŭ ŭ Ū ū Ů ů ǖ ǘ ǚ ǜ Ų ų Ű ű Ŵ ŵ Ý ý Ÿ ÿ Ŷ ŷ Ź ź Ž ž Ż ż Þ þ ß Ħ ħ ¿ ¡ ¢ £ ¤ ¥ € ¦ § ª ¬ ¯ ° ± ÷ ‰ ¼ ½ ¾ ¹ ² ³ µ ¶ † ‡ · • º ∀ ∂ ∃ Ə ə ∅ ∇ ∈ ∉ ∋ ∏ ∑ ‾ − ∗ √ ∝ ∞ ∠ ∧ ∨ ∩ ∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤ ≥ ⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ◊ ℘ ℑ ℜ ℵ ♠ ♣ ♥ ♦ α β Γ γ Δ δ ε ζ η Θ θ ι κ Λ λ μ Ξ ξ Π π ρ Σ σ Τ τ υ Φ φ χ Ψ ψ Ω ω ★ ☆ ☎ ☚ ☛ ☜ ☝ ☞ ☟ ☹ ☺ ✔ ✘ × „ “ ” ‚ ‘ ’ « » ‹ › — – … ← ↑ → ↓ ↔ ⇐ ⇑ ⇒ ⇓ ⇔ © ™ ® ′ ″ [ ] { } ~ ( ) % § $ # | @'),
21320d062caSAndreas Gohr               ),
214c591aabeSAndreas Gohr          array(
215c591aabeSAndreas Gohr                'type'   => 'signature',
216c591aabeSAndreas Gohr                'title'  => $lang['qb_sig'],
217c591aabeSAndreas Gohr                'icon'   => 'sig.png',
218c591aabeSAndreas Gohr                'key'    => 'y',
219c591aabeSAndreas Gohr               ),
2206b6da7f5SAndreas Gohr
2216b6da7f5SAndreas Gohr
2226b6da7f5SAndreas Gohr
2238b3b5ebbSEsther Brunner        ));
2248b3b5ebbSEsther Brunner    } // end event TOOLBAR_DEFINE default action
2258b3b5ebbSEsther Brunner    $evt->advise_after();
2268b3b5ebbSEsther Brunner    unset($evt);
22720d062caSAndreas Gohr
22820d062caSAndreas Gohr    // use JSON to build the JavaScript array
22920d062caSAndreas Gohr    $json = new JSON();
23020d062caSAndreas Gohr    print "var $varname = ".$json->encode($menu).";\n";
23120d062caSAndreas Gohr}
23220d062caSAndreas Gohr
23320d062caSAndreas Gohr/**
23420d062caSAndreas Gohr * prepares the signature string as configured in the config
23520d062caSAndreas Gohr *
23620d062caSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
23720d062caSAndreas Gohr */
23820d062caSAndreas Gohrfunction toolbar_signature(){
23920d062caSAndreas Gohr  global $conf;
2401b2abcf9SAndreas Gohr  global $INFO;
24120d062caSAndreas Gohr
24220d062caSAndreas Gohr  $sig = $conf['signature'];
24320d062caSAndreas Gohr  $sig = strftime($sig);
24420d062caSAndreas Gohr  $sig = str_replace('@USER@',$_SERVER['REMOTE_USER'],$sig);
2451b2abcf9SAndreas Gohr  $sig = str_replace('@NAME@',$INFO['userinfo']['name'],$sig);
2461b2abcf9SAndreas Gohr  $sig = str_replace('@MAIL@',$INFO['userinfo']['mail'],$sig);
247e656dcd4SAndreas Gohr  $sig = str_replace('@DATE@',strftime($conf['dformat']),$sig);
248c591aabeSAndreas Gohr  $sig = str_replace('\\\\n','\\n',addslashes($sig));
24920d062caSAndreas Gohr  return $sig;
25020d062caSAndreas Gohr}
25120d062caSAndreas Gohr
25220d062caSAndreas Gohr//Setup VIM: ex: et ts=4 enc=utf-8 :
253