Skip to content
Snippets Groups Projects
Commit 685bdd2e authored by Ben Coburn's avatar Ben Coburn
Browse files

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
parent 3138b5c7
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Christopher Smith <chris@jalakai.co.uk>
* @author Ben Coburn <btcoburn@silicodon.net>
*/
// 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('<form action="'.wl($ID).'" method="post">');
$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(' </table>');
......@@ -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(' <fieldset name="'.$setting->_key.'" id="'.$setting->_key.'">');
ptln(' <fieldset id="'.$setting->_key.'">');
ptln(' <legend>'.$setting->prompt($this).'</legend>');
ptln(' <table class="inline">');
} else {
......@@ -153,6 +163,30 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
ptln(' </fieldset>');
}
// 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('<fieldset>');
ptln('<table class="inline">');
$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(' <tr>');
ptln(' <td><a class="nolink" title="$meta[\''.$undefined_setting_key.'\']">$'.$this->_config->_name.'[\''.$setting->_out_key().'\']</a></td>');
ptln(' <td>'.$this->getLang('_msg_'.get_class($setting)).'</td>');
ptln(' </tr>');
}
ptln('</table>');
ptln('</fieldset>');
}
// finish up form
ptln('<p>');
ptln(' <input type="hidden" name="do" value="admin" />');
ptln(' <input type="hidden" name="page" value="config" />');
......@@ -270,7 +304,10 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
* @author Ben Coburn <btcoburn@silicodon.net>
*/
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');
......
......@@ -22,6 +22,7 @@ $lang['_configuration_manager'] = 'Configuration Manager'; //same as heading in
$lang['_header_dokuwiki'] = 'DokuWiki Settings';
$lang['_header_plugin'] = 'Plugin Settings';
$lang['_header_template'] = 'Template Settings';
$lang['_header_undefined'] = 'Undefined Settings';
/* --- Config Setting Groups --- */
$lang['_basic'] = 'Basic Settings';
......@@ -40,6 +41,11 @@ $lang['_network'] = 'Network Settings';
$lang['_plugin_sufix'] = 'Plugin Settings';
$lang['_template_sufix'] = 'Template Settings';
/* --- Undefined Setting Messages --- */
$lang['_msg_setting_undefined'] = 'No setting metadata.';
$lang['_msg_setting_no_class'] = 'No setting class.';
$lang['_msg_setting_no_default'] = 'No default value.';
/* -------------------- Config Options --------------------------- */
$lang['fmode'] = 'File creation mode';
......
<?php
/*
/**
* Configuration Class and generic setting classes
*
* @author Chris Smith <chris@jalakai.co.uk>
* @author Ben Coburn <btcoburn@silicodon.net>
*/
if (!class_exists('configuration')) {
......@@ -51,6 +52,7 @@ if (!class_exists('configuration')) {
function retrieve_settings() {
global $conf;
$no_default_check = array('setting_fieldset', 'setting_undefined', 'setting_no_class');
if (!$this->_loaded) {
$default = array_merge($this->_read_config($this->_default_file), $this->get_plugintpl_default($conf['template']));
......@@ -64,14 +66,21 @@ if (!class_exists('configuration')) {
if (isset($this->_metadata[$key])) {
$class = $this->_metadata[$key][0];
$class = ($class && class_exists('setting_'.$class)) ? 'setting_'.$class : 'setting';
if ($class=='setting') {
$this->setting[] = new setting_no_class($key,$param);
}
$param = $this->_metadata[$key];
array_shift($param);
} else {
$class = 'setting';
$class = 'setting_undefined';
$param = NULL;
}
if (!in_array($class, $no_default_check) && !isset($default[$key])) {
$this->setting[] = new setting_no_default($key,$param);
}
$this->setting[$key] = new $class($key,$param);
$this->setting[$key]->initialize($default[$key],$local[$key],$protected[$key]);
}
......@@ -223,7 +232,7 @@ if (!class_exists('configuration')) {
if (@file_exists(DOKU_PLUGIN.$plugin.$file)){
$meta = array();
@include(DOKU_PLUGIN.$plugin.$file);
@include(DOKU_PLUGIN.$plugin.$class);
@include(DOKU_PLUGIN.$plugin.$class);
if (!empty($meta)) {
$metadata['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.'plugin_settings_name'] = array('fieldset');
}
......@@ -240,6 +249,7 @@ if (!class_exists('configuration')) {
if (@file_exists(DOKU_TPLINC.$file)){
$meta = array();
@include(DOKU_TPLINC.$file);
@include(DOKU_TPLINC.$class);
if (!empty($meta)) {
$metadata['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.'template_settings_name'] = array('fieldset');
}
......@@ -616,6 +626,41 @@ if (!class_exists('setting_dirchoice')) {
}
if (!class_exists('setting_hidden')) {
class setting_hidden extends setting {
// Used to explicitly ignore a setting in the configuration manager.
}
}
if (!class_exists('setting_fieldset')) {
class setting_fieldset extends setting {
// A do-nothing class used to detect the 'fieldset' type.
// Used to start a new settings "display-group".
}
}
if (!class_exists('setting_undefined')) {
class setting_undefined extends setting_hidden {
// A do-nothing class used to detect settings with no metadata entry.
// Used internaly to hide undefined settings, and generate the undefined settings list.
}
}
if (!class_exists('setting_no_class')) {
class setting_no_class extends setting_undefined {
// A do-nothing class used to detect settings with a missing setting class.
// Used internaly to hide undefined settings, and generate the undefined settings list.
}
}
if (!class_exists('setting_no_default')) {
class setting_no_default extends setting_undefined {
// A do-nothing class used to detect settings with no default value.
// Used internaly to hide undefined settings, and generate the undefined settings list.
}
}
/**
* Provide php_strip_whitespace (php5 function) functionality
*
......
......@@ -79,8 +79,3 @@ if (!class_exists('setting_im_convert')) {
}
}
if (!class_exists('setting_fieldset')) {
class setting_fieldset extends setting_string {
//do-nothing class used to detect the 'fieldset' type.
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment