From 253d4b48ec708eb42033862dc15c8576f44a48ed Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 1 Oct 2014 15:32:05 +0200 Subject: more PHPDocs, unused var, small bit code reformatting --- lib/plugins/config/admin.php | 45 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) (limited to 'lib/plugins/config/admin.php') diff --git a/lib/plugins/config/admin.php b/lib/plugins/config/admin.php index 835d27775..9202a221b 100644 --- a/lib/plugins/config/admin.php +++ b/lib/plugins/config/admin.php @@ -32,6 +32,9 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { var $_session_started = false; var $_localised_prompts = false; + /** + * @return int + */ function getMenuSort() { return 100; } /** @@ -40,14 +43,20 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { function handle() { global $ID, $INPUT; - if (!$this->_restore_session()) return $this->_close_session(); - if ($INPUT->int('save') != 1) return $this->_close_session(); - if (!checkSecurityToken()) return $this->_close_session(); + if(!$this->_restore_session() || $INPUT->int('save') != 1 || !checkSecurityToken()) { + $this->_close_session(); + return; + } - if (is_null($this->_config)) { $this->_config = new configuration($this->_file); } + if(is_null($this->_config)) { + $this->_config = new configuration($this->_file); + } // don't go any further if the configuration is locked - if ($this->_config->_locked) return $this->_close_session(); + if($this->_config->locked) { + $this->_close_session(); + return; + } $this->_input = $INPUT->arr('config'); @@ -104,6 +113,7 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { formSecurityToken(); $this->_print_h1('dokuwiki_settings', $this->getLang('_header_dokuwiki')); + /** @var setting[] $undefined_settings */ $undefined_settings = array(); $in_fieldset = false; $first_plugin_fieldset = true; @@ -162,7 +172,17 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { // show undefined settings list if ($allow_debug && !empty($undefined_settings)) { - function _setting_natural_comparison($a, $b) { return strnatcmp($a->_key, $b->_key); } + /** + * Callback for sorting settings + * + * @param setting $a + * @param setting $b + * @return int if $a is lower/equal/higher than $b + */ + function _setting_natural_comparison($a, $b) { + return strnatcmp($a->_key, $b->_key); + } + usort($undefined_settings, '_setting_natural_comparison'); $this->_print_h1('undefined_settings', $this->getLang('_header_undefined')); ptln('
'); @@ -235,6 +255,9 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { if ($this->_session_started) session_write_close(); } + /** + * @param bool $prompts + */ function setupLocale($prompts=false) { parent::setupLocale(); @@ -245,6 +268,9 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { } + /** + * @return bool + */ function _setup_localised_plugin_prompts() { global $conf; @@ -299,6 +325,8 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { * Generates a two-level table of contents for the config plugin. * * @author Ben Coburn + * + * @return array */ function getTOC() { if (is_null($this->_config)) { $this->_config = new configuration($this->_file); } @@ -328,6 +356,7 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { $t[] = html_mktocitem('configuration_manager', $this->getLang('_configuration_manager'), 1); $t[] = html_mktocitem('dokuwiki_settings', $this->getLang('_header_dokuwiki'), 1); + /** @var setting $setting */ foreach($toc['conf'] as $setting) { $name = $setting->prompt($this); $t[] = html_mktocitem($setting->_key, $name, 2); @@ -352,6 +381,10 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { return $t; } + /** + * @param string $id + * @param string $text + */ function _print_h1($id, $text) { ptln('

'.$text.'

'); } -- cgit v1.2.3 From 79e79377626799a77c11aa7849cb9c64305590c8 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 7 Jan 2015 10:47:45 +0100 Subject: Remove error supression for file_exists() In an older version of PHP a file_exists() call would issue a warning when the file did not exist. This was fixed in later PHP releases. Since we require PHP 5.3 now, there's no need to supress any error here anymore. This might even give a minor performance boost. --- lib/plugins/config/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/plugins/config/admin.php') diff --git a/lib/plugins/config/admin.php b/lib/plugins/config/admin.php index 9202a221b..2ef570b68 100644 --- a/lib/plugins/config/admin.php +++ b/lib/plugins/config/admin.php @@ -282,7 +282,7 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { if ($plugin == '.' || $plugin == '..' || $plugin == 'tmp' || $plugin == 'config') continue; if (is_file(DOKU_PLUGIN.$plugin)) continue; - if (@file_exists(DOKU_PLUGIN.$plugin.$enlangfile)){ + if (file_exists(DOKU_PLUGIN.$plugin.$enlangfile)){ $lang = array(); @include(DOKU_PLUGIN.$plugin.$enlangfile); if ($conf['lang'] != 'en') @include(DOKU_PLUGIN.$plugin.$langfile); @@ -303,7 +303,7 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { // the same for the active template $tpl = $conf['template']; - if (@file_exists(tpl_incdir().$enlangfile)){ + if (file_exists(tpl_incdir().$enlangfile)){ $lang = array(); @include(tpl_incdir().$enlangfile); if ($conf['lang'] != 'en') @include(tpl_incdir().$langfile); -- cgit v1.2.3 From ae614416a5d7f5cab6c5b82a0c45f587d7fa9c01 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sun, 12 Jul 2015 19:05:43 +0100 Subject: changed all input type=submit buttons to button type=submit button for better stylability --- lib/plugins/config/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/plugins/config/admin.php') diff --git a/lib/plugins/config/admin.php b/lib/plugins/config/admin.php index 2ef570b68..ec8ee0b84 100644 --- a/lib/plugins/config/admin.php +++ b/lib/plugins/config/admin.php @@ -212,8 +212,8 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { if (!$this->_config->locked) { ptln(' '); - ptln(' '); - ptln(' '); + ptln(' '); + ptln(' '); } ptln('

'); -- cgit v1.2.3