1<?php
2/**
3 * Renderer for comments
4 *
5 * @author Andreas Gohr <andi@splitbrain.org>
6 */
7// must be run within Dokuwiki
8if(!defined('DOKU_INC')) die();
9
10/**
11 * The Renderer
12 */
13class renderer_plugin_blogtng_comment extends Doku_Renderer_xhtml {
14    var $slideopen = false;
15    var $base='';
16    var $tpl='';
17
18    /**
19     * the format we produce
20     */
21    function getFormat(){
22        return 'blogtng_comment';
23    }
24
25    function nocache() {}
26    function notoc() {}
27    function document_end() {}
28
29    /**
30     * Render a heading
31     *
32     * @param string $text  the text to display
33     * @param int    $level header level
34     * @param int    $pos   byte position in the original source
35     */
36    function header($text, $level, $pos) {
37        $this->cdata($text);
38    }
39
40    function section_edit() {}
41
42    /**
43     * Open a new section
44     *
45     * @param int $level section level (as determined by the previous header)
46     */
47    function section_open($level) {}
48    function section_close() {}
49    function footnote_open() {}
50    function footnote_close() {}
51
52    /**
53     * Execute PHP code if allowed
54     *
55     * @param  string $text      PHP code that is either executed or printed
56     * @param  string $wrapper   html element to wrap result if $conf['phpok'] is okff
57     *
58     * @author Andreas Gohr <andi@splitbrain.org>
59     */
60    function php($text, $wrapper='code') {
61        $this->doc .= p_xhtml_cached_geshi($text, 'php', $wrapper);
62    }
63
64    /**
65     * Insert HTML if allowed
66     *
67     * @param  string $text      html text
68     * @param  string $wrapper   html element to wrap result if $conf['htmlok'] is okff
69     *
70     * @author Andreas Gohr <andi@splitbrain.org>
71     */
72    function html($text, $wrapper='code') {
73        $this->doc .= p_xhtml_cached_geshi($text, 'html4strict', $wrapper);
74    }
75
76    /**
77     * Renders an RSS feed
78     *
79     * @author Andreas Gohr <andi@splitbrain.org>
80     *
81     * @param string $url
82     * @param array  $params
83     */
84    function rss($url, $params) {}
85
86    /**
87     * Call a syntax plugin's render function if it is allowed
88     * by the actual configuration settings.
89     *
90     * @param  string $name
91     * @param  mixed  $data
92     * @return bool
93     */
94    function plugin($name, $data, $state = '', $match = '') {
95        $comments_xhtml_renderer = array_map('trim', explode(',', $this->getConf('comments_xhtml_renderer')));
96        $comments_forbid_syntax = array_map('trim', explode(',', $this->getConf('comments_forbid_syntax')));
97        /** @var DokuWiki_Syntax_Plugin $plugin */
98        $plugin = plugin_load('syntax',$name);
99        if($plugin != null){
100            if (in_array($name, $comments_forbid_syntax)) {
101                return false;
102            } elseif (in_array($name, $comments_xhtml_renderer)) {
103                $plugin->render('xhtml',$this,$data);
104            } else {
105                $plugin->render($this->getFormat(), $this, $data);
106            }
107        }
108        return true;
109    }
110}
111
112//Setup VIM: ex: et ts=4 :
113