1<?php 2/** 3 * DokuWiki Syntax Plugin Clearfloat 4 * 5 * Clears the floating of elements such as images. 6 * 7 * Syntax: ~~CLEARFLOAT~~ or ~~CL~~ 8 * 9 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 10 * @author Michael Klier <chi@chimeric.de> 11 */ 12 13if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 14if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 15require_once(DOKU_PLUGIN.'syntax.php'); 16if(!defined('DW_LF')) define('DW_LF',"\n"); 17 18/** 19 * All DokuWiki plugins to extend the parser/rendering mechanism 20 * need to inherit from this class 21 */ 22class syntax_plugin_clearfloat extends DokuWiki_Syntax_Plugin { 23 24 25 /** 26 * General Info 27 */ 28 function getInfo(){ 29 return array( 30 'author' => 'Michael Klier', 31 'email' => 'chi@chimeric.de', 32 'date' => @file_get_contents(DOKU_PLUGIN.'clearfloat/VERSION'), 33 'name' => 'Clearfloat', 34 'desc' => 'Clears the floating of elements such as images.', 35 'url' => 'http://dokuwiki.org/plugin:clearfloat' 36 ); 37 } 38 39 /** 40 * Syntax Type 41 * 42 * Needs to return one of the mode types defined in $PARSER_MODES in parser.php 43 */ 44 function getType() { return 'substition'; } 45 function getPType() { return 'block'; } 46 function getSort() { return 308; } 47 48 /** 49 * Connect pattern to lexer 50 */ 51 function connectTo($mode) { 52 $this->Lexer->addSpecialPattern('~~CLEARFLOAT~~',$mode,'plugin_clearfloat'); 53 $this->Lexer->addSpecialPattern('~~CL~~',$mode,'plugin_clearfloat'); 54 } 55 56 /** 57 * Handler to prepare matched data for the rendering process 58 */ 59 function handle($match, $state, $pos, &$handler){ 60 return array(); 61 } 62 63 /** 64 * Handles the actual output creation. 65 */ 66 function render($mode, &$renderer, $data) { 67 if($mode == 'xhtml'){ 68 $renderer->doc .= '<div class="clearer"></div>' . DW_LF; 69 return true; 70 } 71 return false; 72 } 73 74} 75// vim:ts=4:sw=4:et:enc=utf-8: 76