1<?php 2 3namespace dokuwiki\plugin\config\core\Setting; 4 5/** 6 * Class setting_onoff 7 */ 8class SettingOnoff extends SettingNumeric { 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 } else { 17 $value = is_null($this->local) ? $this->default : $this->local; 18 } 19 20 $key = htmlspecialchars($this->key); 21 $checked = ($value) ? ' checked="checked"' : ''; 22 23 $label = '<label for="config___' . $key . '">' . $this->prompt($plugin) . '</label>'; 24 $input = '<div class="input"><input id="config___' . $key . '" name="config[' . $key . 25 ']" type="checkbox" class="checkbox" value="1"' . $checked . $disable . '/></div>'; 26 return array($label, $input); 27 } 28 29 /** @inheritdoc */ 30 public function update($input) { 31 if($this->isProtected()) return false; 32 33 $input = ($input) ? 1 : 0; 34 $value = is_null($this->local) ? $this->default : $this->local; 35 if($value == $input) return false; 36 37 $this->local = $input; 38 return true; 39 } 40} 41