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/');
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     * Syntax Type
26     *
27     * Needs to return one of the mode types defined in $PARSER_MODES in parser.php
28     */
29    function getType()  { return 'substition'; }
30    function getPType() { return 'block'; }
31    function getSort()  { return 308; }
32
33    /**
34     * Connect pattern to lexer
35     */
36    function connectTo($mode) {
37        $this->Lexer->addSpecialPattern('~~CLEARFLOAT~~',$mode,'plugin_clearfloat');
38        $this->Lexer->addSpecialPattern('~~CL~~',$mode,'plugin_clearfloat');
39    }
40
41    /**
42     * Handler to prepare matched data for the rendering process
43     */
44    function handle($match, $state, $pos, Doku_Handler $handler){
45        return array();
46    }
47
48    /**
49     * Handles the actual output creation.
50     */
51    function render($mode, Doku_Renderer $renderer, $data) {
52        if($mode == 'xhtml'){
53            $renderer->doc .= '<div class="clearer"></div>' . DW_LF;
54            return true;
55        }
56        return false;
57    }
58
59}
60// vim:ts=4:sw=4:et:enc=utf-8:
61