Advertisement
Guest User

Untitled

a guest
Jun 24th, 2013
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.87 KB | None | 0 0
  1. <?php
  2.     /**
  3.      * Plugin referencetable: Does nothing because im PHP newbie.
  4.      * Thanks to turnermm for help.
  5.      *
  6.      * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
  7.      */
  8.      
  9.     // must be run within DokuWiki
  10.     if(!defined('DOKU_INC')) die();
  11.      
  12.     if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
  13.     require_once DOKU_PLUGIN.'syntax.php';
  14.      
  15.     /**
  16.      * All DokuWiki plugins to extend the parser/rendering mechanism
  17.      * need to inherit from this class
  18.      */
  19.     class syntax_plugin_refs extends DokuWiki_Syntax_Plugin {
  20.      
  21.         function getInfo() {
  22.             return array('author' => 'midas',
  23.                          'email'  => 'fullmetaljacket02@gmail.com',
  24.                          'date'   => '2013-06-23',
  25.                          'name'   => 'Referencetable Plugin',
  26.                          'desc'   => 'Just simplify life.');
  27.         }
  28.      
  29.         function getType() { return 'container'; }
  30.         function getSort() { return 999; }
  31.      
  32.         function connectTo($mode) {
  33.             $this->Lexer->addEntryPattern('<page>',$mode,'plugin_refs');
  34.             $this->Lexer->addPattern('<name></name>', $mode, 'plugin_refs');
  35.         }
  36.        
  37.         function postConnect() {
  38.             $this->Lexer->addExitPattern('</page>','plugin_refs');
  39.         }
  40.      
  41.         function handle($match, $state, $pos, &$handler){
  42.             switch ($state) {
  43.               case DOKU_LEXER_ENTER :
  44.                     return array($state, $match);
  45.            
  46.               case DOKU_LEXER_MATCHED:
  47.                     preg_match('#<(\w+)>(.*?)<\/\1>#ms', $match, $matches);
  48.                     return array($state, array($matches[1],$matches[2]));
  49.                    
  50.               case DOKU_LEXER_UNMATCHED :  
  51.                     return array($state, $match);
  52.                    
  53.               case DOKU_LEXER_EXIT :      
  54.                     return array($state, '');
  55.             }
  56.             return array();
  57.         }
  58.      
  59.         function render($mode, &$renderer, $data) {
  60.         // $data is what the function handle return'ed.
  61.             if($mode == 'xhtml'){  
  62.                 list($state,$match) = $data;
  63.                 switch ($state) {
  64.                     case DOKU_LEXER_ENTER:      
  65.                         $renderer->doc .= '<div style="border:2px solid #1f63b6;-webkit-border-top-left-radius: 9px;-webkit-border-bottom-right-radius: 9px;-moz-border-radius-topleft: 9px;-moz-border-radius-bottomright: 9px;border-top-left-radius: 9px;border-bottom-right-radius: 9px;overflow:hidden">';
  66.                         break;
  67.                        
  68.                     case DOKU_LEXER_MATCHED:
  69.                         // $type will be one of the tags: return,syntax, etc;
  70.                         // $content will be the content between the tags
  71.                         $renderer->doc .= $content;
  72.                         //  $renderer->doc .= $renderer->_xmlEntities($content);  
  73.                        
  74.                         break;
  75.                        
  76.                     case DOKU_LEXER_UNMATCHED :  
  77.                         $renderer->doc .= $renderer->_xmlEntities($match);
  78.                         break;
  79.                        
  80.                     case DOKU_LEXER_EXIT :      
  81.                         $renderer->doc .= "</div>";
  82.                         break;
  83.                 }
  84.                
  85.             return false;
  86.             }
  87.         }
  88.     }
  89. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement