1<?php
2/**
3 * DokuWiki Plugin wst (Syntax Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Vitalie Ciubotaru <vitalie@ciubotaru.tk>
7 */
8
9// must be run within Dokuwiki
10if (!defined('DOKU_INC')) die();
11if (!defined('DOKU_LF')) define('DOKU_LF', "\n");
12if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t");
13if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
14
15class syntax_plugin_wst_noinclude extends DokuWiki_Syntax_Plugin {
16    /**
17     * @return string Syntax mode type
18     */
19    public function getType() {
20        return 'substition';//maybe switch to 'container'
21    }
22    /**
23     * @return string Paragraph type
24     */
25    public function getPType() {
26        return 'normal'; //?
27    }
28    /**
29     * @return int Sort order - Low numbers go before high numbers
30     */
31    public function getSort() {
32        return 320; // should go before Doku_Parser_Mode_media 320
33    }
34//    function getAllowedTypes() { return array('formatting', 'substition', 'disabled'); }
35    /**
36     * Connect lookup pattern to lexer.
37     *
38     * @param string $mode Parser mode
39     */
40    public function connectTo($mode) {
41        $this->Lexer->addSpecialPattern('<noinclude>|</noinclude>', $mode, 'plugin_wst_noinclude');
42//        $this->Lexer->addEntryPattern('\{\{[W|w][S|s][T|t]:(?=.*\}\})', $mode, 'plugin_wst');
43    }
44
45/**
46    public function postConnect() {
47        $this->Lexer->addExitPattern('\}\}', 'plugin_wst');
48    }
49**/
50    /**
51     * Handle matches of the wst syntax
52     *
53     * @param string          $match   The match of the syntax
54     * @param int             $state   The state of the handler
55     * @param int             $pos     The position in the document
56     * @param Doku_Handler    $handler The handler
57     * @return array Data for the renderer
58     */
59    public function handle($match, $state, $pos, Doku_Handler $handler){
60		return '';
61    }
62
63    /**
64     * Render xhtml output or metadata
65     *
66     * @param string         $mode      Renderer mode (supported modes: xhtml)
67     * @param Doku_Renderer  $renderer  The renderer
68     * @param array          $data      The data from the handler() function
69     * @return bool If rendering was successful.
70     */
71    public function render($mode, Doku_Renderer $renderer, $data) {
72        if($mode != 'xhtml') return false;
73        if (!$data) return false;
74//		$renderer->doc .= $renderer->render_text($data, 'xhtml');
75        return true;
76    }
77}
78
79