From 8dfaf08966f846cb2eea5d1f5c6003f3e42ff0bc Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 9 Oct 2004 02:55:32 +0000 Subject: [PATCH] Put diffs into the RecentChanges RSS/Atom feed to make it more useful for offline reading (and more convenient in general). For new pages, includes the full wikitext. Probably will want to do caching of diffs before pushing this one out the door, but it's not as bad as all that; nothing has to be parsed, just diffed. --- includes/SpecialRecentchanges.php | 43 ++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/includes/SpecialRecentchanges.php b/includes/SpecialRecentchanges.php index 4d468a7582..d227aa0e8f 100644 --- a/includes/SpecialRecentchanges.php +++ b/includes/SpecialRecentchanges.php @@ -135,7 +135,7 @@ function wfSpecialRecentchanges( $par ) { $talkpage = $title->getTalkPage(); $item = new FeedItem( $title->getPrefixedText(), - htmlspecialchars( $obj->rc_comment ), + rcFormatDiff( $obj ), $title->getFullURL(), $obj->rc_timestamp, $obj->rc_user_text, @@ -226,4 +226,45 @@ function rcLimitLinks( $page='Recentchanges', $more='', $doall = false ) { return $note; } +function rcFormatDiff( $row ) { + require_once( 'DifferenceEngine.php' ); + $comment = "

" . htmlspecialchars( $row->rc_comment ) . "

\n"; + + if( $row->rc_namespace >= 0 ) { + global $wgContLang; + + #$diff =& new DifferenceEngine( $row->rc_this_oldid, $row->rc_last_oldid, $row->rc_id ); + #$diff->showDiffPage(); + + $dbr =& wfGetDB( DB_SLAVE ); + if( $row->rc_this_oldid ) { + $newrow = $dbr->selectRow( 'old', + array( 'old_flags', 'old_text' ), + array( 'old_id' => $row->rc_this_oldid ) ); + $newtext = Article::getRevisionText( $newrow ); + } else { + $newrow = $dbr->selectRow( 'cur', + array( 'cur_text' ), + array( 'cur_id' => $row->rc_cur_id ) ); + $newtext = $newrow->cur_text; + } + if( $row->rc_last_oldid ) { + $oldrow = $dbr->selectRow( 'old', + array( 'old_flags', 'old_text' ), + array( 'old_id' => $row->rc_last_oldid ) ); + $oldtext = Article::getRevisionText( $oldrow ); + $diffText = DifferenceEngine::getDiff( $oldtext, $newtext, + wfMsg( 'revisionasof', $wgContLang->timeanddate( $row->rc_timestamp ) ), + wfMsg( 'currentrev' ) ); + } else { + $diffText = '

' . wfMsg( 'newpage' ) . '

' . + '
' . nl2br( htmlspecialchars( $newtext ) ) . '
'; + } + + return $comment . $diffText; + } + + return $comment; +} + ?> -- 2.20.1