1*f62ea8a1Sandi<?php 2*f62ea8a1Sandi/** 3*f62ea8a1Sandi * Syntax Plugin Prototype 4*f62ea8a1Sandi * 5*f62ea8a1Sandi * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6*f62ea8a1Sandi * @author Andreas Gohr <andi@splitbrain.org> 7*f62ea8a1Sandi */ 8*f62ea8a1Sandi 9*f62ea8a1Sandiif(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/'); 10*f62ea8a1Sandiif(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 11*f62ea8a1Sandirequire_once(DOKU_INC.'inc/parser/parser.php'); 12*f62ea8a1Sandi 13*f62ea8a1Sandi/** 14*f62ea8a1Sandi * All DokuWiki plugins to extend the parser/rendering mechanism 15*f62ea8a1Sandi * need to inherit from this class 16*f62ea8a1Sandi */ 17*f62ea8a1Sandiclass DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { 18*f62ea8a1Sandi 19*f62ea8a1Sandi /** 20*f62ea8a1Sandi * Needs to return one of the mode types defined in $PARSER_MODES in parser.php 21*f62ea8a1Sandi */ 22*f62ea8a1Sandi function getType(){ 23*f62ea8a1Sandi trigger_error('getType() not implemented in '.get_class($this), E_USER_WARNING); 24*f62ea8a1Sandi } 25*f62ea8a1Sandi 26*f62ea8a1Sandi /** 27*f62ea8a1Sandi * Handler to prepare matched data for the rendering process 28*f62ea8a1Sandi * 29*f62ea8a1Sandi * Usually you should only need the $match param. 30*f62ea8a1Sandi * 31*f62ea8a1Sandi * @param $match string The text matched by the patterns 32*f62ea8a1Sandi * @param $state int The lexer state for the match 33*f62ea8a1Sandi * @param $pos int The character position of the matched text 34*f62ea8a1Sandi * @param $handler ref Reference to the Doku_Handler object 35*f62ea8a1Sandi * @return array Return an array with all data you want to use in render 36*f62ea8a1Sandi */ 37*f62ea8a1Sandi function handle($match, $state, $pos, &$handler){ 38*f62ea8a1Sandi trigger_error('handle() not implemented in '.get_class($this), E_USER_WARNING); 39*f62ea8a1Sandi } 40*f62ea8a1Sandi 41*f62ea8a1Sandi /** 42*f62ea8a1Sandi * Handles the actual output creation. 43*f62ea8a1Sandi * 44*f62ea8a1Sandi * The function should always check for the given mode and return false 45*f62ea8a1Sandi * when a mode isn't supported. 46*f62ea8a1Sandi * 47*f62ea8a1Sandi * $renderer contains a reference to the renderer object which is 48*f62ea8a1Sandi * currently handling the rendering. You need to use it for writing 49*f62ea8a1Sandi * the output. How this is done depends on the renderer used (specified 50*f62ea8a1Sandi * by $mode 51*f62ea8a1Sandi * 52*f62ea8a1Sandi * The contents of the $data array depends on what the handler() function above 53*f62ea8a1Sandi * created 54*f62ea8a1Sandi * 55*f62ea8a1Sandi * @param $mode string current Rendermode 56*f62ea8a1Sandi * @param $renderer ref reference to the current renderer object 57*f62ea8a1Sandi * @param $data array data created by handler() 58*f62ea8a1Sandi * @return boolean rendered correctly? 59*f62ea8a1Sandi */ 60*f62ea8a1Sandi function render($mode, &$renderer, $data) { 61*f62ea8a1Sandi trigger_error('render() not implemented in '.get_class($this), E_USER_WARNING); 62*f62ea8a1Sandi } 63*f62ea8a1Sandi 64*f62ea8a1Sandi} 65*f62ea8a1Sandi 66*f62ea8a1Sandi//Setup VIM: ex: et ts=4 enc=utf-8 : 67