$doShowToc = 0;
}
+ # Get all headlines for numbering them and adding funky stuff like [edit]
+ # links - this is for later, but we need the number of headlines right now
+ $numMatches = preg_match_all( "/<H([1-6])(.*?" . ">)(.*?)<\/H[1-6]>/i", $text, $matches );
+
+ # if there are fewer than 4 headlines in the article, do not show TOC
+ if( $numMatches < 4 ) {
+ $doShowToc = 0;
+ }
+
+ # if the string __FORCETOC__ (not case-sensitive) occurs in the HTML,
+ # override above conditions and always show TOC
+ $mw =& MagicWord::get( MAG_FORCETOC );
+ if ($mw->matchAndRemove( $text ) ) {
+ $doShowToc = 1;
+ }
+
+
# We need this to perform operations on the HTML
$sk =& $this->mOptions->getSkin();
- # Get all headlines for numbering them and adding funky stuff like [edit]
- # links
- preg_match_all( "/<H([1-6])(.*?" . ">)(.*?)<\/H[1-6]>/i", $text, $matches );
-
# headline counter
$headlineCount = 0;
$full .= $sk->editSectionLink(0);
}
$full .= $block;
- if( $doShowToc && $toclines>3 && !$i) {
+ if( $doShowToc && !$i) {
# Let's add a top anchor just in case we want to link to the top of the page
$full = "<a name=\"top\"></a>".$full.$toc;
}
define("MAG_IMG_WIDTH", 20);
define("MAG_IMG_CENTER", 21);
define("MAG_INT", 22);
+define("MAG_FORCETOC", 23);
$wgVariableIDs = array(
MAG_CURRENTMONTH,
# ID CASE SYNONYMS
MAG_REDIRECT => array( 0, "#redirect" ),
MAG_NOTOC => array( 0, "__NOTOC__" ),
+ MAG_FORCETOC => array( 0, "__FORCETOC__" ),
MAG_NOEDITSECTION => array( 0, "__NOEDITSECTION__" ),
MAG_START => array( 0, "__START__" ),
MAG_CURRENTMONTH => array( 1, "CURRENTMONTH" ),