xref: /plugin/autotranslation/syntax/trans.php (revision 25fca7bd0ec036a36569b65be7e6f94e19dac49b)
1649de279SAndreas Gohr<?php
2649de279SAndreas Gohr/**
3649de279SAndreas Gohr * Translation Plugin: Simple multilanguage plugin
4649de279SAndreas Gohr *
5649de279SAndreas Gohr * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6649de279SAndreas Gohr * @author     Andreas Gohr <andi@splitbrain.org>
7649de279SAndreas Gohr */
8649de279SAndreas Gohr// must be run within Dokuwiki
9649de279SAndreas Gohrif(!defined('DOKU_INC')) die();
10649de279SAndreas Gohr
11*25fca7bdSGerry Weißbachclass syntax_plugin_autotranslation_trans extends DokuWiki_Syntax_Plugin {
12649de279SAndreas Gohr    /**
13649de279SAndreas Gohr     * What kind of syntax are we?
14649de279SAndreas Gohr     */
15649de279SAndreas Gohr    function getType() {
16649de279SAndreas Gohr        return 'substition';
17649de279SAndreas Gohr    }
18649de279SAndreas Gohr
19649de279SAndreas Gohr    /**
20649de279SAndreas Gohr     * Where to sort in?
21649de279SAndreas Gohr     */
22649de279SAndreas Gohr    function getSort() {
23649de279SAndreas Gohr        return 155;
24649de279SAndreas Gohr    }
25649de279SAndreas Gohr
26649de279SAndreas Gohr    /**
27649de279SAndreas Gohr     * Connect pattern to lexer
28649de279SAndreas Gohr     */
29649de279SAndreas Gohr    function connectTo($mode) {
30*25fca7bdSGerry Weißbach        $this->Lexer->addSpecialPattern('~~TRANS~~', $mode, 'plugin_autotranslation_trans');
31649de279SAndreas Gohr    }
32649de279SAndreas Gohr
33649de279SAndreas Gohr    /**
34649de279SAndreas Gohr     * Handle the match
35649de279SAndreas Gohr     */
3626dc9401SGerry Weißbach    function handle($match, $state, $pos, Doku_Handler $handler) {
37649de279SAndreas Gohr        return array();
38649de279SAndreas Gohr    }
39649de279SAndreas Gohr
40649de279SAndreas Gohr    /**
41649de279SAndreas Gohr     * Create output
42649de279SAndreas Gohr     */
4326dc9401SGerry Weißbach    function render($format, Doku_Renderer $renderer, $data) {
44649de279SAndreas Gohr        if($format != 'xhtml') return false;
45649de279SAndreas Gohr
46649de279SAndreas Gohr        // disable caching
47649de279SAndreas Gohr        $renderer->nocache();
48649de279SAndreas Gohr
49*25fca7bdSGerry Weißbach        /** @var helper_plugin_autotranslation $hlp */
50*25fca7bdSGerry Weißbach        $hlp =  plugin_load('helper', 'autotranslation');
51649de279SAndreas Gohr        $renderer->doc .= $hlp->showTranslations();
52649de279SAndreas Gohr        return true;
53649de279SAndreas Gohr    }
54649de279SAndreas Gohr
55649de279SAndreas Gohr}
56649de279SAndreas Gohr
57649de279SAndreas Gohr//Setup VIM: ex: et ts=4 enc=utf-8 :
58