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