1<?php 2/** 3 * DokuWiki Plugin struct (Syntax Component) 4 * 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author Andreas Gohr, Michael Große <dokuwiki@cosmocode.de> 7 */ 8 9// must be run within Dokuwiki 10use plugin\struct\meta\Search; 11use plugin\struct\meta\SearchException; 12 13if (!defined('DOKU_INC')) die(); 14 15class syntax_plugin_struct_table extends DokuWiki_Syntax_Plugin { 16 /** 17 * @return string Syntax mode type 18 */ 19 public function getType() { 20 return 'substition'; 21 } 22 /** 23 * @return string Paragraph type 24 */ 25 public function getPType() { 26 return 'block'; 27 } 28 /** 29 * @return int Sort order - Low numbers go before high numbers 30 */ 31 public function getSort() { 32 return 500; 33 } 34 35 /** 36 * Connect lookup pattern to lexer. 37 * 38 * @param string $mode Parser mode 39 */ 40 public function connectTo($mode) { 41 $this->Lexer->addSpecialPattern('STRUCT',$mode,'plugin_struct_table'); 42 } 43 44 45 /** 46 * Handle matches of the struct syntax 47 * 48 * @param string $match The match of the syntax 49 * @param int $state The state of the handler 50 * @param int $pos The position in the document 51 * @param Doku_Handler $handler The handler 52 * @return array Data for the renderer 53 */ 54 public function handle($match, $state, $pos, Doku_Handler $handler){ 55 $data = array(); 56 57 return $data; 58 } 59 60 /** 61 * Render xhtml output or metadata 62 * 63 * @param string $mode Renderer mode (supported modes: xhtml) 64 * @param Doku_Renderer $renderer The renderer 65 * @param array $data The data from the handler() function 66 * @return bool If rendering was successful. 67 */ 68 public function render($mode, Doku_Renderer $renderer, $data) { 69 if($mode != 'xhtml') return false; 70 71 try { 72 $search = new Search(); 73 $search->addSchema('foo'); 74 $search->addSchema('try1'); 75 $search->addColumn('try1.first'); 76 $sql = $search->getSQL(); 77 78 $renderer->doc = $sql; 79 } catch (SearchException $e) { 80 msg($e->getMessage(), -1, $e->getLine(), $e->getFile()); 81 } 82 83 84 85 86 87 return true; 88 } 89} 90 91// vim:ts=4:sw=4:et: 92