Automatic or manual collapsing and expanding of long pages.
Pages can be collapsed automatically according to a size threshold
set in the user preferences. Pages can be collapsed manually by clicking
the "Collapse" link in the TOC.
When a page is collapsed, only the intro & TOC are displayed. The
individual TOC lines link to section views, which can be individually edited
(classic section editing).
Section editing/viewing behavior has also been improved. When a section
with subsections is viewed or edited, all subsections are also loaded.
Known issues:
- After saving a section, we return to the full article view
rather than the section view, even if we previously were in section view
mode.
- Should work with Standard and Monobook, not tested with Cologne Blue yet.
- In Monobook, no backlink to the mother article is shown during section
viewing (Gabriel, can you fix that?)
# Return the text of this revision
function getContent( $noredir )
{
- global $wgRequest;
+ global $wgRequest,$wgUser,$wgOut;
+
+ $fname = "Article::getContent";
+ wfProfileIn( $fname );
# Get variables from query string :P
$action = $wgRequest->getText( 'action', 'view' );
$section = $wgRequest->getText( 'section' );
-
- $fname = "Article::getContent";
- wfProfileIn( $fname );
+ $sectiontitle = $wgRequest->getText( 'sectiontitle' );
if ( 0 == $this->getID() ) {
if ( "edit" == $action ) {
}
wfProfileOut( $fname );
return wfMsg( "noarticletext" );
- } else {
+ } else {
$this->loadContent( $noredir );
-
- if(
- # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
- ( $this->mTitle->getNamespace() == Namespace::getTalk( Namespace::getUser()) ) &&
- preg_match("/^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/",$this->mTitle->getText()) &&
- $action=="view"
- )
- {
- wfProfileOut( $fname );
- return $this->mContent . "\n" .wfMsg("anontalkpagetext"); }
- else {
- if($action=="edit") {
- if($section!="") {
- if($section=="new") {
- wfProfileOut( $fname );
- return "";
- }
-
- # strip NOWIKI etc. to avoid confusion (true-parameter causes HTML
- # comments to be stripped as well)
- $striparray=array();
- $parser=new Parser();
- $parser->mOutputType=OT_WIKI;
- $striptext=$parser->strip($this->mContent, $striparray, true);
-
- # now that we can be sure that no pseudo-sections are in the source,
- # split it up by section
- $secs =
- preg_split(
- "/(^=+.*?=+|^<h[1-6].*?" . ">.*?<\/h[1-6].*?" . ">)/mi",
- $striptext, -1,
- PREG_SPLIT_DELIM_CAPTURE);
-
- if($section==0) {
- $rv=$secs[0];
- } else {
- $rv=$secs[$section*2-1] . $secs[$section*2];
- }
-
- # reinsert stripped tags
- $rv=$parser->unstrip($rv,$striparray);
- $rv=trim($rv);
- wfProfileOut( $fname );
- return $rv;
- }
+
+ # size threshold at which pages are automatically collapsed
+ $collapsethreshold=$wgUser->getOption( "collapsethreshold" );
+ if($collapsethreshold && strlen($this->mContent)>=$collapsethreshold) {
+ $collapse=true;
+ } else {
+ $collapse=false;
+ }
+ #override user pref is expansion is explicitly requested
+ if($wgRequest->getBool('collapse')) { $collapse=true; }
+ if( $wgRequest->getText( 'collapse' ) == 'false') {
+ $collapse=false;
+ }
+ $wgOut->setCollapse($collapse);
+
+ # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
+ # if so, a "This is an anonymous talk page .." message must be appended to the
+ # displayed page (but not during editing!).
+ $anontalk=false;
+ if( ( $this->mTitle->getNamespace() == Namespace::getTalk( Namespace::getUser()) ) &&
+ preg_match("/^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/",$this->mTitle->getText()) &&
+ $action=="view"
+ ) { $anontalk=true; }
+
+ # 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];
+ if($anontalk) { $rv = $rv . "\n" . wfMsg("anontalkpage"); }
+ return $rv;
+ }
+ # $section contains a section number and is used for section viewing and editing.
+ if($section!="") {
+ if($section=="new" && $action=="edit") {
+ wfProfileOut( $fname );
+ return "";
}
- wfProfileOut( $fname );
- return $this->mContent;
+ $rv=$this->getSection($this->mContent,$section,$sectiontitle);
+ if($anontalk) { $rv = $rv . "\n" . wfMsg("anontalkpage"); }
+ wfProfileOut( $fname );
+ return $rv;
}
}
+
+ if($anontalk) { return $this->mContent . "\n" . wfMsg("anontalkpage"); }
+ wfProfileOut( $fname );
+ return $this->mContent;
+
}
+ # This function returns the text of a section, specified by a number ($section)
+ # and a section title ($sectiontitle). A section is text under a heading like
+ # == Heading == or <h1>Heading</h1>, or the first section before any such
+ # heading (section 0).
+ #
+ # If a section contains subsections, these are also returned.
+ #
+ function getSection($text,$section,$sectiontitle) {
+
+ # strip NOWIKI etc. to avoid confusion (true-parameter causes HTML
+ # comments to be stripped as well)
+ $striparray=array();
+ $parser=new Parser();
+ $parser->mOutputType=OT_WIKI;
+ $striptext=$parser->strip($text, $striparray, true);
+
+ # now that we can be sure that no pseudo-sections are in the source,
+ # split it up by section
+ $secs =
+ preg_split(
+ "/(^=+.*?=+|^<h[1-6].*?" . ">.*?<\/h[1-6].*?" . ">)/mi",
+ $striptext, -1,
+ PREG_SPLIT_DELIM_CAPTURE);
+ if($section==0) {
+ $rv=$secs[0];
+ } else {
+ $headline=$secs[$section*2-1];
+ preg_match( "/^(=+).*?=+|^<h([1-6]).*?>.*?<\/h[1-6].*?>/mi",$headline,$matches);
+ $hlevel=$matches[1];
+
+ # translate wiki heading into level
+ if(strpos($hlevel,"=")!==false) {
+ $hlevel=strlen($hlevel);
+ }
+
+ $rv=$headline. $secs[$section*2];
+ $count=$section+1;
+
+ $break=false;
+ while(!empty($secs[$count*2-1]) && !$break) {
+
+ $subheadline=$secs[$count*2-1];
+ preg_match( "/^(=+).*?=+|^<h([1-6]).*?>.*?<\/h[1-6].*?>/mi",$subheadline,$matches);
+ $subhlevel=$matches[1];
+ if(strpos($subhlevel,"=")!==false) {
+ $subhlevel=strlen($subhlevel);
+ }
+ if($subhlevel > $hlevel) {
+ $rv.=$subheadline.$secs[$count*2];
+ }
+ if($subhlevel <= $hlevel) {
+ $break=true;
+ }
+ $count++;
+
+ }
+ }
+ # reinsert stripped tags
+ $rv=$parser->unstrip($rv,$striparray);
+ $rv=trim($rv);
+ return $rv;
+
+ }
+
+
# Load the revision (including cur_text) into this object
function loadContent( $noredir = false )
{
# If we got diff and oldid in the query, we want to see a
# diff page instead of the article.
- if ( !is_null( $diff ) ) {
+ if ( !is_null( $diff ) ) {
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
$de = new DifferenceEngine( intval($oldid), intval($diff) );
$de->showDiffPage();
/* Side effects: loads last edit */
function getTextOfLastEditWithSectionReplacedOrAdded($section, $text, $summary = ""){
$this->loadLastEdit();
- $oldtext = $this->getContent( true );
+ $oldtext = $this->getContent( true );
if ($section != "") {
if($section=="new") {
if($summary) $subject="== {$summary} ==\n\n";
# now that we can be sure that no pseudo-sections are in the source,
# split it up
+ # Unfortunately we can't simply do a preg_replace because that might
+ # replace the wrong section, so we have to use the section counter instead
$secs=preg_split("/(^=+.*?=+|^<h[1-6].*?" . ">.*?<\/h[1-6].*?" . ">)/mi",
$oldtext,-1,PREG_SPLIT_DELIM_CAPTURE);
$secs[$section*2]=$text."\n\n"; // replace with edited
- if($section) { $secs[$section*2-1]=""; } // erase old headline
+
+ # section 0 is top (intro) section
+ if($section!=0) {
+
+ # headline of old section - we need to go through this section
+ # to determine if there are any subsections that now need to
+ # be erased, as the mother section has been replaced with
+ # the text of all subsections.
+ $headline=$secs[$section*2-1];
+ preg_match( "/^(=+).*?=+|^<h([1-6]).*?>.*?<\/h[1-6].*?>/mi",$headline,$matches);
+ $hlevel=$matches[1];
+
+ # determine headline level for wikimarkup headings
+ if(strpos($hlevel,"=")!==false) {
+ $hlevel=strlen($hlevel);
+ }
+
+ $secs[$section*2-1]=""; // erase old headline
+ $count=$section+1;
+ $break=false;
+ while(!empty($secs[$count*2-1]) && !$break) {
+
+ $subheadline=$secs[$count*2-1];
+ preg_match(
+ "/^(=+).*?=+|^<h([1-6]).*?>.*?<\/h[1-6].*?>/mi",$subheadline,$matches);
+ $subhlevel=$matches[1];
+ if(strpos($subhlevel,"=")!==false) {
+ $subhlevel=strlen($subhlevel);
+ }
+ if($subhlevel > $hlevel) {
+ // erase old subsections
+ $secs[$count*2-1]="";
+ $secs[$count*2]="";
+ }
+ if($subhlevel <= $hlevel) {
+ $break=true;
+ }
+ $count++;
+
+ }
+
+ }
$text=join("",$secs);
-
# reinsert the stuff that we stripped out earlier
- $text=$parser->unstrip($text,$striparray,true);
+ $text=$parser->unstrip($text,$striparray,true);
}
+
}
return $text;
}
return;
else
$isConflict = true;
- }
+ }
}
# First time through: get contents, set time for conflict
# checking, etc.
var $mParserOptions;
var $mShowFeedLinks = false;
var $mEnableClientCache = true;
+ var $mToc; # Table of contents for collapsed pages (in HTML)
+ var $mCollapse = false; # Collapse output? (Set in Article.php)
function OutputPage()
{
$this->mContainsOldMagic = $this->mContainsNewMagic = 0;
$this->mParserOptions = ParserOptions::newFromUser( $temp = NULL );
$this->mSquidMaxage = 0;
+ $this->mToc='';
}
function addHeader( $name, $val ) { array_push( $this->mHeaders, "$name: $val" ) ; }
# $ret .= "<!--[if gte IE 5.5000]><script type='text/javascript' src='$fix'></script><![endif]-->";
return $ret;
}
+
+ function setToc($toc) {
+
+ $this->mToc=$toc;
+
+ }
+
+ function getToc() {
+
+ return $this->mToc;
+
+ }
+
+ function setCollapse($collapse) {
+
+ $this->mCollapse=$collapse;
+
+ }
+
+ function getCollapse() {
+
+ return $this->mCollapse;
+
+ }
}
?>
/* private */ function formatHeadings( $text )
{
- global $wgInputEncoding;
+ global $wgInputEncoding,$wgRequest,$wgOut;
+ $startsection=$wgRequest->getVal('section');
+ if($startsection) { $startsection--;}
$doNumberHeadings = $this->mOptions->getNumberHeadings();
$doShowToc = $this->mOptions->getShowToc();
if( !$this->mTitle->userCanEdit() ) {
if ( empty( $head[$headlineCount] ) ) {
$head[$headlineCount] = "";
}
- $head[$headlineCount] .= $sk->editSectionLink($headlineCount+1);
+ $head[$headlineCount] .= $sk->editSectionLink($startsection+$headlineCount+1);
}
# Add the edit section span
if( $rightClickHack ) {
- $headline = $sk->editSectionScript($headlineCount+1,$headline);
+ $headline = $sk->editSectionScript($startsection+$headlineCount+1,$headline);
}
# give headline the correct <h#> tag
# Top anchor now in skin
$full = $full.$toc;
}
+
+ # If a page is viewed in collapsed mode, a TOC generated
+ # 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) {
+ $full = $full.$collapsedtoc;
+ }
if( !empty( $head[$i] ) ) {
$full .= $head[$i];
return $full;
}
+ /* 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 );
+
+ global $wgUser,$wgInputEncoding,$wgTitle,$wgOut,$wgParser;
+ $sk = $wgUser->getSkin();
+
+ $striparray=array();
+ $oldtype=$wgParser->mOutputType;
+ $wgParser->mOutputType=OT_WIKI;
+ $text=$wgParser->strip($text, $striparray, true);
+ $wgParser->mOutputType=$oldtype;
+
+ $numMatches = preg_match_all( "/^(=+)(.*?)=+|^<h([1-6]).*?>(.*?)<\/h[1-6].*?>/mi",$text,$matches);
+
+ # no headings: text cannot be collapsed
+ if( $numMatches = 0 ) {
+ return "";
+ }
+
+ # We combine the headlines into a bundle and convert them to HTML
+ # in order to make stripping out the wikicrap easier.
+ $combined=implode("!@@@!",$matches[2]);
+ $myout=$wgParser->parse($combined,$wgTitle,$wgOut->mParserOptions);
+ $combined_html=$myout->getText();
+ $headlines=array();
+ $headlines=explode("!@@@!",$combined_html);
+ # headline counter
+ $headlineCount = 0;
+ $toclevel = 0;
+ $toc = "";
+ $full = "";
+ $head = array();
+ $sublevelCount = array();
+ $level = 0;
+ $prevlevel = 0;
+ foreach( $headlines as $headline ) {
+ $numbering = "";
+ if( $level ) {
+ $prevlevel = $level;
+ }
+ $level = $matches[1][$headlineCount];
+
+ # wikisource headings need to be converted into numbers
+ # =foo= equals <h1>foo</h1>, ==foo== equals <h2>foo</h2> etc.
+ if(strpos($level,"=")!==false) {
+ $level=strlen($level);
+ }
+
+ if( $prevlevel && $level > $prevlevel ) {
+ # reset when we enter a new level
+ $sublevelCount[$level] = 0;
+ $toc .= $sk->tocIndent( $level - $prevlevel );
+ $toclevel += $level - $prevlevel;
+ }
+ if( $level < $prevlevel ) {
+ # reset when we step back a level
+ $sublevelCount[$level+1]=0;
+ $toc .= $sk->tocUnindent( $prevlevel - $level );
+ $toclevel -= $prevlevel - $level;
+ }
+ # count number of headlines for each level
+ @$sublevelCount[$level]++;
+ $dot = 0;
+ for( $i = 1; $i <= $level; $i++ ) {
+ if( !empty( $sublevelCount[$i] ) ) {
+ if( $dot ) {
+ $numbering .= ".";
+ }
+ $numbering .= $sublevelCount[$i];
+ $dot = 1;
+ }
+ }
+
+
+ # The canonized header is a version of the header text safe to use for links
+ # Avoid insertion of weird stuff like <math> by expanding the relevant sections
+ $state=array();
+ $canonized_headline = Parser::unstrip( $headline, $state);
+
+ # strip out HTML
+ $canonized_headline = preg_replace( "/<.*?" . ">/","",$canonized_headline );
+ $tocline = trim( $canonized_headline );
+ $canonized_headline = preg_replace("/[ \\?&\\/<>\\(\\)\\[\\]=,+']+/", '_', urlencode( do_html_entity_decode( $tocline, ENT_COMPAT, $wgInputEncoding ) ) );
+ $refer[$headlineCount] = $canonized_headline;
+
+ # count how many in assoc. array so we can track dupes in anchors
+ @$refers[$canonized_headline]++;
+ $refcount[$headlineCount]=$refers[$canonized_headline];
+ $tocline = $numbering . " " . $tocline;
+
+ # Create the anchor for linking from the TOC to the section
+ $anchor = $canonized_headline;
+
+ if($refcount[$headlineCount] > 1 ) {
+ $anchor .= "_" . $refcount[$headlineCount];
+ }
+ $headlineCount++;
+ $toc .= $sk->tocLine($anchor,$tocline,$toclevel,$headlineCount);
+ }
+ $toclines = $headlineCount;
+ $toc .= $sk->tocUnindent( $toclevel );
+ $toc = $sk->tocTable( $toc );
+ return $toc;
+
+ }
/* private */ function doMagicISBN( &$tokenizer )
{
global $wgLang;
{
global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
- extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
+ extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff', 'section','sectiontitle') );
+ $collapse=$wgOut->getCollapse();
if ( 0 != $wgTitle->getNamespace() ) {
$a = array( "bgcolor" => "#ffffec" );
}
else $a = array( "bgcolor" => "#FFFFFF" );
- if($wgOut->isArticle() && $wgUser->getOption("editondblclick") &&
- (!$wgTitle->isProtected() || $wgUser->isSysop()) ) {
- $t = wfMsg( "editthispage" );
- $oid = $red = "";
- if ( !empty($redirect) ) {
- $red = "&redirect={$redirect}";
- }
- if ( !empty($oldid) && ! isset( $diff ) ) {
- $oid = "&oldid={$oldid}";
- }
- $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
+ if($wgOut->isArticle() && $wgUser->getOption("editondblclick")) {
+ $s = $this->editThisPage(false);
$s = "document.location = \"" .$s ."\";";
$a += array ("ondblclick" => $s);
-
}
$a['onload'] = $wgOut->getOnloadHandler();
return $a;
function pageTitle()
{
- global $wgOut, $wgTitle, $wgUser;
-
- $s = "<h1 class='pagetitle'>" . htmlspecialchars( $wgOut->getPageTitle() ) . "</h1>";
+ global $wgOut, $wgTitle, $wgUser, $wgRequest;
+ $section=$wgRequest->getVal('section');
+ $action=$wgRequest->getVal('action');
+
+ if ($section && $action=="view") {
+ $link= $this->makeLink( $wgTitle->getPrefixedText(), htmlspecialchars($wgOut->getPageTitle()) );
+ $s = "<h1 class='pagetitle'>" . $link . " " . wfMsg("sectionedit")."</h1>";
+ } else {
+
+ $s = "<h1 class='pagetitle'>" . htmlspecialchars( $wgOut->getPageTitle() ) . "</h1>";
+ }
if($wgUser->getOption("editsectiononrightclick") && $wgTitle->userCanEdit()) { $s=$this->editSectionScript(0,$s);}
return $s;
}
return $s;
}
- function editThisPage()
+ # if makeLink is false, just return the edit URL
+ function editThisPage($makeLink=true)
{
global $wgOut, $wgTitle, $wgRequest;
$oldid = $wgRequest->getVal( 'oldid' );
$diff = $wgRequest->getVal( 'diff' );
$redirect = $wgRequest->getVal( 'redirect' );
+ $section = $wgRequest->getVal('section');
+ $sectiontitle = $wgRequest->getVal('sectiontitle');
+ $collapse = $wgOut->getCollapse();
- if ( ! $wgOut->isArticleRelated() ) {
+ if ( ! $wgOut->isArticleRelated() && $makeLink) {
$s = wfMsg( "protectedpage" );
} else {
$n = $wgTitle->getPrefixedText();
#$t = wfMsg( "protectedpage" );
$t = wfMsg( "viewsource" );
}
- $oid = $red = "";
+ $oid = $red = $sid = $stl = "";
if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
if ( $oldid && ! isset( $diff ) ) {
$oid = "&oldid={$oldid}";
}
- $s = $this->makeKnownLink( $n, $t, "action=edit{$oid}{$red}" );
+ if ( !empty($section) ) {
+ $sid = "§ion={$section}";
+ }
+ if ( !empty($sectiontitle) ) {
+ $stl = "§iontitle={$sectiontitle}";
+ }
+ if ($collapse && !$section) {
+ $sid = "§ion=0";
+ }
+ $action="action=edit{$oid}{$red}{$sid}{$stl}";
+ if($makeLink) {
+ $s = $this->makeKnownLink( $n, $t, $action );
+ } else {
+ $s = $wgTitle->getFullUrl($action);
+ }
}
return $s;
}
}
# parameter level defines if we are on an indentation level
- function tocLine( $anchor, $tocline, $level ) {
- $link = "<a href=\"#$anchor\">$tocline</a><br />";
+ function tocLine( $anchor, $tocline, $level,$section=0 ) {
+ global $wgTitle;
+ $url = $section ? $wgTitle->getLocalURL( "action=view§ion={$section}§iontitle={$anchor}" )
+ : "#$anchor";
+ $link = "<a href=\"$url\" class='internal'>$tocline</a><br />";
if($level) {
return "$link\n";
} else {
function tocTable($toc) {
# note to CSS fanatics: putting this in a div does not work -- div won't auto-expand
# try min-width & co when somebody gets a chance
+ global $wgRequest,$wgTitle,$wgOut;
+ $collapse=$wgOut->getCollapse();
+ $section=$wgRequest->getVal('section');
+ $collapseexpand="";
+ if(!$section) {
+ if($collapse) {
+ $url=$wgTitle->getLocalURL("action=view&collapse=false");
+ $collapseexpand="<a href=\"$url\" class=\"internal\">".wfMsg("expandpage")."</A>";
+ } else {
+ $url=$wgTitle->getLocalURL("action=view&collapse=true");
+ $collapseexpand="<a href=\"$url\" class=\"internal\">".wfMsg("collapsepage")."</A>";
+ }
+ }
$hideline = " <script type='text/javascript'>showTocToggle(\"" . addslashes( wfMsg("showtoc") ) . "\",\"" . addslashes( wfMsg("hidetoc") ) . "\")</script>";
- return
+ $rv=
"<table border=\"0\" id=\"toc\"><tr><td align=\"center\">\n".
"<b>".wfMsg("toc")."</b>" .
$hideline .
"</td></tr><tr id='tocinside'><td>\n".
- $toc."</td></tr></table>\n";
+ $toc."</td></tr>";
+ if($collapseexpand) {
+ $rv.="<tr><td align=\"center\"><I>$collapseexpand</I></td></tr>";
+ }
+ $rv.="</table>\n";
+ return $rv;
}
# These two do not check for permissions: check $wgTitle->userCanEdit before calling them
$this->titletxt = $wgTitle->getPrefixedText();
- $tpl->set( "title", $wgOut->getPageTitle() );
+ $title=$wgOut->getPageTitle();
+ $section=$wgRequest->getVal('section');
+ if ($section && $action=="view") {
+ $title .= " " . wfMsg("sectionedit");
+ }
+ $tpl->set( "title", $title );
$tpl->set( "pagetitle", $wgOut->getHTMLTitle() );
$tpl->setRef( "thispage", &$this->thispage );
# an array of edit links by default used for the tabs
function buildContentActionUrls () {
- global $wgTitle, $wgUser, $wgRequest;
+ global $wgTitle, $wgUser, $wgRequest,$wgOut;
$action = $wgRequest->getText( 'action' );
$section = $wgRequest->getText( 'section' );
$oldid = $wgRequest->getVal( 'oldid' );
+ $section = $wgRequest->getVal( 'section' );
+ $sectiontitle = $wgRequest->getVal( 'sectiontitle' );
+ $collapse = $wgOut->getCollapse();
$diff = $wgRequest->getVal( 'diff' );
$content_actions = array();
if ( $wgTitle->userCanEdit() ) {
$oid = ( $oldid && ! isset( $diff ) ) ? "&oldid={$oldid}" : false;
+
+ $sid = $section ? "§ion={$section}" : false;
+ $stl = $sectiontitle ? "§iontitle={$sectiontitle}" : false;
+ if($collapse && !$sid) { $sid="§ion=0";}
$istalk = ( Namespace::isTalk( $wgTitle->getNamespace()) );
$istalkclass = $istalk?' istalk':'';
$content_actions['edit'] = array(
'class' => ((($action == 'edit' or $action == 'submit') and $section != 'new') ? 'selected' : '').$istalkclass,
'text' => wfMsg('edit'),
- 'href' => $this->makeUrl($this->thispage, 'action=edit'.$oid),
+ 'href' => $this->makeUrl($this->thispage, 'action=edit'.$oid.$sid.$stl),
'ttip' => wfMsg('tooltip-edit'),
'akey' => wfMsg('accesskey-edit')
);
}
} else {
$oid = ( $oldid && ! isset( $diff ) ) ? "&oldid={$oldid}" : '';
+ $sid = $section ? "§ion={$section}" : false;
+ $stl = $sectiontitle ? "§iontitle={$sectiontitle}" : false;
+ if($collapse && !$sid) { $sid="§ion=0";}
$content_actions['edit'] = array('class' => ($action == 'edit') ? 'selected' : false,
'text' => wfMsg('viewsource'),
- 'href' => $this->makeUrl($this->thispage, 'action=edit'.$oid),
+ 'href' => $this->makeUrl($this->thispage, 'action=edit'.$oid.$sid.$stl),
'ttip' => wfMsg('tooltip-viewsource'),
'akey' => wfMsg('accesskey-viewsource'));
}
$this->mNewpass = $request->getVal( 'wpNewpass' );
$this->mRetypePass =$request->getVal( 'wpRetypePass' );
$this->mStubs = $request->getVal( 'wpStubs' );
+ $this->mCollapse = $request->getVal( 'wpCollapse' );
$this->mRows = $request->getVal( 'wpRows' );
$this->mCols = $request->getVal( 'wpCols' );
$this->mSkin = $request->getVal( 'wpSkin' );
$wgUser->setOption( "rows", $this->validateInt( $this->mRows, 4, 1000 ) );
$wgUser->setOption( "cols", $this->validateInt( $this->mCols, 4, 1000 ) );
$wgUser->setOption( "stubthreshold", $this->validateIntOrNull( $this->mStubs ) );
+ $wgUser->setOption( "collapsethreshold", $this->validateIntOrNull( $this->mCollapse ) );
$wgUser->setOption( "timecorrection", $this->validateTimeZone( $this->mHourDiff, -12, 14 ) );
# Set search namespace options
$this->mRows = $wgUser->getOption( "rows" );
$this->mCols = $wgUser->getOption( "cols" );
$this->mStubs = $wgUser->getOption( "stubthreshold" );
+ $this->mCollapse = $wgUser->getOption( "collapsethreshold" );
$this->mHourDiff = $wgUser->getOption( "timecorrection" );
$this->mSearch = $wgUser->getOption( "searchlimit" );
$this->mSearchLines = $wgUser->getOption( "contextlines" );
$emf = wfMsg( "emailflag" );
$ynn = wfMsg( "yournick" );
$stt = wfMsg ( "stubthreshold" ) ;
+ $coltr = wfMsg("collapsethreshold");
$srh = wfMsg( "searchresultshead" );
$rpp = wfMsg( "resultsperpage" );
$scl = wfMsg( "contextlines" );
" . $this->getToggle( "hideminor" ) .
$this->getToggle( "usenewrc" ) . "
<div><label>$stt: <input type='text' name=\"wpStubs\" value=\"$this->mStubs\" size='6' /></label></div>
+ <div><label>$coltr: <input type='text' name=\"wpCollapse\" value=\"$this->mCollapse\" size='6' /></label></div>
</fieldset>
<fieldset>
$this->mNamespace = 0;
$this->mRestrictionsLoaded = false;
$this->mRestrictions = array();
- $this->mDefaultNamespace = 0;
+ $this->mDefaultNamespace = 0;
}
# From a prefixed DB key
Article::onArticleCreate( $this );
return true;
}
-
+
}
?>
}
function getBool( $name, $default = false ) {
- return $this->getVal( $name, $default ) ? true : false;
+ $val=$this->getVal( $name, $default );
+ if($val=="false") { $val=false; }
+ return $val ? true : false;
}
function getCheck( $name ) {
$wgArticle = new Article($wgTitle);
$action = strtolower( trim( $action ) );
-if ( "" == $action ) { $action = "view"; }
if ($wgRequest->getVal( "printable" ) == "yes") {
$wgOut->setPrintable();
}
"cols" => 80, "rows" => 25, "searchlimit" => 20,
"contextlines" => 5, "contextchars" => 50,
"skin" => $wgDefaultSkin, "math" => 1, "rcdays" => 7, "rclimit" => 50,
- "highlightbroken" => 1, "stubthreshold" => 0,
+ "highlightbroken" => 1, "stubthreshold" => 0, "collapsethreshold" => 30000,
"previewontop" => 1, "editsection"=>1,"editsectiononrightclick"=>0, "showtoc"=>1,
"showtoolbar" =>1,
"date" => 0
"toc" => "Table of contents",
"showtoc" => "show",
"hidetoc" => "hide",
+"collapsepage" => "Collapse page",
+"expandpage" => "Expand page",
"thisisdeleted" => "View or restore $1?",
"restorelink" => "$1 deleted edits",
'feedlinks' => 'Feed:',
"resultsperpage" => "Hits to show per page",
"contextlines" => "Lines to show per hit",
"contextchars" => "Characters of context per line",
-"stubthreshold" => "Threshold for stub display",
+"stubthreshold" => "Threshold (in bytes) for marking links as stubs",
+"collapsethreshold" => "Threshold (in bytes) for auto-collapsing pages",
"recentchangescount" => "Number of titles in recent changes",
"savedprefs" => "Your preferences have been saved.",
"timezonetext" => "Enter number of hours your local time differs