1<?php
2
3/**
4 * DokuWiki Plugin dbquery (Syntax Component)
5 *
6 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
7 * @author  Andreas Gohr <dokuwiki@cosmocode.de>
8 */
9class syntax_plugin_dbquery_macro extends \dokuwiki\Extension\SyntaxPlugin
10{
11    /** @inheritDoc */
12    public function getType()
13    {
14        return 'substition';
15    }
16
17    /** @inheritDoc */
18    public function getPType()
19    {
20        return 'normal';
21    }
22
23    /** @inheritDoc */
24    public function getSort()
25    {
26        return 155;
27    }
28
29    /** @inheritDoc */
30    public function connectTo($mode)
31    {
32        $this->Lexer->addSpecialPattern('~~DBQUERY:.*?~~', $mode, 'plugin_dbquery_macro');
33    }
34
35    /** @inheritDoc */
36    public function handle($match, $state, $pos, Doku_Handler $handler)
37    {
38        $macro = strtolower(trim(substr($match, 10, -2)));
39        return [$macro];
40    }
41
42    /** @inheritDoc */
43    public function render($mode, Doku_Renderer $renderer, $data)
44    {
45        $renderer->info['dbquery'][$data[0]] = true;
46        return true;
47    }
48}
49
50