return 0;
}
}
+
+ /**
+ * Returns true if this article exists in the database.
+ * @return bool
+ */
+ function exists() {
+ return $this->getId() != 0;
+ }
/**
* Get the view count for this article
return $titleObj !== NULL;
}
+ /**
+ * Returns true if the currently-referenced revision is the current edit
+ * to this page (and it exists).
+ * @return bool
+ */
+ function isCurrent() {
+ return $this->exists() &&
+ isset( $this->mRevision ) &&
+ $this->mRevision->isCurrent();
+ }
+
/**
* Loads everything except the text
* This isn't necessary for all uses, so it's only done if needed.
}
}
# Should the parser cache be used?
- if ( $wgEnableParserCache && intval($wgUser->getOption( 'stubthreshold' )) == 0 && empty( $oldid ) && $this->getID() ) {
- $pcache = true;
- } else {
- $pcache = false;
- }
+ $pcache = $wgEnableParserCache &&
+ intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 &&
+ $this->exists() &&
+ empty( $oldid );
+ wfDebug( 'Article::view using parser cache: ' . ($pcache ? 'yes' : 'no' ) . "\n" );
$outputDone = false;
if ( $pcache ) {
$wgOut->addPrimaryWikiText( $text, $this );
} else {
# Display content, don't attempt to save to parser cache
+
+ # Don't show section-edit links on old revisions... this way lies madness.
+ if( !$this->isCurrent() ) {
+ $oldEditSectionSetting = $wgOut->mParserOptions->setEditSection( false );
+ }
$wgOut->addWikiText( $text );
+
+ if( !$this->isCurrent() ) {
+ $wgOut->mParserOptions->setEditSection( $oldEditSectionSetting );
+ }
}
}
/* title may have been set from the cache */
function setOldSubtitle( $oldid=0 ) {
global $wgLang, $wgOut, $wgUser;
+ $current = ( $oldid == $this->mLatest );
$td = $wgLang->timeanddate( $this->mTimestamp, true );
$sk = $wgUser->getSkin();
- $lnk = $sk->makeKnownLinkObj ( $this->mTitle, wfMsg( 'currentrevisionlink' ) );
+ $lnk = $current
+ ? wfMsg( 'currentrevisionlink' )
+ : $lnk = $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'currentrevisionlink' ) );
$prevlink = $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'previousrevision' ), 'direction=prev&oldid='.$oldid );
- $nextlink = $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'nextrevision' ), 'direction=next&oldid='.$oldid );
+ $nextlink = $current
+ ? wfMsg( 'nextrevision' )
+ : $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'nextrevision' ), 'direction=next&oldid='.$oldid );
$r = wfMsg( 'revisionasofwithlink', $td, $lnk, $prevlink, $nextlink );
$wgOut->setSubtitle( $r );
}
}
$prevlink = $sk->makeKnownLinkObj( $wgTitle, wfMsg( 'previousdiff' ), 'diff=prev&oldid='.$this->mOldid );
- if ( $this->mNewid == 0 ) {
+ if ( $this->newRev->isCurrent() ) {
$nextlink = '';
} else {
$nextlink = $sk->makeKnownLinkObj( $wgTitle, wfMsg( 'nextdiff' ), 'diff=next&oldid='.$this->mNewid );
DifferenceEngine::showDiff( $this->mOldtext, $this->mNewtext,
$oldHeader, $newHeader );
$wgOut->addHTML( "<hr /><h2>{$this->mPagetitle}</h2>\n" );
+
+ if( !$this->newRev->isCurrent() ) {
+ $oldEditSectionSetting = $wgOut->mParserOptions->setEditSection( false );
+ }
$wgOut->addWikiText( $this->mNewtext );
+ if( !$this->newRev->isCurrent() ) {
+ $wgOut->mParserOptions->setEditSection( $oldEditSectionSetting );
+ }
wfProfileOut( $fname );
}