From 79303cd93a877d2edd33e9efeafd78e532dd3226 Mon Sep 17 00:00:00 2001 From: Jens Frank Date: Sat, 28 Aug 2004 23:00:04 +0000 Subject: [PATCH] ENH#59 Provide a (diff) link in Special:Contributions Does not look up the next old revision for every change but links to pseudo-revision 'prev'. DifferenceEngine looks up the previous revision if user requests a specific diff. --- includes/Article.php | 2 +- includes/Database.php | 2 +- includes/DifferenceEngine.php | 15 +++++++++++++-- includes/SpecialContributions.php | 15 ++++++++++----- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 3bde806606..9530bd02df 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -663,7 +663,7 @@ class Article { if ( !is_null( $diff ) ) { require_once( 'DifferenceEngine.php' ); $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); - $de = new DifferenceEngine( intval($oldid), intval($diff), intval($rcid) ); + $de = new DifferenceEngine( $oldid, $diff, $rcid ); $de->showDiffPage(); wfProfileOut( $fname ); if( $diff == 0 ) { diff --git a/includes/Database.php b/includes/Database.php index ac3f06ec14..acfab2bb90 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -326,7 +326,7 @@ class Database { return !!$this->query( $sql, DB_MASTER, $fname ); } - function getField( $table, $var, $cond='', $fname = 'Database::get', $options = array() ) { + function getField( $table, $var, $cond='', $fname = 'Database::getField', $options = array() ) { return $this->selectField( $table, $var, $cond, $fname = 'Database::get', $options = array() ); } diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index 94a310223a..5241c4b75f 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -12,8 +12,19 @@ class DifferenceEngine { function DifferenceEngine( $old, $new, $rcid = 0 ) { - $this->mOldid = $old; - $this->mNewid = $new; + global $wgTitle; + if ( 'prev' == $new ) { + $this->mNewid = intval($old); + $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" ); + + } else { + $this->mOldid = intval($old); + $this->mNewid = intval($new); + } $this->mRcidMarkPatrolled = intval($rcid); # force it to be an integer } diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index ca909f9935..78bd35c8a9 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -75,7 +75,7 @@ function wfSpecialContributions( $par = "" ) "ORDER BY inverse_timestamp LIMIT {$querylimit}"; $res1 = $dbr->query( $sql, $fname ); - $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text FROM $old " . + $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text,old_id FROM $old " . "WHERE old_user_text='" . $dbr->strencode( $nt->getText() ) . "' {$omq} " . "ORDER BY inverse_timestamp LIMIT {$querylimit}"; $res2 = $dbr->query( $sql, $fname ); @@ -84,7 +84,7 @@ function wfSpecialContributions( $par = "" ) "WHERE cur_user {$userCond} {$cmq} ORDER BY inverse_timestamp LIMIT {$querylimit}"; $res1 = $dbr->query( $sql, $fname ); - $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text FROM $old " . + $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text,old_id FROM $old " . "WHERE old_user {$userCond} {$omq} ORDER BY inverse_timestamp LIMIT {$querylimit}"; $res2 = $dbr->query( $sql, $fname ); } @@ -127,6 +127,7 @@ function wfSpecialContributions( $par = "" ) $obj1 = $dbr->fetchObject( $res1 ); $topmark = true; + $oldid = false; --$nCur; } else { $ns = $obj2->old_namespace; @@ -135,6 +136,7 @@ function wfSpecialContributions( $par = "" ) $comment =$obj2->old_comment; $me = $obj2->old_minor_edit; $usertext = $obj2->old_user_text; + $oldid = $obj2->old_id; $obj2 = $dbr->fetchObject( $res2 ); $topmark = false; @@ -142,7 +144,7 @@ function wfSpecialContributions( $par = "" ) --$nOld; } if( $n >= $offset ) - ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, ( $me > 0), $isnew, $usertext ); + ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, ( $me > 0), $isnew, $usertext, $oldid ); } $wgOut->addHTML( "\n" ); @@ -175,7 +177,7 @@ other users. TODO: This would probably look a lot nicer in a table. */ -function ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, $isminor, $isnew, $target ) +function ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, $isminor, $isnew, $target, $oldid ) { global $wgLang, $wgOut, $wgUser, $wgRequest; $page = Title::makeName( $ns, $t ); @@ -197,6 +199,9 @@ function ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, $isminor, $isnew, $t } } + if ( $oldid ) { + $oldtext= $sk->makeKnownLink( $page, '('.wfMsg('diff').')', 'diff=prev&oldid='.$oldid ); + } else { $oldtext=''; } $histlink="(".$sk->makeKnownLink($page,wfMsg("hist"),"action=history").")"; if($comment) { @@ -212,7 +217,7 @@ function ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, $isminor, $isnew, $t $mflag = ""; } - $wgOut->addHTML( "
  • {$d} {$histlink} {$mflag} {$link} {$comment}{$topmarktext}
  • \n" ); + $wgOut->addHTML( "
  • {$d} {$histlink} {$mflag} {$link} {$comment}{$topmarktext}{$oldtext}
  • \n" ); } function ucCountLink( $lim, $d ) -- 2.20.1