From: Roan Kattouw Date: Sat, 20 Jun 2009 21:47:10 +0000 (+0000) Subject: Core changes for NavigableTOC extension: X-Git-Tag: 1.31.0-rc.0~41269 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=ae130186e80fb2734b4a34318cf509d5eb14cd12;p=lhc%2Fweb%2Fwiklou.git Core changes for NavigableTOC extension: * Add TOC HTML to ParserOutput * Add class tocsection-$section to
  • elements in the TOC representing sections in the current page (as opposed to transcluded sections) --- diff --git a/includes/Linker.php b/includes/Linker.php index 2b6e674620..0f97198cb7 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1142,8 +1142,11 @@ class Linker { /** * parameter level defines if we are on an indentation level */ - function tocLine( $anchor, $tocline, $tocnumber, $level ) { - return "\n
  • ' . $tocnumber . ' ' . $tocline . ''; diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index a0e0a2e5fd..5fe307dc51 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3647,7 +3647,8 @@ class Parser $legacyAnchor .= '_' . $refers[$legacyArrayKey]; } if( $enoughToc && ( !isset($wgMaxTocLevel) || $toclevel<$wgMaxTocLevel ) ) { - $toc .= $sk->tocLine($anchor, $tocline, $numbering, $toclevel); + $toc .= $sk->tocLine($anchor, $tocline, + $numbering, $toclevel, ($isTemplate ? false : $sectionIndex)); # Find the DOM node for this header while ( $node && !$isTemplate ) { @@ -3703,6 +3704,8 @@ class Parser } $toc = $sk->tocList( $toc ); } + + $this->mOutput->setTOCHTML( $toc ); # split up and insert constructed headlines diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index 22c1dfba2a..46ae1a7fe8 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -24,7 +24,8 @@ class ParserOutput $mOutputHooks = array(), # Hook tags as per $wgParserOutputHooks $mWarnings = array(), # Warning text to be returned to the user. Wikitext formatted, in the key only $mSections = array(), # Table of contents - $mProperties = array(); # Name/value pairs to be cached in the DB + $mProperties = array(), # Name/value pairs to be cached in the DB + $mTOCHTML = ''; # HTML of the TOC private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change. /** @@ -58,6 +59,7 @@ class ParserOutput function getOutputHooks() { return (array)$this->mOutputHooks; } function getWarnings() { return array_keys( $this->mWarnings ); } function getIndexPolicy() { return $this->mIndexPolicy; } + function getTOCHTML() { return $this->mTOCHTML; } function containsOldMagic() { return $this->mContainsOldMagic; } function setText( $text ) { return wfSetVar( $this->mText, $text ); } @@ -68,6 +70,7 @@ class ParserOutput function setTitleText( $t ) { return wfSetVar( $this->mTitleText, $t ); } function setSections( $toc ) { return wfSetVar( $this->mSections, $toc ); } function setIndexPolicy( $policy ) { return wfSetVar( $this->mIndexPolicy, $policy ); } + function setTOCHTML( $tochtml ) { return wfSetVar( $this->mTOCHTML, $tochtml ); } function addCategory( $c, $sort ) { $this->mCategories[$c] = $sort; } function addLanguageLink( $t ) { $this->mLanguageLinks[] = $t; }