diff options
Diffstat (limited to 'lib/plugins')
6 files changed, 40 insertions, 35 deletions
diff --git a/lib/plugins/config/core/Setting/Setting.php b/lib/plugins/config/core/Setting/Setting.php index 52d00c59f..e7f8ff8c2 100644 --- a/lib/plugins/config/core/Setting/Setting.php +++ b/lib/plugins/config/core/Setting/Setting.php @@ -31,6 +31,8 @@ class Setting { * * The given parameters will be set up as class properties * + * @see initialize() to set the actual value of the setting + * * @param string $key * @param array|null $params array with metadata of setting */ @@ -46,16 +48,44 @@ class Setting { } /** - * Receives current values for the setting $key + * Set the current values for the setting $key + * + * This is used to initialize the setting with the data read form the config files. * + * @see update() to set a new value * @param mixed $default default setting value * @param mixed $local local setting value * @param mixed $protected protected setting value */ - public function initialize($default, $local, $protected) { - if(isset($default)) $this->default = $default; - if(isset($local)) $this->local = $local; - if(isset($protected)) $this->protected = $protected; + public function initialize($default = null, $local = null, $protected = null) { + $this->default = $default; + $this->local = $local; + $this->protected = $protected; + } + + /** + * update changed setting with user provided value $input + * - if changed value fails error check, save it to $this->_input (to allow echoing later) + * - if changed value passes error check, set $this->_local to the new value + * + * @param mixed $input the new value + * @return boolean true if changed, false otherwise (also on error) + */ + public function update($input) { + if(is_null($input)) return false; + if($this->isProtected()) return false; + + $value = is_null($this->local) ? $this->default : $this->local; + if($value == $input) return false; + + if($this->pattern && !preg_match($this->pattern, $input)) { + $this->error = true; + $this->input = $input; + return false; + } + + $this->local = $input; + return true; } /** @@ -128,31 +158,6 @@ class Setting { } /** - * update changed setting with user provided value $input - * - if changed value fails error check, save it to $this->_input (to allow echoing later) - * - if changed value passes error check, set $this->_local to the new value - * - * @param mixed $input the new value - * @return boolean true if changed, false otherwise (also on error) - */ - public function update($input) { - if(is_null($input)) return false; - if($this->isProtected()) return false; - - $value = is_null($this->local) ? $this->default : $this->local; - if($value == $input) return false; - - if($this->pattern && !preg_match($this->pattern, $input)) { - $this->error = true; - $this->input = $input; - return false; - } - - $this->local = $input; - return true; - } - - /** * Build html for label and input of setting * * @param \admin_plugin_config $plugin object of config plugin diff --git a/lib/plugins/config/core/Setting/SettingAuthtype.php b/lib/plugins/config/core/Setting/SettingAuthtype.php index b7f82119a..14830f8b3 100644 --- a/lib/plugins/config/core/Setting/SettingAuthtype.php +++ b/lib/plugins/config/core/Setting/SettingAuthtype.php @@ -8,7 +8,7 @@ namespace dokuwiki\plugin\config\core\Setting; class SettingAuthtype extends SettingMultichoice { /** @inheritdoc */ - public function initialize($default, $local, $protected) { + public function initialize($default = null, $local = null, $protected = null) { /** @var $plugin_controller \Doku_Plugin_Controller */ global $plugin_controller; diff --git a/lib/plugins/config/core/Setting/SettingCompression.php b/lib/plugins/config/core/Setting/SettingCompression.php index f6d2c5b86..f97d82801 100644 --- a/lib/plugins/config/core/Setting/SettingCompression.php +++ b/lib/plugins/config/core/Setting/SettingCompression.php @@ -10,7 +10,7 @@ class SettingCompression extends SettingMultichoice { protected $choices = array('0'); // 0 = no compression, always supported /** @inheritdoc */ - public function initialize($default, $local, $protected) { + public function initialize($default = null, $local = null, $protected = null) { // populate _choices with the compression methods supported by this php installation if(function_exists('gzopen')) $this->choices[] = 'gz'; diff --git a/lib/plugins/config/core/Setting/SettingDirchoice.php b/lib/plugins/config/core/Setting/SettingDirchoice.php index 7855009ae..dfb27f5f4 100644 --- a/lib/plugins/config/core/Setting/SettingDirchoice.php +++ b/lib/plugins/config/core/Setting/SettingDirchoice.php @@ -10,7 +10,7 @@ class SettingDirchoice extends SettingMultichoice { protected $dir = ''; /** @inheritdoc */ - public function initialize($default, $local, $protected) { + public function initialize($default = null, $local = null, $protected = null) { // populate $this->_choices with a list of directories $list = array(); diff --git a/lib/plugins/config/core/Setting/SettingLicense.php b/lib/plugins/config/core/Setting/SettingLicense.php index a9b6d6bdf..8dacf8e25 100644 --- a/lib/plugins/config/core/Setting/SettingLicense.php +++ b/lib/plugins/config/core/Setting/SettingLicense.php @@ -10,7 +10,7 @@ class SettingLicense extends SettingMultichoice { protected $choices = array(''); // none choosen /** @inheritdoc */ - public function initialize($default, $local, $protected) { + public function initialize($default = null, $local = null, $protected = null) { global $license; foreach($license as $key => $data) { diff --git a/lib/plugins/config/core/Setting/SettingRenderer.php b/lib/plugins/config/core/Setting/SettingRenderer.php index 6d6451197..37ba9c70a 100644 --- a/lib/plugins/config/core/Setting/SettingRenderer.php +++ b/lib/plugins/config/core/Setting/SettingRenderer.php @@ -15,7 +15,7 @@ class SettingRenderer extends SettingMultichoice { protected $format = null; /** @inheritdoc */ - public function initialize($default, $local, $protected) { + public function initialize($default = null, $local = null, $protected = null) { $format = $this->format; foreach(plugin_list('renderer') as $plugin) { |