summaryrefslogtreecommitdiff
path: root/platform/www/lib/plugins/include/syntax/sorttag.php
blob: c7704bacb779f6ddb126e5272d46125b98999c98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php

/**
 * Include plugin sort order tag, idea and parts of the code copied from the indexmenu plugin.
 *
 * @license     GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author      Samuele Tognini <samuele@netsons.org>
 * @author      Michael Hamann <michael@content-space.de>
 *
 */
class syntax_plugin_include_sorttag extends DokuWiki_Syntax_Plugin {

    /**
     * What kind of syntax are we?
     */
    public function getType(){
        return 'substition';
    }

    /**
     * The paragraph type - block, we don't need paragraph tags
     *
     * @return string The paragraph type
     */
    public function getPType() {
        return 'block';
    }

    /**
     * Where to sort in?
     */
    public function getSort(){
        return 139;
    }

    /**
     * Connect pattern to lexer
     */
    public function connectTo($mode) {
        $this->Lexer->addSpecialPattern('{{include_n>.+?}}',$mode,'plugin_include_sorttag');
    }

    /**
     * Handle the match
     */
    public function handle($match, $state, $pos, Doku_Handler $handler){
        $match = substr($match,12,-2);
        return array($match);
    }

    /**
     * Render output
     */
    public function render($mode, Doku_Renderer $renderer, $data) {
        if ($mode === 'metadata') {
            /** @var Doku_Renderer_metadata $renderer */
            $renderer->meta['include_n'] = $data[0];
        }
    }
}