summaryrefslogtreecommitdiff
path: root/lib/plugins
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2007-08-05 15:24:05 +0200
committerAndreas Gohr <andi@splitbrain.org>2007-08-05 15:24:05 +0200
commitb8595a660455f6778266779753c6238127664a28 (patch)
tree29e0a132e510d6b98f1985b9f4e876a5351d3e64 /lib/plugins
parent71f7bde7834ef576e5312e68d5e739bfe70afbcb (diff)
downloadrpg-b8595a660455f6778266779753c6238127664a28.tar.gz
rpg-b8595a660455f6778266779753c6238127664a28.tar.bz2
separated TOC from page
This patch introduces a tpl_toc() function which can be used to freely place the Table of Contents in a template. When used, tpl_content should be called with a parameter of false to supress the automatic TOC placement. Note: if tpl_toc() us run *before* tpl_content(), TOCs will not work in the preview. A work around is to run tpl_content() in a output buffer first. This patch also adds a getTOC() function for admin plugins which allows plugin authors to put create their own TOC which will be placed correctly in the template. A convenience function html_mktocitem() is available. The config manager was adjusted to make ue of this new feature, but some bugs might remain. darcs-hash:20070805132405-7ad00-77d2c3cdf66cc62b2d408cc6580f938636a109af.gz
Diffstat (limited to 'lib/plugins')
-rw-r--r--lib/plugins/admin.php4
-rw-r--r--lib/plugins/config/admin.php49
2 files changed, 28 insertions, 25 deletions
diff --git a/lib/plugins/admin.php b/lib/plugins/admin.php
index 00a07a054..2eeda3f7b 100644
--- a/lib/plugins/admin.php
+++ b/lib/plugins/admin.php
@@ -41,5 +41,9 @@ class DokuWiki_Admin_Plugin extends DokuWiki_Plugin {
function forAdminOnly() {
return true;
}
+
+ function getTOC(){
+ return array();
+ }
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
diff --git a/lib/plugins/config/admin.php b/lib/plugins/config/admin.php
index 1e12df53a..26880b390 100644
--- a/lib/plugins/config/admin.php
+++ b/lib/plugins/config/admin.php
@@ -32,7 +32,7 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
var $_changed = false; // set to true if configuration has altered
var $_error = false;
var $_session_started = false;
- var $_localised_prompts = false;
+ var $_localised_prompts = false;
/**
* return some info
@@ -42,7 +42,7 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
return array(
'author' => 'Christopher Smith',
'email' => 'chris@jalakai.co.uk',
- 'date' => '2006-01-24',
+ 'date' => '2007-08-05',
'name' => 'Configuration Manager',
'desc' => "Manage Dokuwiki's Configuration Settings",
'url' => 'http://wiki.splitbrain.org/plugin:config',
@@ -99,7 +99,6 @@ 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('<div id="config__manager">');
@@ -277,10 +276,10 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
}
closedir($dh);
}
-
+
// the same for the active template
$tpl = $conf['template'];
-
+
if (@file_exists(DOKU_TPLINC.$enlangfile)){
$lang = array();
@include(DOKU_TPLINC.$enlangfile);
@@ -295,17 +294,19 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
$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.
- *
- * @author Ben Coburn <btcoburn@silicodon.net>
- */
- function _print_config_toc() {
+ * Generates a two-level table of contents for the config plugin.
+ *
+ * @author Ben Coburn <btcoburn@silicodon.net>
+ */
+ function getTOC() {
+ if (is_null($this->_config)) { $this->_config = new configuration($this->_file); }
+ $this->setupLocale(true);
+
$allow_debug = $GLOBALS['conf']['allowdebug']; // avoid global $conf; here.
// gather toc data
@@ -325,35 +326,33 @@ class admin_plugin_config extends DokuWiki_Admin_Plugin {
}
}
- // 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);
+ $t = array();
+
+ $t[] = html_mktocitem('configuration_manager', $this->getLang('_configuration_manager'), 1);
+ $t[] = html_mktocitem('dokuwiki_settings', $this->getLang('_header_dokuwiki'), 1);
foreach($toc['conf'] as $setting) {
$name = $setting->prompt($this);
- $r->toc_additem($setting->_key, $name, 2);
+ $t[] = html_mktocitem($setting->_key, $name, 2);
}
if (!empty($toc['plugin'])) {
- $r->toc_additem('plugin_settings', $this->getLang('_header_plugin'), 1);
+ $t[] = html_mktocitem('plugin_settings', $this->getLang('_header_plugin'), 1);
}
foreach($toc['plugin'] as $setting) {
$name = $setting->prompt($this);
- $r->toc_additem($setting->_key, $name, 2);
+ $t[] = html_mktocitem($setting->_key, $name, 2);
}
if (isset($toc['template'])) {
- $r->toc_additem('template_settings', $this->getLang('_header_template'), 1);
+ $t[] = html_mktocitem('template_settings', $this->getLang('_header_template'), 1);
$setting = $toc['template'];
$name = $setting->prompt($this);
- $r->toc_additem($setting->_key, $name, 2);
+ $t[] = html_mktocitem($setting->_key, $name, 2);
}
if ($has_undefined && $allow_debug) {
- $r->toc_additem('undefined_settings', $this->getLang('_header_undefined'), 1);
+ $t[] = html_mktocitem('undefined_settings', $this->getLang('_header_undefined'), 1);
}
- print $r->render_TOC();
+ return $t;
}
function _print_h1($id, $text) {