From e1b31a95036c9d14ff4b1baa752f46a228dd56e2 Mon Sep 17 00:00:00 2001
From: Ben Coburn <btcoburn@silicodon.net>
Date: Thu, 15 Feb 2007 02:53:18 +0100
Subject: [PATCH] config plugin TOC refactoring

Now uses the new toc_additem function in the Doku_Renderer_xhtml class.

darcs-hash:20070215015318-05dcb-f725b589b6ecf9b332f624f4bb9cafe7ed546172.gz
---
 lib/plugins/config/admin.php | 52 +++++++++---------------------------
 1 file changed, 13 insertions(+), 39 deletions(-)

diff --git a/lib/plugins/config/admin.php b/lib/plugins/config/admin.php
index b4c7681cf..4cf3ea9b1 100644
--- a/lib/plugins/config/admin.php
+++ b/lib/plugins/config/admin.php
@@ -299,7 +299,6 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
     /**
     * 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 <btcoburn@silicodon.net>
     */
@@ -323,59 +322,34 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
         }
       }
 
-      // 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);
+      // use the xhtml renderer to make the toc
+      require_once(DOKU_INC.'inc/parser/xhtml.php');
+      $r = new Doku_Renderer_xhtml;
+
+      // build toc
+      $r->toc_additem('configuration_manager', $this->getLang('_configuration_manager'), 1);
+      $r->toc_additem('dokuwiki_settings', $this->getLang('_header_dokuwiki'), 1);
       foreach($toc['conf'] as $setting) {
         $name = $setting->prompt($this);
-        $xhtml_toc[] = array('hid' => $setting->_key,
-            'title' => $name,
-            'type'  => 'ul',
-            'level' => 2);
+        $r->toc_additem($setting->_key, $name, 2);
       }
       if (!empty($toc['plugin'])) {
-        $xhtml_toc[] = array('hid' => 'plugin_settings',
-            'title' => $this->getLang('_header_plugin'),
-            'type'  => 'ul',
-            'level' => 1);
+        $r->toc_additem('plugin_settings', $this->getLang('_header_plugin'), 1);
       }
       foreach($toc['plugin'] as $setting) {
         $name = $setting->prompt($this);
-        $xhtml_toc[] = array('hid' => $setting->_key,
-            'title' => $name,
-            'type'  => 'ul',
-            'level' => 2);
+        $r->toc_additem($setting->_key, $name, 2);
       }
       if (isset($toc['template'])) {
-        $xhtml_toc[] = array('hid' => 'template_settings',
-            'title' => $this->getLang('_header_template'),
-            'type'  => 'ul',
-            'level' => 1);
+        $r->toc_additem('template_settings', $this->getLang('_header_template'), 1);
         $setting = $toc['template'];
         $name = $setting->prompt($this);
-        $xhtml_toc[] = array('hid' => $setting->_key,
-            'title' => $name,
-            'type'  => 'ul',
-            'level' => 2);
+        $r->toc_additem($setting->_key, $name, 2);
       }
       if ($has_undefined && $allow_debug) {
-        $xhtml_toc[] = array('hid' => 'undefined_settings',
-            'title' => $this->getLang('_header_undefined'),
-            'type'  => 'ul',
-            'level' => 1);
+        $r->toc_additem('undefined_settings', $this->getLang('_header_undefined'), 1);
       }
 
-      // 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();
     }
 
-- 
GitLab