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