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