# When a page is viewed in collapsed mode, only the intro section and, for
# pages with multiple sections, a table of contents are shown.
if($collapse && $action=="view" && $section=="") {
- $rv=$this->getSection($this->mContent,0,"");
+ $rv=$this->getSection($this->mContent,0,$sectiontitle);
$wgOut->setToc(Parser::getTocFromSource($this->mContent));
if($anontalk) { $rv = $rv . "\n" . wfMsg("anontalkpage"); }
+ wfProfileOut( $fname );
return $rv;
}
# $section contains a section number and is used for section viewing and editing.
return $t ;
}
- function internalParse( $text, $linestart, $args = array() )
+ // set isMain=false if you call from a template etc. and don't want to do stuff
+ // like TOC insertion for that content
+ function internalParse( $text, $linestart, $args = array(), $isMain=true )
{
$fname = "Parser::internalParse";
wfProfileIn( $fname );
$text = $this->replaceExternalLinks( $text );
$text = $this->doTokenizedParser ( $text );
$text = $this->doTableStuff ( $text ) ;
- $text = $this->formatHeadings( $text );
+ $text = $this->formatHeadings( $text, $isMain );
$sk =& $this->mOptions->getSkin();
$text = $sk->transformContent( $text );
# Run full parser on the included text
$text = $this->strip( $text, $this->mStripState );
- $text = $this->internalParse( $text, (bool)$newline, $assocArgs );
+ $text = $this->internalParse( $text, (bool)$newline, $assocArgs, false );
if(!empty($newline)) $text = "\n".$text;
# Add the result to the strip state for re-inclusion after
*
*/
- /* private */ function formatHeadings( $text )
+ /* private */ function formatHeadings( $text, $isMain=true )
{
global $wgInputEncoding,$wgRequest,$wgOut;
# from the wikisource is stored in the title object.
# This TOC is now fetched and inserted here if it exists.
$collapsedtoc=$wgOut->getToc();
- if ($collapsedtoc && !$i) {
+ if ($collapsedtoc && !$i && $isMain) {
$full = $full.$collapsedtoc;
- }
- $wgOut->setToc("");
+ }
if( !empty( $head[$i] ) ) {
$full .= $head[$i];