[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/ -> toolbar.php (source)

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