r7865 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r7864‎ | r7865 | r7866 >
Date:09:35, 25 March 2005
Author:vibber
Status:old
Tags:
Comment:
* do showtoc option via CSS hiding of toc when it's off.
This lets us use the same parser cache for either setting.
Modified paths:
  • /trunk/phase3/includes/Parser.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -1120,7 +1120,6 @@
11211121 $confstr .= '!' . $this->getOption( 'stubthreshold' );
11221122 $confstr .= '!' . $this->getOption( 'editsection' );
11231123 $confstr .= '!' . $this->getOption( 'editsectiononrightclick' );
1124 - $confstr .= '!' . $this->getOption( 'showtoc' );
11251124 $confstr .= '!' . $this->getOption( 'date' );
11261125 $confstr .= '!' . $this->getOption( 'numberheadings' );
11271126 $confstr .= '!' . $this->getOption( 'language' );
Index: trunk/phase3/includes/Parser.php
@@ -2191,7 +2191,7 @@
21922192 global $wgInputEncoding, $wgMaxTocLevel, $wgContLang, $wgLinkHolders, $wgInterwikiLinkHolders;
21932193
21942194 $doNumberHeadings = $this->mOptions->getNumberHeadings();
2195 - $doShowToc = $this->mOptions->getShowToc();
 2195+ $doShowToc = true;
21962196 $forceTocHere = false;
21972197 if( !$this->mTitle->userCanEdit() ) {
21982198 $showEditLink = 0;
@@ -2210,7 +2210,7 @@
22112211 # do not add TOC
22122212 $mw =& MagicWord::get( MAG_NOTOC );
22132213 if( $mw->matchAndRemove( $text ) ) {
2214 - $doShowToc = 0;
 2214+ $doShowToc = false;
22152215 }
22162216
22172217 # Get all headlines for numbering them and adding funky stuff like [edit]
@@ -2219,7 +2219,7 @@
22202220
22212221 # if there are fewer than 4 headlines in the article, do not show TOC
22222222 if( $numMatches < 4 ) {
2223 - $doShowToc = 0;
 2223+ $doShowToc = false;
22242224 }
22252225
22262226 # if the string __TOC__ (not case-sensitive) occurs in the HTML,
@@ -2227,20 +2227,20 @@
22282228
22292229 $mw =& MagicWord::get( MAG_TOC );
22302230 if($mw->match( $text ) ) {
2231 - $doShowToc = 1;
 2231+ $doShowToc = true;
22322232 $forceTocHere = true;
22332233 } else {
22342234 # if the string __FORCETOC__ (not case-sensitive) occurs in the HTML,
22352235 # override above conditions and always show TOC above first header
22362236 $mw =& MagicWord::get( MAG_FORCETOC );
22372237 if ($mw->matchAndRemove( $text ) ) {
2238 - $doShowToc = 1;
 2238+ $doShowToc = true;
22392239 }
22402240 }
22412241
22422242 # Never ever show TOC if no headers
22432243 if( $numMatches < 1 ) {
2244 - $doShowToc = 0;
 2244+ $doShowToc = false;
22452245 }
22462246
22472247 # We need this to perform operations on the HTML
@@ -2990,7 +2990,6 @@
29912991 var $mEditSection; # Create "edit section" links
29922992 var $mEditSectionOnRightClick; # Generate JavaScript to edit section on right click
29932993 var $mNumberHeadings; # Automatically number headings
2994 - var $mShowToc; # Show table of contents
29952994
29962995 function getUseTeX() { return $this->mUseTeX; }
29972996 function getUseDynamicDates() { return $this->mUseDynamicDates; }
@@ -3001,7 +3000,6 @@
30023001 function getEditSection() { return $this->mEditSection; }
30033002 function getEditSectionOnRightClick() { return $this->mEditSectionOnRightClick; }
30043003 function getNumberHeadings() { return $this->mNumberHeadings; }
3005 - function getShowToc() { return $this->mShowToc; }
30063004
30073005 function setUseTeX( $x ) { return wfSetVar( $this->mUseTeX, $x ); }
30083006 function setUseDynamicDates( $x ) { return wfSetVar( $this->mUseDynamicDates, $x ); }
@@ -3011,7 +3009,6 @@
30123010 function setEditSection( $x ) { return wfSetVar( $this->mEditSection, $x ); }
30133011 function setEditSectionOnRightClick( $x ) { return wfSetVar( $this->mEditSectionOnRightClick, $x ); }
30143012 function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings, $x ); }
3015 - function setShowToc( $x ) { return wfSetVar( $this->mShowToc, $x ); }
30163013
30173014 function setSkin( &$x ) { $this->mSkin =& $x; }
30183015
@@ -3048,7 +3045,6 @@
30493046 $this->mEditSection = $user->getOption( 'editsection' );
30503047 $this->mEditSectionOnRightClick = $user->getOption( 'editsectiononrightclick' );
30513048 $this->mNumberHeadings = $user->getOption( 'numberheadings' );
3052 - $this->mShowToc = $user->getOption( 'showtoc' );
30533049 wfProfileOut( $fname );
30543050 }
30553051 }
Index: trunk/phase3/includes/Skin.php
@@ -299,6 +299,9 @@
300300 if( $wgUser->getOption( 'justify' ) ) {
301301 $s .= "#article { text-align: justify; }\n";
302302 }
 303+ if( !$wgUser->getOption( 'showtoc' ) ) {
 304+ $s .= "#toc { display: none; }\n";
 305+ }
303306 return $s;
304307 }
305308

Status & tagging log