1<?php
2/**
3 * BBCode plugin: allows BBCode markup familiar from forum software
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Esther Brunner <esther@kaffeehaus.ch>
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');
12
13/**
14 * All DokuWiki plugins to extend the parser/rendering mechanism
15 * need to inherit from this class
16 */
17class syntax_plugin_bbcode_email extends DokuWiki_Syntax_Plugin {
18
19    function getType() { return 'substition'; }
20    function getSort() { return 105; }
21    function connectTo($mode) { $this->Lexer->addSpecialPattern('\[email.+?\[/email\]',$mode,'plugin_bbcode_email'); }
22
23    /**
24     * Handle the match
25     */
26    function handle($match, $state, $pos, Doku_Handler $handler) {
27        $match = trim(substr($match, 7, -8));
28        $match = preg_split('/\]/u',$match,2);
29        if ( !isset($match[0]) ) {
30            $url   = $match[1];
31            $title = NULL;
32        } else {
33            $url   = $match[0];
34            $title = $match[1];
35        }
36        $handler->_addCall('emaillink',array($url, $title), $pos);
37        return true;
38    }
39
40    /**
41     * Create output
42     */
43    function render($mode, Doku_Renderer $renderer, $data) {
44        return true;
45    }
46}
47// vim:ts=4:sw=4:et:enc=utf-8:
48