From 0b7ae97a8a85b49cbe7aed2cb5476432688a572c Mon Sep 17 00:00:00 2001 From: Jens Frank Date: Sat, 13 Nov 2004 08:40:34 +0000 Subject: [PATCH] Fixed direction=prec/next style navigation of old revisions --- includes/Article.php | 61 ++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 0f18585d0e..b361976008 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -292,25 +292,21 @@ class Article { } /** - * Load the revision (including cur_text) into this object - */ - function loadContent( $noredir = false ) { - global $wgOut, $wgRequest; - - if ( $this->mContentLoaded ) return; - - $dbr =& $this->getDB(); - # Query variables :P - $oldid = $wgRequest->getVal( 'oldid' ); - $redirect = $wgRequest->getVal( 'redirect' ); - - $fname = 'Article::loadContent'; + * Return the oldid of the article that is to be shown. + * For requests with a "direction", this is not the oldid of the + * query + */ + function getOldID() { + global $wgRequest, $wgOut; + static $lastid; - # Pre-fill content with error message so that if something - # fails we'll have something telling us what we intended. + if ( isset( $lastid ) ) { + return $lastid; + } - $t = $this->mTitle->getPrefixedText(); + $oldid = $wgRequest->getVal( 'oldid' ); if ( isset( $oldid ) ) { + $dbr =& $this->getDB(); $oldid = IntVal( $oldid ); if ( $wgRequest->getVal( 'direction' ) == 'next' ) { $nextid = $this->mTitle->getNextRevisionID( $oldid ); @@ -327,7 +323,32 @@ class Article { # TODO } } + $lastid = $oldid; } + return @$oldid; # "@" to be able to return "unset" without PHP complaining + } + + + /** + * Load the revision (including cur_text) into this object + */ + function loadContent( $noredir = false ) { + global $wgOut, $wgRequest; + + if ( $this->mContentLoaded ) return; + + $dbr =& $this->getDB(); + # Query variables :P + $oldid = $this->getOldID(); + $redirect = $wgRequest->getVal( 'redirect' ); + + $fname = 'Article::loadContent'; + + # Pre-fill content with error message so that if something + # fails we'll have something telling us what we intended. + + $t = $this->mTitle->getPrefixedText(); + if ( isset( $oldid ) ) { $t .= ',oldid='.$oldid; } @@ -658,14 +679,14 @@ class Article { * the given title. */ function view() { - global $wgUser, $wgOut, $wgRequest, $wgOnlySysopsCanPatrol; + global $wgUser, $wgOut, $wgRequest, $wgOnlySysopsCanPatrol, $wgLang; global $wgLinkCache, $IP, $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol; $sk = $wgUser->getSkin(); $fname = 'Article::view'; wfProfileIn( $fname ); # Get variables from query string - $oldid = $wgRequest->getVal( 'oldid' ); + $oldid = $this->getOldID(); $diff = $wgRequest->getVal( 'diff' ); $rcid = $wgRequest->getVal( 'rcid' ); @@ -753,8 +774,10 @@ class Article { $targetUrl = $rt->escapeLocalURL(); $titleText = htmlspecialchars( $rt->getPrefixedText() ); $link = $sk->makeLinkObj( $rt ); - $wgOut->addHTML( '' . + + $wgOut->addHTML( '#REDIRECT' . ''.$link.'' ); + } else if ( $pcache ) { # Display content and save to parser cache $wgOut->addPrimaryWikiText( $text, $this ); -- 2.20.1