[ Index ]
 

Code source de DokuWiki 2006-11-06

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/plugins/info/ -> syntax.php (source)

   1  <?php
   2  /**
   3   * Info Plugin: Displays information about various DokuWiki internals
   4   * 
   5   * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
   6   * @author     Andreas Gohr <andi@splitbrain.org>
   7   */
   8  // must be run within Dokuwiki
   9  if(!defined('DOKU_INC')) die();
  10  
  11  if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
  12  require_once (DOKU_PLUGIN.'syntax.php');
  13  
  14  /**
  15   * All DokuWiki plugins to extend the parser/rendering mechanism
  16   * need to inherit from this class
  17   */
  18  class syntax_plugin_info extends DokuWiki_Syntax_Plugin {
  19  
  20      /**
  21       * return some info
  22       */
  23      function getInfo(){
  24          return array(
  25              'author' => 'Andreas Gohr',
  26              'email'  => 'andi@splitbrain.org',
  27              'date'   => '2005-08-03',
  28              'name'   => 'Info Plugin',
  29              'desc'   => 'Displays information about various DokuWiki internals',
  30              'url'    => 'http://wiki.splitbrain.org/plugin:info',
  31          );
  32      }
  33  
  34      /**
  35       * What kind of syntax are we?
  36       */
  37      function getType(){
  38          return 'substition';
  39      }
  40     
  41      /**
  42       * What about paragraphs?
  43       */
  44      function getPType(){
  45          return 'block';
  46      }
  47  
  48      /**
  49       * Where to sort in?
  50       */ 
  51      function getSort(){
  52          return 155;
  53      }
  54  
  55  
  56      /**
  57       * Connect pattern to lexer
  58       */
  59      function connectTo($mode) {
  60          $this->Lexer->addSpecialPattern('~~INFO:\w+~~',$mode,'plugin_info');
  61      }
  62  
  63  
  64      /**
  65       * Handle the match
  66       */
  67      function handle($match, $state, $pos, &$handler){
  68          $match = substr($match,7,-2); //strip ~~INFO: from start and ~~ from end
  69          return array(strtolower($match));
  70      }
  71  
  72      /**
  73       * Create output
  74       */
  75      function render($format, &$renderer, $data) {
  76          if($format == 'xhtml'){
  77              //handle various info stuff
  78              switch ($data[0]){
  79                  case 'version':
  80                      $renderer->doc .= getVersion();
  81                      break;
  82                  case 'syntaxmodes':
  83                      $renderer->doc .= $this->_syntaxmodes_xhtml();
  84                      break;
  85                  case 'syntaxtypes':
  86                      $renderer->doc .= $this->_syntaxtypes_xhtml();
  87                      break;
  88                  case 'syntaxplugins':
  89                      $this->_syntaxplugins_xhtml($renderer);
  90                      break;
  91                  default:
  92                      $renderer->doc .= "no info about ".htmlspecialchars($data[0]);
  93              }
  94              return true;
  95          }
  96          return false;
  97      }
  98  
  99      /**
 100       * list all installed syntax plugins
 101       *
 102       * uses some of the original renderer methods
 103       */
 104      function _syntaxplugins_xhtml(& $renderer){
 105          global $lang;
 106          $renderer->doc .= '<ul>';
 107  
 108          $plugins = plugin_list('syntax');
 109          foreach($plugins as $p){
 110              if (!$po =& plugin_load('syntax',$p)) continue;
 111              $info = $po->getInfo();
 112  
 113              $renderer->doc .= '<li><div class="li">';
 114              $renderer->externallink($info['url'],$info['name']);
 115              $renderer->doc .= ' ';
 116              $renderer->doc .= '<em>'.$info['date'].'</em>';
 117              $renderer->doc .= ' ';
 118              $renderer->doc .= $lang['by'];
 119              $renderer->doc .= ' ';
 120              $renderer->emaillink($info['email'],$info['author']);
 121              $renderer->doc .= '<br />';
 122              $renderer->doc .= strtr(htmlspecialchars($info['desc']),array("\n"=>"<br />"));
 123              $renderer->doc .= '</div></li>';
 124              unset($po);
 125          }
 126  
 127          $renderer->doc .= '</ul>';
 128      }
 129  
 130      /**
 131       * lists all known syntax types and their registered modes
 132       */
 133      function _syntaxtypes_xhtml(){
 134          global $PARSER_MODES;
 135          $doc  = '';
 136  
 137          $doc .= '<table class="inline"><tbody>';
 138          foreach($PARSER_MODES as $mode => $modes){
 139              $doc .= '<tr>';
 140              $doc .= '<td class="leftalign">';
 141              $doc .= $mode;
 142              $doc .= '</td>';
 143              $doc .= '<td class="leftalign">';
 144              $doc .= join(', ',$modes);
 145              $doc .= '</td>';
 146              $doc .= '</tr>';
 147          }
 148          $doc .= '</tbody></table>';
 149          return $doc;
 150      }
 151  
 152      /**
 153       * lists all known syntax modes and their sorting value
 154       */
 155      function _syntaxmodes_xhtml(){
 156          $modes = p_get_parsermodes();
 157          $doc  = '';
 158  
 159          foreach ($modes as $mode){
 160              $doc .= $mode['mode'].' ('.$mode['sort'].'), ';
 161          }
 162          return $doc;
 163      }
 164  }
 165  
 166  //Setup VIM: ex: et ts=4 enc=utf-8 :


Généré le : Tue Apr 3 20:47:31 2007 par Balluche grâce à PHPXref 0.7