1<?php 2 3// must be run within DokuWiki 4if(!defined('DOKU_INC')) die(); 5 6if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 7require_once DOKU_PLUGIN.'syntax.php'; 8/** 9 * All DokuWiki plugins to extend the parser/rendering mechanism 10 * need to inherit from this class 11 */ 12class syntax_plugin_bez_query extends DokuWiki_Syntax_Plugin { 13 14 public function getType() { return 'container'; } 15 public function getAllowedTypes() { 16 return array('container', 'formatting', 'substition', 'disabled'); 17 } 18 public function connectTo($mode) { 19 $this->Lexer->addEntryPattern('<bez-query.*?>(?=.*?</bez-query>)',$mode,'plugin_bez_query'); 20 } 21 public function postConnect() { 22 $this->Lexer->addExitPattern('</bez-query>','plugin_bez_query'); 23 } 24 public function getSort() { return 34; } 25 26 27 public function handle($match, $state, $pos, Doku_Handler $handler){ 28 switch ($state) { 29 case DOKU_LEXER_ENTER : 30 return array($state, $match); 31 32 case DOKU_LEXER_UNMATCHED : return array($state, $match); 33 case DOKU_LEXER_EXIT : return array($state, ''); 34 } 35 return array(); 36 } 37 38 public function render($mode, Doku_Renderer $renderer, $data) { 39 // $data is what the function handle() return'ed. 40 if($mode == 'xhtml'){ 41 /** @var Doku_Renderer_xhtml $renderer */ 42 list($state,$match) = $data; 43 switch ($state) { 44 case DOKU_LEXER_ENTER : 45 46 $renderer->doc .= "QUERY: ".htmlspecialchars($match).""; 47 $renderer->doc .= "<pre>"; 48 break; 49 50 case DOKU_LEXER_UNMATCHED : 51 $renderer->doc .= $renderer->_xmlEntities($match); 52 break; 53 case DOKU_LEXER_EXIT : 54 $renderer->doc .= "</pre>"; 55 break; 56 } 57 return true; 58 } 59 return false; 60 } 61} 62