1<?php
2
3use dokuwiki\Extension\SyntaxPlugin;
4use dokuwiki\Parsing\Handler;
5
6/**
7 * BBCode plugin: allows BBCode markup familiar from forum software
8 *
9 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
10 * @author     Esther Brunner <esther@kaffeehaus.ch>
11 */
12class syntax_plugin_bbcode_email extends SyntaxPlugin
13{
14    /** @inheritdoc */
15    public function getType()
16    {
17        return 'substition';
18    }
19    /** @inheritdoc */
20    public function getSort()
21    {
22        return 105;
23    }
24    /** @inheritdoc */
25    public function connectTo($mode)
26    {
27        $this->Lexer->addSpecialPattern('\[email.+?\[/email\]', $mode, 'plugin_bbcode_email');
28    }
29
30    /** @inheritdoc */
31    public function handle($match, $state, $pos, Handler $handler)
32    {
33        $match = trim(substr($match, 7, -8));
34        [$url, $title] = sexplode(']', $match, 2, null);
35        $handler->addCall('emaillink', [$url, $title], $pos);
36        return true;
37    }
38
39    /** @inheritdoc */
40    public function render($format, Doku_Renderer $renderer, $data)
41    {
42        return true;
43    }
44}
45