From 9773c5edfdb8d172ce0d2bb7644b774728be894a Mon Sep 17 00:00:00 2001 From: "joe.lapp" <joe.lapp@pobox.com> Date: Sat, 17 Sep 2005 06:18:21 +0200 Subject: [PATCH] $conf['toptoclevel'] specifying topmost level of TOC Particularly useful with $conf['useheading'] darcs-hash:20050917041821-36b45-4187b687b6ade759035d0d695eb715f9192c1a7e.gz --- conf/dokuwiki.php | 1 + inc/parser/handler.php | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/conf/dokuwiki.php b/conf/dokuwiki.php index 0c5cae8c3..e9afdb2be 100644 --- a/conf/dokuwiki.php +++ b/conf/dokuwiki.php @@ -29,6 +29,7 @@ $conf['htmlok'] = 0; //may raw HTML be embedded? This may b $conf['phpok'] = 0; //may PHP code be embedded? Never do this on the internet! 0|1 $conf['dformat'] = 'Y/m/d H:i'; //dateformat accepted by PHPs date() function $conf['signature'] = ' --- //[[@MAIL@|@NAME@]] @DATE@//'; //signature see wiki:config for details +$conf['toptoclevel'] = 1; //Level starting with and below to include in AutoTOC (max. 5) $conf['maxtoclevel'] = 3; //Up to which level include into AutoTOC (max. 5) $conf['maxseclevel'] = 3; //Up to which level create editable sections (max. 5) $conf['camelcase'] = 0; //Use CamelCase for linking? (I don't like it) 0|1 diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 20a9433bd..c165e0a87 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -1489,12 +1489,16 @@ class Doku_Handler_Toc { function process($calls) { #FIXME can this be done better? - global $conf; + + global $conf; + $toplevel = $conf['toptoclevel']; // retrieve vars once to save time + $maxlevel = $conf['maxtoclevel']; foreach ( $calls as $call ) { - if ( $call[0] == 'header' && $call[1][1] <= $conf['maxtoclevel'] ) { + $level = $call[1][1]; + if ( $call[0] == 'header' && $level >= $toplevel && $level <= $maxlevel ) { $this->numHeaders++; - $this->addToToc($call); + $this->addToToc($level - $toplevel + 1, $call); } $this->calls[] = $call; } @@ -1504,9 +1508,7 @@ class Doku_Handler_Toc { return $this->calls; } - function addToToc($call) { - - $depth = $call[1][1]; + function addToToc($depth, $call) { // If it's the opening item... if ( count ( $this->toc) == 0 ) { -- GitLab