xref: /plugin/struct/types/Wiki.php (revision 7b9717bf607fbce3672e42d16e802f0123a0d5fb)
1<?php
2namespace plugin\struct\types;
3
4class Wiki extends AbstractBaseType {
5
6    /**
7     * @param int|string $value
8     * @param \Doku_Renderer $R
9     * @param string $mode
10     * @return bool
11     */
12    public function renderValue($value, \Doku_Renderer $R, $mode) {
13        $doc = p_render($mode, p_get_instructions($value), $info);
14        $R->doc .= $doc; // FIXME this probably does not work for all renderers
15        return true;
16    }
17
18    /**
19     * Clean line endings
20     *
21     * @param int|string $value
22     * @return int|string
23     */
24    public function validate($value) {
25        $value = parent::validate($value);
26        $value = cleanText($value);
27        return $value;
28    }
29
30    /**
31     * Use a text area for input
32     *
33     * @param string $name
34     * @param string $value
35     * @return string
36     */
37    public function valueEditor($name, $value) {
38        $class = 'struct_'.strtolower($this->getClass());
39        $name = hsc($name);
40        $value = formText($value);
41
42        $html = "<textarea name=\"$name\" class=\"$class\">$value</textarea>";
43        return "$html";
44    }
45
46}
47