[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 3 namespace dokuwiki\plugin\config\core\Setting; 4 5 /** 6 * Class setting_onoff 7 */ 8 class SettingOnoff extends SettingNumeric { 9 10 /** 11 * We treat the strings 'false' and 'off' as false 12 * @inheritdoc 13 */ 14 protected function cleanValue($value) { 15 if($value === null) return null; 16 17 if(is_string($value)) { 18 if(strtolower($value) === 'false') return 0; 19 if(strtolower($value) === 'off') return 0; 20 if(trim($value) === '') return 0; 21 } 22 23 return (int) (bool) $value; 24 } 25 26 /** @inheritdoc */ 27 public function html(\admin_plugin_config $plugin, $echo = false) { 28 $disable = ''; 29 30 if($this->isProtected()) { 31 $value = $this->protected; 32 $disable = ' disabled="disabled"'; 33 } else { 34 $value = is_null($this->local) ? $this->default : $this->local; 35 } 36 37 $key = htmlspecialchars($this->key); 38 $checked = ($value) ? ' checked="checked"' : ''; 39 40 $label = '<label for="config___' . $key . '">' . $this->prompt($plugin) . '</label>'; 41 $input = '<div class="input"><input id="config___' . $key . '" name="config[' . $key . 42 ']" type="checkbox" class="checkbox" value="1"' . $checked . $disable . '/></div>'; 43 return array($label, $input); 44 } 45 46 /** @inheritdoc */ 47 public function update($input) { 48 if($this->isProtected()) return false; 49 50 $input = ($input) ? 1 : 0; 51 $value = is_null($this->local) ? $this->default : $this->local; 52 if($value == $input) return false; 53 54 $this->local = $input; 55 return true; 56 } 57 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body