xref: /dokuwiki/lib/plugins/config/core/Setting/SettingString.php (revision d868eb89f182718a31113373a6272670bd7f8012)
10a5b05ebSAndreas Gohr<?php
20a5b05ebSAndreas Gohr
30a5b05ebSAndreas Gohrnamespace dokuwiki\plugin\config\core\Setting;
40a5b05ebSAndreas Gohr
50a5b05ebSAndreas Gohr/**
60a5b05ebSAndreas Gohr * Class setting_string
70a5b05ebSAndreas Gohr */
88c7c53b0SAndreas Gohrclass SettingString extends Setting
98c7c53b0SAndreas Gohr{
100a5b05ebSAndreas Gohr    /** @inheritdoc */
11*d868eb89SAndreas Gohr    public function html(\admin_plugin_config $plugin, $echo = false)
12*d868eb89SAndreas Gohr    {
130a5b05ebSAndreas Gohr        $disable = '';
140a5b05ebSAndreas Gohr
150a5b05ebSAndreas Gohr        if ($this->isProtected()) {
160a5b05ebSAndreas Gohr            $value = $this->protected;
170a5b05ebSAndreas Gohr            $disable = 'disabled="disabled"';
18467c1427SAndreas Gohr        } elseif ($echo && $this->error) {
190a5b05ebSAndreas Gohr            $value = $this->input;
200a5b05ebSAndreas Gohr        } else {
210a5b05ebSAndreas Gohr            $value = is_null($this->local) ? $this->default : $this->local;
220a5b05ebSAndreas Gohr        }
230a5b05ebSAndreas Gohr
240a5b05ebSAndreas Gohr        $key = htmlspecialchars($this->key);
250a5b05ebSAndreas Gohr        $value = htmlspecialchars($value);
260a5b05ebSAndreas Gohr
270a5b05ebSAndreas Gohr        $label = '<label for="config___' . $key . '">' . $this->prompt($plugin) . '</label>';
280a5b05ebSAndreas Gohr        $input = '<input id="config___' . $key . '" name="config[' . $key .
290a5b05ebSAndreas Gohr            ']" type="text" class="edit" value="' . $value . '" ' . $disable . '/>';
30467c1427SAndreas Gohr        return [$label, $input];
310a5b05ebSAndreas Gohr    }
320a5b05ebSAndreas Gohr}
33