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