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