xref: /plugin/struct/types/Text.php (revision fb31ca9fa3249b10a91554bcd044f27dda620b99)
1<?php
2namespace plugin\struct\types;
3
4use dokuwiki\Form\Form;
5
6class Text extends AbstractBaseType {
7
8    protected $config = array(
9        'prefix' => '',
10        'postfix' => '',
11    );
12
13
14
15
16    /**
17     * Output the stored data
18     *
19     * @param int|string $value
20     * @return string the HTML to represent this data
21     */
22    public function getDisplayData($value) {
23        return hsc($this->config['prefix'] . $value . $this->config['postfix']);
24    }
25
26    /**
27     * @param string $name
28     * @param \string[] $values
29     * @return string
30     */
31    public function multiValueEditor($name, $values) {
32        $value = join(', ',$values);
33        return $this->valueEditor($name, $value);
34    }
35
36    /**
37     * Return the editor to edit a single value
38     *
39     * @param string $name the form name where this has to be stored
40     * @param string $value the current value
41     * @return string html
42     */
43    public function valueEditor($name, $value) {
44        $name = hsc($name);
45        $value = hsc($value);
46        $html = "<input name=\"$name\" value=\"$value\" />";
47        return "$html";
48    }
49}
50