r21725 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21724‎ | r21725 | r21726 >
Date:19:51, 30 April 2007
Author:brion
Status:old
Tags:
Comment:
* (bug 6204) Fixes for indentation with $wgMaxTocLevel:
- don't emit too many list close tags after an invisible header
- don't emit too many final list close tags if last header is invisible
- don't emit TOC when there are no visible headers
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -3453,17 +3453,13 @@
34543454 $enoughToc = true;
34553455 }
34563456
3457 - # Never ever show TOC if no headers
3458 - if( $numMatches < 1 ) {
3459 - $enoughToc = false;
3460 - }
3461 -
34623457 # We need this to perform operations on the HTML
34633458 $sk = $this->mOptions->getSkin();
34643459
34653460 # headline counter
34663461 $headlineCount = 0;
34673462 $sectionCount = 0; # headlineCount excluding template sections
 3463+ $numVisible = 0;
34683464
34693465 # Ugh .. the TOC should have neat indentation levels which can be
34703466 # passed to the skin functions. These are determined here
@@ -3493,7 +3489,6 @@
34943490
34953491 if( $toclevel ) {
34963492 $prevlevel = $level;
3497 - $prevtoclevel = $toclevel;
34983493 }
34993494 $level = $matches[1][$headlineCount];
35003495
@@ -3504,7 +3499,9 @@
35053500 $toclevel++;
35063501 $sublevelCount[$toclevel] = 0;
35073502 if( $toclevel<$wgMaxTocLevel ) {
 3503+ $prevtoclevel = $toclevel;
35083504 $toc .= $sk->tocIndent();
 3505+ $numVisible++;
35093506 }
35103507 }
35113508 elseif ( $level < $prevlevel && $toclevel > 1 ) {
@@ -3611,9 +3608,14 @@
36123609 $sectionCount++;
36133610 }
36143611
 3612+ # Never ever show TOC if no headers
 3613+ if( $numVisible < 1 ) {
 3614+ $enoughToc = false;
 3615+ }
 3616+
36153617 if( $enoughToc ) {
3616 - if( $toclevel<$wgMaxTocLevel ) {
3617 - $toc .= $sk->tocUnindent( $toclevel - 1 );
 3618+ if( $prevtoclevel > 0 && $prevtoclevel < $wgMaxTocLevel ) {
 3619+ $toc .= $sk->tocUnindent( $prevtoclevel - 1 );
36183620 }
36193621 $toc = $sk->tocList( $toc );
36203622 }
Index: trunk/phase3/RELEASE-NOTES
@@ -365,7 +365,12 @@
366366 * (bug 8602) Converted Special:Contributions to use an IndexPager. The
367367 interpretation of the offset parameter has changed, and the go parameter
368368 has been removed.
 369+* (bug 6204) Fixes for indentation with $wgMaxTocLevel:
 370+ - don't emit too many list close tags after an invisible header
 371+ - don't emit too many final list close tags if last header is invisible
 372+ - don't emit TOC when there are no visible headers
369373
 374+
370375 == Maintenance ==
371376
372377 * New script maintenance/language/checkExtensioni18n.php used to check i18n

Follow-up revisions

RevisionCommit summaryAuthorDate
r21814Fix #9764: level indentation of toc is incorrect....hashar19:09, 2 May 2007
r21829Revert r21725 (bug 6204) due to regressions (bug 9764). Will leave it to be w...brion17:14, 3 May 2007
r21833Parser test for bug #6204 : TOC not properly rendered when using $wgMaxTocLevelhashar17:49, 3 May 2007
r25291Revert r25260; breaks several parser tests cases, seems to be borking up sect...brion16:01, 29 August 2007
r25303Merged revisions 25215-25302 via svnmerge from...david07:10, 30 August 2007
r38208Revert r38196, r38204 -- "(bugs 6089, 13079) Show edit section links for tran...brion23:56, 29 July 2008