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