1<?php
2
3namespace dokuwiki\plugin\config\core\Setting;
4
5/**
6 * Class setting_password
7 */
8class SettingPassword extends SettingString
9{
10    protected $code = 'plain';  // mechanism to be used to obscure passwords
11
12    /** @inheritdoc */
13    public function update($input)
14    {
15        if ($this->isProtected()) return false;
16        if (!$input) return false;
17
18        if ($this->pattern && !preg_match($this->pattern, $input)) {
19            $this->error = true;
20            $this->input = $input;
21            return false;
22        }
23
24        $this->local = conf_encodeString($input, $this->code);
25        return true;
26    }
27
28    /** @inheritdoc */
29    public function html(\admin_plugin_config $plugin, $echo = false)
30    {
31
32        $disable = $this->isProtected() ? 'disabled="disabled"' : '';
33
34        $key = htmlspecialchars($this->key);
35
36        $label = '<label for="config___' . $key . '">' . $this->prompt($plugin) . '</label>';
37        $input = '<input id="config___' . $key . '" name="config[' . $key .
38            ']" autocomplete="new-password" type="password" class="edit" value="" ' . $disable . ' />';
39        return [$label, $input];
40    }
41}
42