From 4fa2dffce72d182e25295de4947077cf52ba1f2b Mon Sep 17 00:00:00 2001 From: Ben Coburn Date: Wed, 10 May 2006 08:57:32 +0200 Subject: config plugin ui organization - organizes the configuration settings list into chunks - provides a table of contents for the configuration chunks - provides one chunk for each plugin with configurable settings - provides one chunk for the active template (if it has settings) - provides the config file setting as a tool-tip on the setting label ex. $conf['start'] - provides for localization of useful strings - generates a "smart" fallback name for plugins and templates - plugin and template sections are only shown if they have settings - current configuration list is organized into chunks Note: There are NEW strings to translate into the non-english language files. darcs-hash:20060510065732-05dcb-398d5c7efa7981f690d97a25a5110b1f39be9f8e.gz --- lib/plugins/config/admin.php | 138 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 127 insertions(+), 11 deletions(-) (limited to 'lib/plugins/config/admin.php') diff --git a/lib/plugins/config/admin.php b/lib/plugins/config/admin.php index 8031b6f27..cae1c3e42 100644 --- a/lib/plugins/config/admin.php +++ b/lib/plugins/config/admin.php @@ -97,6 +97,7 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { if (is_null($this->_config)) { $this->_config = new configuration($this->_file); } $this->setupLocale(true); + $this->_print_config_toc(); print $this->locale_xhtml('intro'); ptln('
'); @@ -109,22 +110,48 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { ptln('
'.$this->getLang('updated').'
'); ptln('
'); - ptln(' '); + $this->_print_h1('dokuwiki_settings', $this->getLang('_header_dokuwiki')); + $in_fieldset = false; + $first_plugin_fieldset = true; + $first_template_fieldset = true; foreach($this->_config->setting as $setting) { - - list($label,$input) = $setting->html($this, $this->_error); - - $class = $setting->is_default() ? ' class="default"' : ($setting->is_protected() ? ' class="protected"' : ''); - $error = $setting->error() ? ' class="error"' : ''; - - ptln(' '); - ptln(' '); - ptln(' '.$input.''); - ptln(' '); + if (is_a($setting, 'setting_fieldset')) { + // config setting group + if ($in_fieldset) { + ptln('
'.$label.'
'); + ptln(' '); + } else { + $in_fieldset = true; + } + if ($first_plugin_fieldset && substr($setting->_key, 0, 10)=='plugin'.CM_KEYMARKER) { + $this->_print_h1('plugin_settings', $this->getLang('_header_plugin')); + $first_plugin_fieldset = false; + } else if ($first_template_fieldset && substr($setting->_key, 0, 7)=='tpl'.CM_KEYMARKER) { + $this->_print_h1('template_settings', $this->getLang('_header_template')); + $first_template_fieldset = false; + } + ptln('
'); + ptln(' '.$setting->prompt($this).''); + ptln(' '); + } else { + // config settings + list($label,$input) = $setting->html($this, $this->_error); + + $class = $setting->is_default() ? ' class="default"' : ($setting->is_protected() ? ' class="protected"' : ''); + $error = $setting->error() ? ' class="value error"' : ' class="value"'; + + ptln(' '); + ptln(' '); + ptln(' '.$input.''); + ptln(' '); + } } ptln('
'.$label.'
'); + if ($in_fieldset) { + ptln('
'); + } ptln('

'); ptln(' '); @@ -204,6 +231,12 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { $this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.$key] = $value; } } + + // fill in the plugin name if missing (should exist for plugins with settings) + if (!isset($this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.'plugin_settings_name'])) { + $this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.'plugin_settings_name'] = + ucwords(str_replace('_', ' ', $plugin)).' '.$this->getLang('_plugin_sufix'); + } } closedir($dh); } @@ -219,8 +252,91 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin { $this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value; } } + + // fill in the template name if missing (should exist for templates with settings) + if (!isset($this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.'template_settings_name'])) { + $this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.'template_settings_name'] = + ucwords(str_replace('_', ' ', $tpl)).' '.$this->getLang('_template_sufix'); + } return true; } + /** + * Generates a two-level table of contents for the config plugin. + * Uses inc/parser/xhtml.php#render_TOC to format the output. + * Relies on internal data structures in the Doku_Renderer_xhtml class. + * + * @author Ben Coburn + */ + function _print_config_toc() { + // gather toc data + $toc = array('conf'=>array(), 'plugin'=>array(), 'template'=>null); + foreach($this->_config->setting as $setting) { + if (is_a($setting, 'setting_fieldset')) { + if (substr($setting->_key, 0, 10)=='plugin'.CM_KEYMARKER) { + $toc['plugin'][] = $setting; + } else if (substr($setting->_key, 0, 7)=='tpl'.CM_KEYMARKER) { + $toc['template'] = $setting; + } else { + $toc['conf'][] = $setting; + } + } + } + + // build toc list + $xhtml_toc = array(); + $xhtml_toc[] = array('hid' => 'configuration_manager', + 'title' => $this->getLang('_configuration_manager'), + 'type' => 'ul', + 'level' => 1); + $xhtml_toc[] = array('hid' => 'dokuwiki_settings', + 'title' => $this->getLang('_header_dokuwiki'), + 'type' => 'ul', + 'level' => 1); + foreach($toc['conf'] as $setting) { + $name = $setting->prompt($this); + $xhtml_toc[] = array('hid' => $setting->_key, + 'title' => $name, + 'type' => 'ul', + 'level' => 2); + } + if (!empty($toc['plugin'])) { + $xhtml_toc[] = array('hid' => 'plugin_settings', + 'title' => $this->getLang('_header_plugin'), + 'type' => 'ul', + 'level' => 1); + } + foreach($toc['plugin'] as $setting) { + $name = $setting->prompt($this); + $xhtml_toc[] = array('hid' => $setting->_key, + 'title' => $name, + 'type' => 'ul', + 'level' => 2); + } + if (isset($toc['template'])) { + $xhtml_toc[] = array('hid' => 'template_settings', + 'title' => $this->getLang('_header_template'), + 'type' => 'ul', + 'level' => 1); + $setting = $toc['template']; + $name = $setting->prompt($this); + $xhtml_toc[] = array('hid' => $setting->_key, + 'title' => $name, + 'type' => 'ul', + 'level' => 2); + } + + // use the xhtml renderer to make the toc + require_once(DOKU_INC.'inc/parser/xhtml.php'); + $r = new Doku_Renderer_xhtml; + $r->toc = $xhtml_toc; + print $r->render_TOC(); + } + + function _print_h1($id, $text) { + ptln('

'.$text.'

'); + } + + } -- cgit v1.2.3