1<?php
2/**
3 * Signhere Plugin: Display a signature line with a description
4 * Usage: ____(<Description>)____
5 *
6 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
7 * @author     Dennis Ploeger <develop@dieploegers.de>
8 */
9
10if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
11if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
12require_once(DOKU_PLUGIN.'syntax.php');
13
14/**
15 * All DokuWiki plugins to extend the parser/rendering mechanism
16 * need to inherit from this class
17 */
18class syntax_plugin_signhere extends DokuWiki_Syntax_Plugin {
19
20    // How many spaces do you wish to be put around the description?
21
22    var $space_fill = 4;
23
24    // How much do you like the min-width of the signature line?
25
26    var $min_width = "100px";
27
28    // What font size do you want for the description?
29
30    var $font_size = "x-small";
31
32    /**
33     * What kind of syntax are we?
34     */
35    function getType(){
36        return 'substition';
37    }
38
39    /**
40     * Where to sort in?
41     */
42    function getSort(){
43        return 400;
44    }
45
46    /**
47     * Connect pattern to lexer
48     */
49    function connectTo($mode) {
50        $this->Lexer->addSpecialPattern("-_.*?_-", $mode ,'plugin_signhere');
51    }
52
53    /**
54     * Handle the match
55     */
56
57    function handle($match, $state, $pos, &$handler){
58        preg_match('/-_(.*?)_-/', $match, $matches);
59        return array($matches[1]);
60    }
61
62    /**
63     * Create output
64     */
65    function render($mode, &$renderer, $data) {
66        global $INFO, $conf;
67
68        if($mode == 'xhtml'){
69
70            $data[0] = str_repeat('&nbsp;', $this->space_fill).$data[0].str_repeat('&nbsp;', $this->space_fill);
71
72            $renderer->doc .= '<table border="0" cellspacing="0" cellpadding="0">';
73            $renderer->doc .= '<tr>';
74            $renderer->doc .= '<td style="min-width:'.$this->min_width.';border-bottom:1px solid #000000">&nbsp;</td>';
75            $renderer->doc .= '</tr>';
76            $renderer->doc .= '<tr>';
77            $renderer->doc .= '<td align="center" style="font-size:'.$this->font_size.';">'.$data[0].'</td>';
78            $renderer->doc .= '</tr>';
79            $renderer->doc .= '</table>';
80            $renderer->doc .= '<br />';
81
82            return true;
83        }
84        return false;
85    }
86
87}
88
89//Setup VIM: ex: et ts=4 enc=utf-8 :
90
91?>
92