1<?php
2
3use dokuwiki\Extension\SyntaxPlugin;
4
5/**
6 * Translation Plugin: Simple multilanguage plugin
7 *
8 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
9 * @author     Andreas Gohr <andi@splitbrain.org>
10 */
11class syntax_plugin_translation_notrans extends SyntaxPlugin
12{
13    /** @var helper_plugin_translation */
14    protected $hlp;
15
16    /**
17     * Constructor. Load helper plugin
18     */
19    public function __construct()
20    {
21        $this->hlp = plugin_load('helper', 'translation');
22    }
23
24    /** @inheritdoc */
25    public function getType()
26    {
27        return 'substition';
28    }
29
30    /** @inheritdoc */
31    public function getSort()
32    {
33        return 155;
34    }
35
36    /** @inheritdoc */
37    public function connectTo($mode)
38    {
39        $this->Lexer->addSpecialPattern('~~NOTRANS~~', $mode, 'plugin_translation_notrans');
40    }
41
42    /** @inheritdoc */
43    public function handle($match, $state, $pos, Doku_Handler $handler)
44    {
45        return ['notrans'];
46    }
47
48    /** @inheritdoc */
49    public function render($format, Doku_Renderer $renderer, $data)
50    {
51        // store info in metadata
52        if ($format == 'metadata') {
53            /** @var Doku_Renderer_metadata $renderer */
54            $renderer->meta['plugin']['translation']['notrans'] = true;
55        }
56        return false;
57    }
58}
59