From: Brion Vibber Date: Fri, 25 Mar 2005 09:35:59 +0000 (+0000) Subject: * do showtoc option via CSS hiding of toc when it's off. X-Git-Tag: 1.5.0alpha1~529 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=e69fe0c5a2497e45dde2f2d0eb7ecbc8b4dd499f;p=lhc%2Fweb%2Fwiklou.git * do showtoc option via CSS hiding of toc when it's off. This lets us use the same parser cache for either setting. --- diff --git a/includes/Parser.php b/includes/Parser.php index 99fc1886a6..060503cfcf 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -2191,7 +2191,7 @@ class Parser global $wgInputEncoding, $wgMaxTocLevel, $wgContLang, $wgLinkHolders, $wgInterwikiLinkHolders; $doNumberHeadings = $this->mOptions->getNumberHeadings(); - $doShowToc = $this->mOptions->getShowToc(); + $doShowToc = true; $forceTocHere = false; if( !$this->mTitle->userCanEdit() ) { $showEditLink = 0; @@ -2210,7 +2210,7 @@ class Parser # do not add TOC $mw =& MagicWord::get( MAG_NOTOC ); if( $mw->matchAndRemove( $text ) ) { - $doShowToc = 0; + $doShowToc = false; } # Get all headlines for numbering them and adding funky stuff like [edit] @@ -2219,7 +2219,7 @@ class Parser # if there are fewer than 4 headlines in the article, do not show TOC if( $numMatches < 4 ) { - $doShowToc = 0; + $doShowToc = false; } # if the string __TOC__ (not case-sensitive) occurs in the HTML, @@ -2227,20 +2227,20 @@ class Parser $mw =& MagicWord::get( MAG_TOC ); if($mw->match( $text ) ) { - $doShowToc = 1; + $doShowToc = true; $forceTocHere = true; } else { # if the string __FORCETOC__ (not case-sensitive) occurs in the HTML, # override above conditions and always show TOC above first header $mw =& MagicWord::get( MAG_FORCETOC ); if ($mw->matchAndRemove( $text ) ) { - $doShowToc = 1; + $doShowToc = true; } } # Never ever show TOC if no headers if( $numMatches < 1 ) { - $doShowToc = 0; + $doShowToc = false; } # We need this to perform operations on the HTML @@ -2990,7 +2990,6 @@ class ParserOptions var $mEditSection; # Create "edit section" links var $mEditSectionOnRightClick; # Generate JavaScript to edit section on right click var $mNumberHeadings; # Automatically number headings - var $mShowToc; # Show table of contents function getUseTeX() { return $this->mUseTeX; } function getUseDynamicDates() { return $this->mUseDynamicDates; } @@ -3001,7 +3000,6 @@ class ParserOptions function getEditSection() { return $this->mEditSection; } function getEditSectionOnRightClick() { return $this->mEditSectionOnRightClick; } function getNumberHeadings() { return $this->mNumberHeadings; } - function getShowToc() { return $this->mShowToc; } function setUseTeX( $x ) { return wfSetVar( $this->mUseTeX, $x ); } function setUseDynamicDates( $x ) { return wfSetVar( $this->mUseDynamicDates, $x ); } @@ -3011,7 +3009,6 @@ class ParserOptions function setEditSection( $x ) { return wfSetVar( $this->mEditSection, $x ); } function setEditSectionOnRightClick( $x ) { return wfSetVar( $this->mEditSectionOnRightClick, $x ); } function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings, $x ); } - function setShowToc( $x ) { return wfSetVar( $this->mShowToc, $x ); } function setSkin( &$x ) { $this->mSkin =& $x; } @@ -3048,7 +3045,6 @@ class ParserOptions $this->mEditSection = $user->getOption( 'editsection' ); $this->mEditSectionOnRightClick = $user->getOption( 'editsectiononrightclick' ); $this->mNumberHeadings = $user->getOption( 'numberheadings' ); - $this->mShowToc = $user->getOption( 'showtoc' ); wfProfileOut( $fname ); } } diff --git a/includes/Skin.php b/includes/Skin.php index ff3f92f2d1..9d63c40d02 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -299,6 +299,9 @@ END; if( $wgUser->getOption( 'justify' ) ) { $s .= "#article { text-align: justify; }\n"; } + if( !$wgUser->getOption( 'showtoc' ) ) { + $s .= "#toc { display: none; }\n"; + } return $s; } diff --git a/includes/User.php b/includes/User.php index 2277171ff5..13621d48b9 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1120,7 +1120,6 @@ class User { $confstr .= '!' . $this->getOption( 'stubthreshold' ); $confstr .= '!' . $this->getOption( 'editsection' ); $confstr .= '!' . $this->getOption( 'editsectiononrightclick' ); - $confstr .= '!' . $this->getOption( 'showtoc' ); $confstr .= '!' . $this->getOption( 'date' ); $confstr .= '!' . $this->getOption( 'numberheadings' ); $confstr .= '!' . $this->getOption( 'language' );