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 * @author  i-net /// software GmbH <tools@inetsoftware.de>
12 */
13
14if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
15if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
16require_once(DOKU_PLUGIN.'syntax.php');
17if(!defined('DW_LF')) define('DW_LF',"\n");
18
19/**
20 * All DokuWiki plugins to extend the parser/rendering mechanism
21 * need to inherit from this class
22 */
23class syntax_plugin_clearfloat extends DokuWiki_Syntax_Plugin {
24
25    /**
26     * Syntax Type
27     *
28     * Needs to return one of the mode types defined in $PARSER_MODES in parser.php
29     */
30    function getType()  { return 'substition'; }
31    function getPType() { return 'block'; }
32    function getSort()  { return 308; }
33
34    /**
35     * Connect pattern to lexer
36     */
37    function connectTo($mode) {
38        $this->Lexer->addSpecialPattern('~~CLEARFLOAT~~',$mode,'plugin_clearfloat');
39        $this->Lexer->addSpecialPattern('~~CL~~',$mode,'plugin_clearfloat');
40    }
41
42    /**
43     * Handler to prepare matched data for the rendering process
44     */
45    function handle($match, $state, $pos, Doku_Handler $handler){
46        return array();
47    }
48
49    /**
50     * Handles the actual output creation.
51     */
52    function render($mode, Doku_Renderer $renderer, $data) {
53        if($mode == 'xhtml'){
54            $renderer->doc .= '<div class="clearer"></div>' . DW_LF;
55            return true;
56        }
57        return false;
58    }
59
60}
61// vim:ts=4:sw=4:et:enc=utf-8:
62