xref: /dokuwiki/lib/plugins/config/core/Setting/SettingString.php (revision 8c7c53b0321a3cd3116b8d3b2ad27863a38dece7)
1<?php
2
3namespace dokuwiki\plugin\config\core\Setting;
4
5/**
6 * Class setting_string
7 */
8class SettingString extends Setting
9{
10    /** @inheritdoc */
11    public function html(\admin_plugin_config $plugin, $echo = false) {
12        $disable = '';
13
14        if ($this->isProtected()) {
15            $value = $this->protected;
16            $disable = 'disabled="disabled"';
17        } elseif ($echo && $this->error) {
18            $value = $this->input;
19        } else {
20            $value = is_null($this->local) ? $this->default : $this->local;
21        }
22
23        $key = htmlspecialchars($this->key);
24        $value = htmlspecialchars($value);
25
26        $label = '<label for="config___' . $key . '">' . $this->prompt($plugin) . '</label>';
27        $input = '<input id="config___' . $key . '" name="config[' . $key .
28            ']" type="text" class="edit" value="' . $value . '" ' . $disable . '/>';
29        return [$label, $input];
30    }
31}
32