xref: /dokuwiki/inc/toolbar.php (revision 1b2abcf93c01d372fac2868ee6930c2326b7c914)
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
900976812SAndreas Gohr  if(!defined('DOKU_INC')) define('DOKU_INC',fullpath(dirname(__FILE__).'/../').'/');
1020d062caSAndreas Gohr
1120d062caSAndreas Gohrrequire_once(DOKU_INC.'inc/JSON.php');
1220d062caSAndreas Gohr
1320d062caSAndreas Gohr
1420d062caSAndreas Gohr/**
1520d062caSAndreas Gohr * Prepares and prints an JavaScript array with all toolbar buttons
1620d062caSAndreas Gohr *
1720d062caSAndreas Gohr * @todo add toolbar plugins
1820d062caSAndreas Gohr * @param  string $varname Name of the JS variable to fill
1920d062caSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
2020d062caSAndreas Gohr */
2120d062caSAndreas Gohrfunction toolbar_JSdefines($varname){
2220d062caSAndreas Gohr    global $ID;
2320d062caSAndreas Gohr    global $conf;
2420d062caSAndreas Gohr    global $lang;
2520d062caSAndreas Gohr
268b3b5ebbSEsther Brunner    $menu = array();
278b3b5ebbSEsther Brunner
288b3b5ebbSEsther Brunner    $evt = new Doku_Event('TOOLBAR_DEFINE', $menu);
298b3b5ebbSEsther Brunner    if ($evt->advise_before()){
308b3b5ebbSEsther Brunner
3120d062caSAndreas Gohr        // build button array
328b3b5ebbSEsther Brunner        $menu = array_merge($menu, array(
3320d062caSAndreas Gohr           array(
3420d062caSAndreas Gohr                'type'   => 'format',
3520d062caSAndreas Gohr                'title'  => $lang['qb_bold'],
3620d062caSAndreas Gohr                'icon'   => 'bold.png',
3720d062caSAndreas Gohr                'key'    => 'b',
3820d062caSAndreas Gohr                'open'   => '**',
3920d062caSAndreas Gohr                'close'  => '**',
4020d062caSAndreas Gohr                ),
4120d062caSAndreas Gohr           array(
4220d062caSAndreas Gohr                'type'   => 'format',
4320d062caSAndreas Gohr                'title'  => $lang['qb_italic'],
4420d062caSAndreas Gohr                'icon'   => 'italic.png',
4520d062caSAndreas Gohr                'key'    => 'i',
4620d062caSAndreas Gohr                'open'   => '//',
4720d062caSAndreas Gohr                'close'  => '//',
4820d062caSAndreas Gohr                ),
4920d062caSAndreas Gohr           array(
5020d062caSAndreas Gohr                'type'   => 'format',
5120d062caSAndreas Gohr                'title'  => $lang['qb_underl'],
5220d062caSAndreas Gohr                'icon'   => 'underline.png',
5320d062caSAndreas Gohr                'key'    => 'u',
5420d062caSAndreas Gohr                'open'   => '__',
5520d062caSAndreas Gohr                'close'  => '__',
5620d062caSAndreas Gohr                ),
5720d062caSAndreas Gohr           array(
5820d062caSAndreas Gohr                'type'   => 'format',
5920d062caSAndreas Gohr                'title'  => $lang['qb_code'],
6020d062caSAndreas Gohr                'icon'   => 'mono.png',
6120d062caSAndreas Gohr                'key'    => 'c',
6220d062caSAndreas Gohr                'open'   => "''",
6320d062caSAndreas Gohr                'close'  => "''",
6420d062caSAndreas Gohr                ),
6520d062caSAndreas Gohr           array(
6620d062caSAndreas Gohr                'type'   => 'format',
6720d062caSAndreas Gohr                'title'  => $lang['qb_strike'],
6820d062caSAndreas Gohr                'icon'   => 'strike.png',
6920d062caSAndreas Gohr                'key'    => 'd',
7020d062caSAndreas Gohr                'open'  => '<del>',
71b0bf105aSAndreas Gohr                'close'   => '</del>',
7220d062caSAndreas Gohr                ),
7320d062caSAndreas Gohr           array(
7420d062caSAndreas Gohr                'type'   => 'format',
7520d062caSAndreas Gohr                'title'  => $lang['qb_h1'],
7620d062caSAndreas Gohr                'icon'   => 'h1.png',
7720d062caSAndreas Gohr                'key'    => '1',
7820d062caSAndreas Gohr                'open'   => '====== ',
7920d062caSAndreas Gohr                'close'  => ' ======\n',
8020d062caSAndreas Gohr                ),
8120d062caSAndreas Gohr           array(
8220d062caSAndreas Gohr                'type'   => 'format',
8320d062caSAndreas Gohr                'title'  => $lang['qb_h2'],
8420d062caSAndreas Gohr                'icon'   => 'h2.png',
8520d062caSAndreas Gohr                'key'    => '2',
8620d062caSAndreas Gohr                'open'   => '===== ',
8720d062caSAndreas Gohr                'close'  => ' =====\n',
8820d062caSAndreas Gohr                ),
8920d062caSAndreas Gohr           array(
9020d062caSAndreas Gohr                'type'   => 'format',
9120d062caSAndreas Gohr                'title'  => $lang['qb_h3'],
9220d062caSAndreas Gohr                'icon'   => 'h3.png',
9320d062caSAndreas Gohr                'key'    => '3',
9420d062caSAndreas Gohr                'open'   => '==== ',
9520d062caSAndreas Gohr                'close'  => ' ====\n',
9620d062caSAndreas Gohr                ),
9720d062caSAndreas Gohr           array(
9820d062caSAndreas Gohr                'type'   => 'format',
9920d062caSAndreas Gohr                'title'  => $lang['qb_h4'],
10020d062caSAndreas Gohr                'icon'   => 'h4.png',
10120d062caSAndreas Gohr                'key'    => '4',
10220d062caSAndreas Gohr                'open'   => '=== ',
10320d062caSAndreas Gohr                'close'  => ' ===\n',
10420d062caSAndreas Gohr                ),
10520d062caSAndreas Gohr           array(
10620d062caSAndreas Gohr                'type'   => 'format',
10720d062caSAndreas Gohr                'title'  => $lang['qb_h5'],
10820d062caSAndreas Gohr                'icon'   => 'h5.png',
10920d062caSAndreas Gohr                'key'    => '5',
11020d062caSAndreas Gohr                'open'   => '== ',
11120d062caSAndreas Gohr                'close'  => ' ==\n',
11220d062caSAndreas Gohr                ),
11320d062caSAndreas Gohr           array(
11420d062caSAndreas Gohr                'type'   => 'format',
11520d062caSAndreas Gohr                'title'  => $lang['qb_link'],
11620d062caSAndreas Gohr                'icon'   => 'link.png',
11720d062caSAndreas Gohr                'key'    => 'l',
11820d062caSAndreas Gohr                'open'   => '[[',
11920d062caSAndreas Gohr                'close'  => ']]',
12020d062caSAndreas Gohr                ),
12120d062caSAndreas Gohr           array(
12220d062caSAndreas Gohr                'type'   => 'format',
12320d062caSAndreas Gohr                'title'  => $lang['qb_extlink'],
12420d062caSAndreas Gohr                'icon'   => 'linkextern.png',
12520d062caSAndreas Gohr                'open'   => '[[',
12620d062caSAndreas Gohr                'close'  => ']]',
12720d062caSAndreas Gohr                'sample' => 'http://example.com|'.$lang['qb_extlink'],
12820d062caSAndreas Gohr                ),
12920d062caSAndreas Gohr           array(
13020d062caSAndreas Gohr                'type'   => 'format',
13120d062caSAndreas Gohr                'title'  => $lang['qb_ol'],
13220d062caSAndreas Gohr                'icon'   => 'ol.png',
13320d062caSAndreas Gohr                'open'   => '  - ',
13420d062caSAndreas Gohr                'close'  => '\n',
13520d062caSAndreas Gohr                ),
13620d062caSAndreas Gohr           array(
13720d062caSAndreas Gohr                'type'   => 'format',
13820d062caSAndreas Gohr                'title'  => $lang['qb_ul'],
13920d062caSAndreas Gohr                'icon'   => 'ul.png',
14020d062caSAndreas Gohr                'open'   => '  * ',
14120d062caSAndreas Gohr                'close'  => '\n',
14220d062caSAndreas Gohr                ),
14320d062caSAndreas Gohr           array(
14420d062caSAndreas Gohr                'type'   => 'insert',
14520d062caSAndreas Gohr                'title'  => $lang['qb_hr'],
14620d062caSAndreas Gohr                'icon'   => 'hr.png',
14720d062caSAndreas Gohr                'insert' => '----\n',
14820d062caSAndreas Gohr                ),
14920d062caSAndreas Gohr           array(
150c591aabeSAndreas Gohr                'type'   => 'mediapopup',
15120d062caSAndreas Gohr                'title'  => $lang['qb_media'],
15220d062caSAndreas Gohr                'icon'   => 'image.png',
1533df72098SAndreas Gohr                'url'    => DOKU_BASE.'lib/exe/mediamanager.php?ns=',
15420d062caSAndreas Gohr                'name'   => 'mediaselect',
1553df72098SAndreas Gohr                'options'=> 'width=750,height=500,left=20,top=20,scrollbars=yes,resizable=yes',
15620d062caSAndreas Gohr                ),
15720d062caSAndreas Gohr          array(
15820d062caSAndreas Gohr                'type'   => 'picker',
15920d062caSAndreas Gohr                'title'  => $lang['qb_smileys'],
16020d062caSAndreas Gohr                'icon'   => 'smiley.png',
16120d062caSAndreas Gohr                'list'   => getSmileys(),
16220d062caSAndreas Gohr                'icobase'=> 'smileys',
16320d062caSAndreas Gohr               ),
16420d062caSAndreas Gohr          array(
16520d062caSAndreas Gohr                'type'   => 'picker',
16620d062caSAndreas Gohr                'title'  => $lang['qb_chars'],
16720d062caSAndreas Gohr                'icon'   => 'chars.png',
168014b95e7SAnika Henke                'list'   => explode(' ','À à Á á  â à ã Ä ä Ǎ ǎ Ă ă Å å Ā ā Ą ą Æ æ Ć ć Ç ç Č č Ĉ ĉ Ċ ċ Ð đ ð Ď ď È è É é Ê ê Ë ë Ě ě Ē ē Ė ė Ę ę Ģ ģ Ĝ ĝ Ğ ğ Ġ ġ Ĥ ĥ Ì ì Í í Î î Ï ï Ǐ ǐ Ī ī İ ı Į į Ĵ ĵ Ķ ķ Ĺ ĺ Ļ ļ Ľ ľ Ł ł Ŀ ŀ Ń ń Ñ ñ Ņ ņ Ň ň Ò ò Ó ó Ô ô Õ õ Ö ö Ǒ ǒ Ō ō Ő ő Œ œ Ø ø Ŕ ŕ Ŗ ŗ Ř ř Ś ś Ş ş Š š Ŝ ŝ Ţ ţ Ť ť Ù ù Ú ú Û û Ü ü Ǔ ǔ Ŭ ŭ Ū ū Ů ů ǖ ǘ ǚ ǜ Ų ų Ű ű Ŵ ŵ Ý ý Ÿ ÿ Ŷ ŷ Ź ź Ž ž Ż ż Þ þ ß Ħ ħ ¿ ¡ ¢ £ ¤ ¥ € ¦ § ª ¬ ¯ ° ± ÷ ‰ ¼ ½ ¾ ¹ ² ³ µ ¶ † ‡ · • º ∀ ∂ ∃ Ə ə ∅ ∇ ∈ ∉ ∋ ∏ ∑ ‾ − ∗ √ ∝ ∞ ∠ ∧ ∨ ∩ ∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤ ≥ ⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ◊ ℘ ℑ ℜ ℵ ♠ ♣ ♥ ♦ α β Γ γ Δ δ ε ζ η Θ θ ι κ Λ λ μ Ξ ξ Π π ρ Σ σ Τ τ υ Φ φ χ Ψ ψ Ω ω ★ ☆ ☎ ☚ ☛ ☜ ☝ ☞ ☟ ☹ ☺ ✔ ✘ × „ “ ” ‚ ‘ ’ « » ‹ › — – … ← ↑ → ↓ ↔ ⇐ ⇑ ⇒ ⇓ ⇔ © ™ ® ′ ″'),
16920d062caSAndreas Gohr               ),
170c591aabeSAndreas Gohr          array(
171c591aabeSAndreas Gohr                'type'   => 'signature',
172c591aabeSAndreas Gohr                'title'  => $lang['qb_sig'],
173c591aabeSAndreas Gohr                'icon'   => 'sig.png',
174c591aabeSAndreas Gohr                'key'    => 'y',
175c591aabeSAndreas Gohr               ),
1768b3b5ebbSEsther Brunner        ));
1778b3b5ebbSEsther Brunner    } // end event TOOLBAR_DEFINE default action
1788b3b5ebbSEsther Brunner    $evt->advise_after();
1798b3b5ebbSEsther Brunner    unset($evt);
18020d062caSAndreas Gohr
18120d062caSAndreas Gohr    // use JSON to build the JavaScript array
18220d062caSAndreas Gohr    $json = new JSON();
18320d062caSAndreas Gohr    print "var $varname = ".$json->encode($menu).";\n";
18420d062caSAndreas Gohr}
18520d062caSAndreas Gohr
18620d062caSAndreas Gohr/**
18720d062caSAndreas Gohr * prepares the signature string as configured in the config
18820d062caSAndreas Gohr *
18920d062caSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
19020d062caSAndreas Gohr */
19120d062caSAndreas Gohrfunction toolbar_signature(){
19220d062caSAndreas Gohr  global $conf;
193*1b2abcf9SAndreas Gohr  global $INFO;
19420d062caSAndreas Gohr
19520d062caSAndreas Gohr  $sig = $conf['signature'];
19620d062caSAndreas Gohr  $sig = strftime($sig);
19720d062caSAndreas Gohr  $sig = str_replace('@USER@',$_SERVER['REMOTE_USER'],$sig);
198*1b2abcf9SAndreas Gohr  $sig = str_replace('@NAME@',$INFO['userinfo']['name'],$sig);
199*1b2abcf9SAndreas Gohr  $sig = str_replace('@MAIL@',$INFO['userinfo']['mail'],$sig);
20020d062caSAndreas Gohr  $sig = str_replace('@DATE@',date($conf['dformat']),$sig);
201c591aabeSAndreas Gohr  $sig = str_replace('\\\\n','\\n',addslashes($sig));
20220d062caSAndreas Gohr  return $sig;
20320d062caSAndreas Gohr}
20420d062caSAndreas Gohr
20520d062caSAndreas Gohr//Setup VIM: ex: et ts=4 enc=utf-8 :
206