$action = $wgRequest->getText( 'action', 'view' );
$section = $wgRequest->getText( 'section' );
$sectiontitle = $wgRequest->getText( 'sectiontitle' );
+ $oid = $wgRequest->getInt( 'oldid' );
if ( 0 == $this->getID() ) {
if ( "edit" == $action ) {
if( $wgRequest->getText( 'collapse' ) == 'false') {
$collapse=false;
}
+ if($oid) { $collapse=false; }
$wgOut->setCollapse($collapse);
# check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
# 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=="") {
- $secs =
- preg_split(
- "/(^=+.*?=+|^<h[1-6].*?" . ">.*?<\/h[1-6].*?" . ">)/mi",
- $this->mContent, -1,
- PREG_SPLIT_DELIM_CAPTURE);
- $wgOut->setToc(Parser::getTocFromSource($this->mContent));
- $rv=$secs[0];
+ $rv=$this->getSection($this->mContent,0,"");
+ $wgOut->setToc(Parser::getTocFromSource($this->mContent));
if($anontalk) { $rv = $rv . "\n" . wfMsg("anontalkpage"); }
return $rv;
}
}
$text=join("",$secs);
# reinsert the stuff that we stripped out earlier
- $text=$parser->unstrip($text,$striparray,true);
+ $text=$parser->unstrip($text,$striparray);
}
}
if ($collapsedtoc && !$i) {
$full = $full.$collapsedtoc;
}
+ $wgOut->setToc("");
if( !empty( $head[$i] ) ) {
$full .= $head[$i];
/* Generates a HTML-formatted table of contents which links to individual sections
from the wikisource. Used for collapsing long pages.
*/
- /* static */ function getTocFromSource( $text ) {
- #$numMatches = preg_match_all( "/<H([1-6])(.*?" . ">)(.*?)<\/H[1-6]>/i", $text, $matches );
+ /* static */ function getTocFromSource( $text ) {
global $wgUser,$wgInputEncoding,$wgTitle,$wgOut,$wgParser;
$sk = $wgUser->getSkin();
$combined_html=$myout->getText();
$headlines=array();
$headlines=explode("!@@@!",$combined_html);
+
# headline counter
$headlineCount = 0;
$toclevel = 0;
$level = 0;
$prevlevel = 0;
foreach( $headlines as $headline ) {
+ $headline=trim($headline);
$numbering = "";
if( $level ) {
$prevlevel = $level;
$tocline = $numbering . " " . $tocline;
# Create the anchor for linking from the TOC to the section
- $anchor = $canonized_headline;
+ $anchor = trim($canonized_headline);
if($refcount[$headlineCount] > 1 ) {
$anchor .= "_" . $refcount[$headlineCount];
"cols" => 80, "rows" => 25, "searchlimit" => 20,
"contextlines" => 5, "contextchars" => 50,
"skin" => $wgDefaultSkin, "math" => 1, "rcdays" => 7, "rclimit" => 50,
- "highlightbroken" => 1, "stubthreshold" => 0, "collapsethreshold" => 30000,
+ "highlightbroken" => 1, "stubthreshold" => 0, "collapsethreshold" => 5000,
"previewontop" => 1, "editsection"=>1,"editsectiononrightclick"=>0, "showtoc"=>1,
"showtoolbar" =>1,
"date" => 0