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