Add previous/next links to old revision pages
authorJens Frank <jeluf@users.mediawiki.org>
Sat, 2 Oct 2004 21:36:36 +0000 (21:36 +0000)
committerJens Frank <jeluf@users.mediawiki.org>
Sat, 2 Oct 2004 21:36:36 +0000 (21:36 +0000)
includes/Article.php
includes/DifferenceEngine.php
languages/Language.php
languages/LanguageDe.php

index 7dc3727..8e724ca 100644 (file)
@@ -409,6 +409,23 @@ class Article {
                $t = $this->mTitle->getPrefixedText();
                if ( isset( $oldid ) ) {
                        $oldid = IntVal( $oldid );
+                       if ( $wgRequest->getVal( 'direction' ) == 'next' ) {
+                               $nextid = $this->mTitle->getNextRevisionID( $oldid );
+                               if ( $nextid ) {
+                                       $oldid = $nextid;
+                               } else {
+                                       $wgOut->redirect( $this->mTitle->getFullURL( 'redirect=no' ) );
+                               }
+                       } elseif ( $wgRequest->getVal( 'direction' ) == 'prev' ) {
+                               $previd = $this->mTitle->getPreviousRevisionID( $oldid );
+                               if ( $previd ) {
+                                       $oldid = $previd;
+                               } else {
+                                       # TODO
+                               }
+                       }
+               }
+               if ( isset( $oldid ) ) {
                        $t .= ',oldid='.$oldid;
                }
                if ( isset( $redirect ) ) {
@@ -803,7 +820,7 @@ class Article {
                        # We're looking at an old revision
 
                        if ( !empty( $oldid ) ) {
-                               $this->setOldSubtitle();
+                               $this->setOldSubtitle( $oldid );
                                $wgOut->setRobotpolicy( 'noindex,follow' );
                        }
                        if ( '' != $this->mRedirectedFrom ) {
@@ -1898,14 +1915,17 @@ class Article {
        /**
         * @todo document this function
         * @private
+        * @param string $oldid         Revision ID of this article revision
         */
-       function setOldSubtitle() {
+       function setOldSubtitle( $oldid=0 ) {
                global $wgLang, $wgOut, $wgUser;
 
                $td = $wgLang->timeanddate( $this->mTimestamp, true );
                $sk = $wgUser->getSkin();
                $lnk = $sk->makeKnownLinkObj ( $this->mTitle, wfMsg( 'currentrevisionlink' ) );
-               $r = wfMsg( 'revisionasofwithlink', $td, $lnk );
+               $prevlink = $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'previousrevision' ), 'direction=prev&oldid='.$oldid );
+               $nextlink = $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'nextrevision' ), 'direction=next&oldid='.$oldid );
+               $r = wfMsg( 'revisionasofwithlink', $td, $lnk, $prevlink, $nextlink );
                $wgOut->setSubtitle( $r );
        }
 
index 9276d0f..b28cc13 100644 (file)
@@ -27,11 +27,6 @@ class DifferenceEngine {
                        $this->mNewid = intval($old);
 
                        $this->mOldid = $wgTitle->getPreviousRevisionID( $this->mNewid );
-                       #$dbr =& wfGetDB( DB_SLAVE );
-                       #$this->mOldid = $dbr->selectField( 'old', 'old_id',
-                               #"old_title='" . $wgTitle->getDBkey() . "'" .
-                               #' AND old_namespace=' . $wgTitle->getNamespace() .
-                               #" AND old_id<{$this->mNewid} ORDER BY old_id DESC" );
 
                } elseif ( 'next' == $new ) {
 
@@ -40,11 +35,6 @@ class DifferenceEngine {
                        #
                        $this->mOldid = intval($old);
                        $this->mNewid = $wgTitle->getNextRevisionID( $this->mOldid );
-                       #$dbr =& wfGetDB( DB_SLAVE );
-                       #$this->mNewid = $dbr->selectField( 'old', 'old_id',
-                       #       "old_title='" . $wgTitle->getDBkey() . "'" .
-                       #       ' AND old_namespace=' . $wgTitle->getNamespace() .
-                       #       " AND old_id>{$this->mOldid} ORDER BY old_id " );
                        if ( false === $this->mNewid ) {
                                # if no result, NewId points to the newest old revision. The only newer
                                # revision is cur, which is "0".
index a9fb977..c6c7267 100644 (file)
@@ -685,7 +685,9 @@ Please check the URL you used to access this page.\n",
 'loadhist'             => 'Loading page history',
 'currentrev'   => 'Current revision',
 'revisionasof'          => 'Revision as of $1',
-'revisionasofwithlink'  => '(Revision as of $1; $2)',
+'revisionasofwithlink'  => 'Revision as of $1; $2<br />$3 | $4',
+'previousrevision'     => '&larr;Older revision',
+'nextrevision'         => 'Newer revision&rarr;',
 'currentrevisionlink'   => 'view current revision',
 'cur'                  => 'cur',
 'next'                 => 'next',
index b04c8fd..1b97725 100644 (file)
@@ -479,6 +479,9 @@ Benutzer mit Sysop-Rechten bearbeitet werden kann. Beachten Sie bitte die
 "loadhist"             => "Lade Liste mit früheren Versionen",
 "currentrev"   => "Aktuelle Version",
 "revisionasof" => "Version vom $1",
+'revisionasofwithlink' => 'Version vom $1; $2<br />$3 | $4',
+'nextrevision'         => '&larr;Nächstjüngere Version',
+'previousrevision'     => 'Nächstältere Version&rarr;',
 "cur"                  => "Aktuell",
 "next"                 => "Nächste",
 "last"                 => "Letzte",