1<?php
2/**
3 * DokuWiki Plugin feedback (Syntax Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Michael Große <grosse@cosmocode.de>
7 */
8
9// must be run within Dokuwiki
10if (!defined('DOKU_INC')) die();
11
12class syntax_plugin_feedback extends DokuWiki_Syntax_Plugin {
13    /**
14     * @return string Syntax mode type
15     */
16    public function getType() {
17        return 'substition';
18    }
19    /**
20     * @return string Paragraph type
21     */
22    public function getPType() {
23        return 'normal';
24    }
25    /**
26     * @return int Sort order - Low numbers go before high numbers
27     */
28    public function getSort() {
29        return 123;
30    }
31
32    /**
33     * Connect lookup pattern to lexer.
34     *
35     * @param string $mode Parser mode
36     */
37    public function connectTo($mode) {
38        $this->Lexer->addSpecialPattern('{{FEEDBACK}}',$mode,'plugin_feedback');
39    }
40
41    /**
42     * Handle matches of the @@PLUGIN_NAME@@ syntax
43     *
44     * @param string          $match   The match of the syntax
45     * @param int             $state   The state of the handler
46     * @param int             $pos     The position in the document
47     * @param Doku_Handler    $handler The handler
48     * @return array Data for the renderer
49     */
50    public function handle($match, $state, $pos, Doku_Handler $handler){
51        $data = array();
52
53        return $data;
54    }
55
56    /**
57     * Render xhtml output or metadata
58     *
59     * @param string         $mode      Renderer mode (supported modes: xhtml)
60     * @param Doku_Renderer  $renderer  The renderer
61     * @param array          $data      The data from the handler() function
62     * @return bool If rendering was successful.
63     */
64    public function render($mode, Doku_Renderer $renderer, $data) {
65        if($mode !== 'xhtml') return false;
66        /** @var action_plugin_feedback $action */
67        $action = plugin_load('action', 'feedback');
68        if ($action) {
69            $renderer->doc .= $action->tpl(true);
70        }
71        return true;
72    }
73}
74
75// vim:ts=4:sw=4:et:
76