From 685bdd2e6c508c47a360b2dbf1beea318f7f99cd Mon Sep 17 00:00:00 2001 From: Ben Coburn Date: Sat, 20 May 2006 12:37:18 +0200 Subject: config plugin ui update 20060520 This patch hides settings that are missing config metadata and optionally provides a list of warnings about settings that are not properly configured. - Warnings about settings are listed if $conf['allowdebug'] is true. - Warnings are listed by the $conf string as it appears in local.php. - Warnings show the $meta string as it would appear in the correct settings metadata file. - There are 3 kinds of warnings. - undefined There is no $meta information defined for this setting. - no class The setting class specified in $meta can not be found. This setting does have a $meta entry. - no default The setting is missing a default value. The setting does have a $meta entry with a valid setting class. - Note: Settings with metadata but other warnings are allowed to appear in the normal config settings list. Also... - Templates can now define their own settings classes. - Removed an XHTML validation error from the first patch. - More language strings to go with the new warnings. The warnings under the 'Undefined Settings' heading are intended to provide developers with a list of any settings that they have forgotten to finish preparing for the config plugin. This list should be blank for stable releases. darcs-hash:20060520103718-05dcb-6d4e6bce78498cbf9d087e27d52e4aa30917b0a5.gz --- lib/plugins/config/admin.php | 49 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 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 cae1c3e42..649318ef9 100644 --- a/lib/plugins/config/admin.php +++ b/lib/plugins/config/admin.php @@ -4,6 +4,7 @@ * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Christopher Smith + * @author Ben Coburn */ // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); @@ -91,6 +92,7 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { * output appropriate html */ function html() { + $allow_debug = $GLOBALS['conf']['allowdebug']; // avoid global $conf; here. global $lang; global $ID; @@ -112,11 +114,19 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { ptln('
'); $this->_print_h1('dokuwiki_settings', $this->getLang('_header_dokuwiki')); + $undefined_settings = array(); $in_fieldset = false; $first_plugin_fieldset = true; $first_template_fieldset = true; foreach($this->_config->setting as $setting) { - if (is_a($setting, 'setting_fieldset')) { + if (is_a($setting, 'setting_hidden')) { + // skip hidden (and undefined) settings + if ($allow_debug && is_a($setting, 'setting_undefined')) { + $undefined_settings[] = $setting; + } else { + continue; + } + } else if (is_a($setting, 'setting_fieldset')) { // config setting group if ($in_fieldset) { ptln(' '); @@ -131,7 +141,7 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { $this->_print_h1('template_settings', $this->getLang('_header_template')); $first_template_fieldset = false; } - ptln('
'); + ptln('
'); ptln(' '.$setting->prompt($this).''); ptln(' '); } else { @@ -153,6 +163,30 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { ptln(' '); } + // show undefined settings list + if ($allow_debug && !empty($undefined_settings)) { + 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('
'); + ptln('
'); + $undefined_setting_match = array(); + foreach($undefined_settings as $setting) { + if (preg_match('/^(?:plugin|tpl)'.CM_KEYMARKER.'.*?'.CM_KEYMARKER.'(.*)$/', $setting->_key, $undefined_setting_match)) { + $undefined_setting_key = $undefined_setting_match[1]; + } else { + $undefined_setting_key = $setting->_key; + } + ptln(' '); + ptln(' '); + ptln(' '); + ptln(' '); + } + ptln('
$'.$this->_config->_name.'[\''.$setting->_out_key().'\']'.$this->getLang('_msg_'.get_class($setting)).'
'); + ptln('
'); + } + + // finish up form ptln('

'); ptln(' '); ptln(' '); @@ -270,7 +304,10 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { * @author Ben Coburn */ function _print_config_toc() { + $allow_debug = $GLOBALS['conf']['allowdebug']; // avoid global $conf; here. + // gather toc data + $has_undefined = false; $toc = array('conf'=>array(), 'plugin'=>array(), 'template'=>null); foreach($this->_config->setting as $setting) { if (is_a($setting, 'setting_fieldset')) { @@ -281,6 +318,8 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { } else { $toc['conf'][] = $setting; } + } else if (!$has_undefined && is_a($setting, 'setting_undefined')) { + $has_undefined = true; } } @@ -326,6 +365,12 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { 'type' => 'ul', 'level' => 2); } + if ($has_undefined && $allow_debug) { + $xhtml_toc[] = array('hid' => 'undefined_settings', + 'title' => $this->getLang('_header_undefined'), + 'type' => 'ul', + 'level' => 1); + } // use the xhtml renderer to make the toc require_once(DOKU_INC.'inc/parser/xhtml.php'); -- cgit v1.2.3