5 * @subpackage SpecialPage
11 require_once( 'Feed.php' );
12 require_once( 'ChangesList.php' );
13 require_once( 'Revision.php' );
18 function wfSpecialRecentchanges( $par, $specialPage ) {
19 global $wgUser, $wgOut, $wgRequest, $wgUseRCPatrol;
20 global $wgRCShowWatchingUsers, $wgShowUpdatedMarker;
21 global $wgAllowCategorizedRecentChanges ;
22 $fname = 'wfSpecialRecentchanges';
24 # Get query parameters
25 $feedFormat = $wgRequest->getVal( 'feed' );
27 /* Checkbox values can't be true be default, because
28 * we cannot differentiate between unset and not set at all
31 /* int */ 'days' => $wgUser->getDefaultOption('rcdays'),
32 /* int */ 'limit' => $wgUser->getDefaultOption('rclimit'),
33 /* bool */ 'hideminor' => false,
34 /* bool */ 'hidebots' => true,
35 /* bool */ 'hideanons' => false,
36 /* bool */ 'hideliu' => false,
37 /* bool */ 'hidepatrolled' => false,
38 /* bool */ 'hidemyself' => false,
39 /* text */ 'from' => '',
40 /* text */ 'namespace' => null,
41 /* bool */ 'invert' => false,
42 /* bool */ 'categories_any' => false,
48 $days = $wgUser->getOption( 'rcdays' );
49 if ( !$days ) { $days = $defaults['days']; }
50 $days = $wgRequest->getInt( 'days', $days );
52 $limit = $wgUser->getOption( 'rclimit' );
53 if ( !$limit ) { $limit = $defaults['limit']; }
55 # list( $limit, $offset ) = wfCheckLimits( 100, 'rclimit' );
56 $limit = $wgRequest->getInt( 'limit', $limit );
58 /* order of selection: url > preferences > default */
59 $hideminor = $wgRequest->getBool( 'hideminor', $wgUser->getOption( 'hideminor') ?
true : $defaults['hideminor'] );
61 # As a feed, use limited settings only
64 if( $limit > $wgFeedLimit ) {
65 $options['limit'] = $wgFeedLimit;
70 $namespace = $wgRequest->getIntOrNull( 'namespace' );
71 $invert = $wgRequest->getBool( 'invert', $defaults['invert'] );
72 $hidebots = $wgRequest->getBool( 'hidebots', $defaults['hidebots'] );
73 $hideanons = $wgRequest->getBool( 'hideanons', $defaults['hideanons'] );
74 $hideliu = $wgRequest->getBool( 'hideliu', $defaults['hideliu'] );
75 $hidepatrolled = $wgRequest->getBool( 'hidepatrolled', $defaults['hidepatrolled'] );
76 $hidemyself = $wgRequest->getBool ( 'hidemyself', $defaults['hidemyself'] );
77 $from = $wgRequest->getVal( 'from', $defaults['from'] );
79 # Get query parameters from path
81 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
82 foreach ( $bits as $bit ) {
83 if ( 'hidebots' == $bit ) $hidebots = 1;
84 if ( 'bots' == $bit ) $hidebots = 0;
85 if ( 'hideminor' == $bit ) $hideminor = 1;
86 if ( 'minor' == $bit ) $hideminor = 0;
87 if ( 'hideliu' == $bit ) $hideliu = 1;
88 if ( 'hidepatrolled' == $bit ) $hidepatrolled = 1;
89 if ( 'hideanons' == $bit ) $hideanons = 1;
90 if ( 'hidemyself' == $bit ) $hidemyself = 1;
92 if ( is_numeric( $bit ) ) {
96 if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
100 if ( preg_match( '/^days=(\d+)$/', $bit, $m ) ) {
107 if ( $limit < 0 ||
$limit > 5000 ) $limit = $defaults['limit'];
110 # Database connection and caching
111 $dbr =& wfGetDB( DB_SLAVE
);
112 extract( $dbr->tableNames( 'recentchanges', 'watchlist' ) );
115 $cutoff_unixtime = time() - ( $days * 86400 );
116 $cutoff_unixtime = $cutoff_unixtime - ($cutoff_unixtime %
86400);
117 $cutoff = $dbr->timestamp( $cutoff_unixtime );
118 if(preg_match('/^[0-9]{14}$/', $from) and $from > wfTimestamp(TS_MW
,$cutoff)) {
119 $cutoff = $dbr->timestamp($from);
121 $from = $defaults['from'];
124 # 10 seconds server-side caching max
125 $wgOut->setSquidMaxage( 10 );
127 # Get last modified date, for client caching
128 # Don't use this if we are using the patrol feature, patrol changes don't update the timestamp
129 $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, $fname );
130 if ( $feedFormat ||
!$wgUseRCPatrol ) {
131 if( $lastmod && $wgOut->checkLastModified( $lastmod ) ){
132 # Client cache fresh and headers sent, nothing more to do.
137 # It makes no sense to hide both anons and logged-in users
138 # Where this occurs, force anons to be shown
139 if( $hideanons && $hideliu )
142 # Form WHERE fragments for all the options
143 $hidem = $hideminor ?
'AND rc_minor = 0' : '';
144 $hidem .= $hidebots ?
' AND rc_bot = 0' : '';
145 $hidem .= $hideliu ?
' AND rc_user = 0' : '';
146 $hidem .= ( $wgUseRCPatrol && $hidepatrolled ) ?
' AND rc_patrolled = 0' : '';
147 $hidem .= $hideanons ?
' AND rc_user != 0' : '';
150 if( $wgUser->getID() ) {
151 $hidem .= ' AND rc_user != ' . $wgUser->getID();
153 $hidem .= ' AND rc_user_text != ' . $dbr->addQuotes( $wgUser->getName() );
157 # Namespace filtering
158 $hidem .= is_null( $namespace ) ?
'' : ' AND rc_namespace' . ($invert ?
'!=' : '=') . $namespace;
160 // This is the big thing!
162 $uid = $wgUser->getID();
165 $sql2 = "SELECT * FROM $recentchanges FORCE INDEX (rc_timestamp) " .
166 ($uid ?
"LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") .
167 "WHERE rc_timestamp >= '{$cutoff}' {$hidem} " .
168 "ORDER BY rc_timestamp DESC";
169 $sql2 = $dbr->limitResult($sql2, $limit, 0);
170 $res = $dbr->query( $sql2, $fname );
172 // Fetch results, prepare a batch link existence check query
174 $batch = new LinkBatch
;
175 while( $row = $dbr->fetchObject( $res ) ){
177 if ( !$feedFormat ) {
179 $title = Title
::makeTitleSafe( NS_USER
, $row->rc_user_text
);
180 $batch->addObj( $title );
183 $title = Title
::makeTitleSafe( NS_USER_TALK
, $row->rc_user_text
);
184 $batch->addObj( $title );
188 $dbr->freeResult( $res );
191 rcOutputFeed( $rows, $feedFormat, $limit, $hideminor, $lastmod );
196 // Run existence checks
198 $any = $wgRequest->getBool( 'categories_any', $defaults['categories_any']);
201 if ( !$specialPage->including() ) {
202 $wgOut->addWikiText( wfMsgForContent( "recentchangestext" ) );
204 // Dump everything here
205 $nondefaults = array();
207 wfAppendToArrayIfNotDefault( 'days', $days, $defaults, $nondefaults);
208 wfAppendToArrayIfNotDefault( 'limit', $limit , $defaults, $nondefaults);
209 wfAppendToArrayIfNotDefault( 'hideminor', $hideminor, $defaults, $nondefaults);
210 wfAppendToArrayIfNotDefault( 'hidebots', $hidebots, $defaults, $nondefaults);
211 wfAppendToArrayIfNotDefault( 'hideanons', $hideanons, $defaults, $nondefaults );
212 wfAppendToArrayIfNotDefault( 'hideliu', $hideliu, $defaults, $nondefaults);
213 wfAppendToArrayIfNotDefault( 'hidepatrolled', $hidepatrolled, $defaults, $nondefaults);
214 wfAppendToArrayIfNotDefault( 'hidemyself', $hidemyself, $defaults, $nondefaults);
215 wfAppendToArrayIfNotDefault( 'from', $from, $defaults, $nondefaults);
216 wfAppendToArrayIfNotDefault( 'namespace', $namespace, $defaults, $nondefaults);
217 wfAppendToArrayIfNotDefault( 'invert', $invert, $defaults, $nondefaults);
218 wfAppendToArrayIfNotDefault( 'categories_any', $any, $defaults, $nondefaults);
220 // Add end of the texts
221 $wgOut->addHTML( '<div class="rcoptions">' . rcOptionsPanel( $defaults, $nondefaults ) . "\n" );
222 $wgOut->addHTML( rcNamespaceForm( $namespace, $invert, $nondefaults, $any ) . '</div>'."\n");
225 // And now for the content
226 $sk = $wgUser->getSkin();
227 $wgOut->setSyndicated( true );
229 $list = ChangesList
::newFromUser( $wgUser );
231 if ( $wgAllowCategorizedRecentChanges ) {
232 $categories = trim ( $wgRequest->getVal ( 'categories' , "" ) ) ;
233 $categories = str_replace ( "|" , "\n" , $categories ) ;
234 $categories = explode ( "\n" , $categories ) ;
235 rcFilterByCategories ( $rows , $categories , $any ) ;
238 $s = $list->beginRecentChangesList();
240 foreach( $rows as $obj ){
245 if ( ! ( $hideminor && $obj->rc_minor
) &&
246 ! ( $hidepatrolled && $obj->rc_patrolled
) ) {
247 $rc = RecentChange
::newFromRow( $obj );
248 $rc->counter
= $counter++
;
250 if ($wgShowUpdatedMarker
251 && !empty( $obj->wl_notificationtimestamp
)
252 && ($obj->rc_timestamp
>= $obj->wl_notificationtimestamp
)) {
253 $rc->notificationtimestamp
= true;
255 $rc->notificationtimestamp
= false;
258 if ($wgRCShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
259 $sql3 = "SELECT COUNT(*) AS n FROM $watchlist WHERE wl_title='" . $dbr->strencode($obj->rc_title
) ."' AND wl_namespace=$obj->rc_namespace" ;
260 $res3 = $dbr->query( $sql3, 'wfSpecialRecentChanges');
261 $x = $dbr->fetchObject( $res3 );
262 $rc->numberofWatchingusers
= $x->n
;
264 $rc->numberofWatchingusers
= 0;
266 $s .= $list->recentChangesLine( $rc, !empty( $obj->wl_user
) );
270 $s .= $list->endRecentChangesList();
271 $wgOut->addHTML( $s );
275 function rcFilterByCategories ( &$rows , $categories , $any ) {
276 require_once ( 'Categoryfinder.php' ) ;
280 foreach ( $categories AS $cat ) {
281 $cat = trim ( $cat ) ;
282 if ( $cat == "" ) continue ;
287 $articles = array () ;
289 foreach ( $rows AS $k => $r ) {
290 $nt = Title
::newFromText ( $r->rc_title
, $r->rc_namespace
) ;
291 $id = $nt->getArticleID() ;
292 if ( $id == 0 ) continue ; # Page might have been deleted...
293 if ( !in_array ( $id , $articles ) ) {
296 if ( !isset ( $a2r[$id] ) ) {
297 $a2r[$id] = array() ;
303 if ( count ( $articles ) == 0 OR count ( $cats ) == 0 )
307 $c = new Categoryfinder
;
308 $c->seed ( $articles , $cats , $any ?
"OR" : "AND" ) ;
309 $match = $c->run () ;
312 $newrows = array () ;
313 foreach ( $match AS $id ) {
314 foreach ( $a2r[$id] AS $rev ) {
316 $newrows[$k] = $rows[$k] ;
322 function rcOutputFeed( $rows, $feedFormat, $limit, $hideminor, $lastmod ) {
323 global $messageMemc, $wgDBname, $wgFeedCacheTimeout;
324 global $wgFeedClasses, $wgTitle, $wgSitename, $wgContLanguageCode;
326 if( !isset( $wgFeedClasses[$feedFormat] ) ) {
327 wfHttpError( 500, "Internal Server Error", "Unsupported feed type." );
331 $timekey = "$wgDBname:rcfeed:$feedFormat:timestamp";
332 $key = "$wgDBname:rcfeed:$feedFormat:limit:$limit:minor:$hideminor";
334 $feedTitle = $wgSitename . ' - ' . wfMsgForContent( 'recentchanges' ) .
335 ' [' . $wgContLanguageCode . ']';
336 $feed = new $wgFeedClasses[$feedFormat](
338 htmlspecialchars( wfMsgForContent( 'recentchangestext' ) ),
339 $wgTitle->getFullUrl() );
342 * Bumping around loading up diffs can be pretty slow, so where
343 * possible we want to cache the feed output so the next visitor
347 if( ( $wgFeedCacheTimeout > 0 ) && ( $feedLastmod = $messageMemc->get( $timekey ) ) ) {
349 * If the cached feed was rendered very recently, we may
350 * go ahead and use it even if there have been edits made
351 * since it was rendered. This keeps a swarm of requests
352 * from being too bad on a super-frequently edited wiki.
354 if( time() - wfTimestamp( TS_UNIX
, $feedLastmod )
355 < $wgFeedCacheTimeout
356 ||
wfTimestamp( TS_UNIX
, $feedLastmod )
357 > wfTimestamp( TS_UNIX
, $lastmod ) ) {
358 wfDebug( "RC: loading feed from cache ($key; $feedLastmod; $lastmod)...\n" );
359 $cachedFeed = $messageMemc->get( $key );
361 wfDebug( "RC: cached feed timestamp check failed ($feedLastmod; $lastmod)\n" );
364 if( is_string( $cachedFeed ) ) {
365 wfDebug( "RC: Outputting cached feed\n" );
366 $feed->httpHeaders();
369 wfDebug( "RC: rendering new feed and caching it\n" );
371 rcDoOutputFeed( $rows, $feed );
372 $cachedFeed = ob_get_contents();
375 $expire = 3600 * 24; # One day
376 $messageMemc->set( $key, $cachedFeed );
377 $messageMemc->set( $timekey, wfTimestamp( TS_MW
), $expire );
382 function rcDoOutputFeed( $rows, &$feed ) {
383 $fname = 'rcDoOutputFeed';
384 wfProfileIn( $fname );
388 # Merge adjacent edits by one user
391 foreach( $rows as $obj ) {
393 $obj->rc_namespace
>= 0 &&
394 $obj->rc_cur_id
== $sorted[$n-1]->rc_cur_id
&&
395 $obj->rc_user_text
== $sorted[$n-1]->rc_user_text
) {
396 $sorted[$n-1]->rc_last_oldid
= $obj->rc_last_oldid
;
404 foreach( $sorted as $obj ) {
405 $title = Title
::makeTitle( $obj->rc_namespace
, $obj->rc_title
);
406 $talkpage = $title->getTalkPage();
407 $item = new FeedItem(
408 $title->getPrefixedText(),
409 rcFormatDiff( $obj ),
410 $title->getFullURL(),
413 $talkpage->getFullURL()
415 $feed->outItem( $item );
418 wfProfileOut( $fname );
424 function rcCountLink( $lim, $d, $page='Recentchanges', $more='' ) {
425 global $wgUser, $wgLang, $wgContLang;
426 $sk = $wgUser->getSkin();
427 $s = $sk->makeKnownLink( $wgContLang->specialPage( $page ),
428 ($lim ?
$wgLang->formatNum( "{$lim}" ) : wfMsg( 'recentchangesall' ) ), "{$more}" .
429 ($d ?
"days={$d}&" : '') . 'limit='.$lim );
436 function rcDaysLink( $lim, $d, $page='Recentchanges', $more='' ) {
437 global $wgUser, $wgLang, $wgContLang;
438 $sk = $wgUser->getSkin();
439 $s = $sk->makeKnownLink( $wgContLang->specialPage( $page ),
440 ($d ?
$wgLang->formatNum( "{$d}" ) : wfMsg( 'recentchangesall' ) ), $more.'days='.$d .
441 ($lim ?
'&limit='.$lim : '') );
446 * Used by Recentchangeslinked
448 function rcDayLimitLinks( $days, $limit, $page='Recentchanges', $more='', $doall = false, $minorLink = '',
449 $botLink = '', $liuLink = '', $patrLink = '', $myselfLink = '' ) {
450 if ($more != '') $more .= '&';
451 $cl = rcCountLink( 50, $days, $page, $more ) . ' | ' .
452 rcCountLink( 100, $days, $page, $more ) . ' | ' .
453 rcCountLink( 250, $days, $page, $more ) . ' | ' .
454 rcCountLink( 500, $days, $page, $more ) .
455 ( $doall ?
( ' | ' . rcCountLink( 0, $days, $page, $more ) ) : '' );
456 $dl = rcDaysLink( $limit, 1, $page, $more ) . ' | ' .
457 rcDaysLink( $limit, 3, $page, $more ) . ' | ' .
458 rcDaysLink( $limit, 7, $page, $more ) . ' | ' .
459 rcDaysLink( $limit, 14, $page, $more ) . ' | ' .
460 rcDaysLink( $limit, 30, $page, $more ) .
461 ( $doall ?
( ' | ' . rcDaysLink( $limit, 0, $page, $more ) ) : '' );
463 $linkParts = array( 'minorLink' => 'minor', 'botLink' => 'bots', 'liuLink' => 'liu', 'patrLink' => 'patr', 'myselfLink' => 'mine' );
464 foreach( $linkParts as $linkVar => $linkMsg ) {
465 if( $
$linkVar != '' )
466 $links[] = wfMsgHtml( 'rcshowhide' . $linkMsg, $
$linkVar );
469 $shm = implode( ' | ', $links );
470 $note = wfMsg( 'rclinks', $cl, $dl, $shm );
476 * Makes change an option link which carries all the other options
478 function makeOptionsLink( $title, $override, $options ) {
479 global $wgUser, $wgContLang;
480 $sk = $wgUser->getSkin();
481 return $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchanges' ),
482 $title, wfArrayToCGI( $override, $options ) );
486 * Creates the options panel
488 function rcOptionsPanel( $defaults, $nondefaults ) {
489 global $wgLang, $wgUseRCPatrol;
491 $options = $nondefaults +
$defaults;
493 if( $options['from'] )
494 $note = wfMsg( 'rcnotefrom', $wgLang->formatNum( $options['limit'] ), $wgLang->timeanddate( $options['from'], true ) );
496 $note = wfMsg( 'rcnote', $wgLang->formatNum( $options['limit'] ), $wgLang->formatNum( $options['days'] ) );
500 $options_limit = array(50, 100, 250, 500);
502 while ( $i+
1 < count($options_limit) ) {
503 $cl .= makeOptionsLink( $options_limit[$i], array( 'limit' => $options_limit[$i] ), $nondefaults) . ' | ' ;
506 $cl .= makeOptionsLink( $options_limit[$i], array( 'limit' => $options_limit[$i] ), $nondefaults) ;
508 // day links, reset 'from' to none
510 $options_days = array(1, 3, 7, 14, 30);
512 while ( $i+
1 < count($options_days) ) {
513 $dl .= makeOptionsLink( $options_days[$i], array( 'days' => $options_days[$i], 'from' => '' ), $nondefaults) . ' | ' ;
516 $dl .= makeOptionsLink( $options_days[$i], array( 'days' => $options_days[$i], 'from' => '' ), $nondefaults) ;
519 $showhide = array( wfMsg( 'show' ), wfMsg( 'hide' ));
520 $minorLink = makeOptionsLink( $showhide[1-$options['hideminor']],
521 array( 'hideminor' => 1-$options['hideminor'] ), $nondefaults);
522 $botLink = makeOptionsLink( $showhide[1-$options['hidebots']],
523 array( 'hidebots' => 1-$options['hidebots'] ), $nondefaults);
524 $anonsLink = makeOptionsLink( $showhide[ 1 - $options['hideanons'] ],
525 array( 'hideanons' => 1 - $options['hideanons'] ), $nondefaults );
526 $liuLink = makeOptionsLink( $showhide[1-$options['hideliu']],
527 array( 'hideliu' => 1-$options['hideliu'] ), $nondefaults);
528 $patrLink = makeOptionsLink( $showhide[1-$options['hidepatrolled']],
529 array( 'hidepatrolled' => 1-$options['hidepatrolled'] ), $nondefaults);
530 $myselfLink = makeOptionsLink( $showhide[1-$options['hidemyself']],
531 array( 'hidemyself' => 1-$options['hidemyself'] ), $nondefaults);
533 $links[] = wfMsgHtml( 'rcshowhideminor', $minorLink );
534 $links[] = wfMsgHtml( 'rcshowhidebots', $botLink );
535 $links[] = wfMsgHtml( 'rcshowhideanons', $anonsLink );
536 $links[] = wfMsgHtml( 'rcshowhideliu', $liuLink );
538 $links[] = wfMsgHtml( 'rcshowhidepatr', $patrLink );
539 $links[] = wfMsgHtml( 'rcshowhidemine', $myselfLink );
540 $hl = implode( ' | ', $links );
542 // show from this onward link
543 $now = $wgLang->timeanddate( wfTimestampNow(), true );
544 $tl = makeOptionsLink( $now, array( 'from' => wfTimestampNow()), $nondefaults );
546 $rclinks = wfMsg( 'rclinks', $cl, $dl, $hl );
547 $rclistfrom = wfMsg( 'rclistfrom', $tl );
548 return "$note<br />$rclinks<br />$rclistfrom";
553 * Creates the choose namespace selection
557 * @param mixed $namespace The key of the currently selected namespace, empty string
559 * @param bool $invert Whether to invert the namespace selection
560 * @param array $nondefaults An array of non default options to be remembered
561 * @param bool $categories_any Default value for the checkbox
565 function rcNamespaceForm( $namespace, $invert, $nondefaults, $categories_any ) {
566 global $wgScript, $wgAllowCategorizedRecentChanges, $wgRequest;
567 $t = Title
::makeTitle( NS_SPECIAL
, 'Recentchanges' );
569 $namespaceselect = HTMLnamespaceselector($namespace, '');
570 $submitbutton = '<input type="submit" value="' . wfMsgHtml( 'allpagessubmit' ) . "\" />\n";
571 $invertbox = "<input type='checkbox' name='invert' value='1' id='nsinvert'" . ( $invert ?
' checked="checked"' : '' ) . ' />';
573 if ( $wgAllowCategorizedRecentChanges ) {
574 $categories = trim ( $wgRequest->getVal ( 'categories' , "" ) ) ;
575 $cb_arr = array( 'type' => 'checkbox', 'name' => 'categories_any', 'value' => "1" ) ;
576 if ( $categories_any ) $cb_arr['checked'] = "checked" ;
578 $catbox .= wfMsg('rc_categories') . " ";
579 $catbox .= wfElement('input', array( 'type' => 'text', 'name' => 'categories', 'value' => $categories));
580 $catbox .= " " ;
581 $catbox .= wfElement('input', $cb_arr );
582 $catbox .= wfMsg('rc_categories_any');
587 $out = "<div class='namespacesettings'><form method='get' action='{$wgScript}'>\n";
589 foreach ( $nondefaults as $key => $value ) {
590 if ($key != 'namespace' && $key != 'invert')
591 $out .= wfElement('input', array( 'type' => 'hidden', 'name' => $key, 'value' => $value));
594 $out .= '<input type="hidden" name="title" value="'.$t->getPrefixedText().'" />';
596 <div id='nsselect' class='recentchanges'>
597 <label for='namespace'>" . wfMsgHtml('namespace') . "</label>
598 {$namespaceselect}{$submitbutton}{$invertbox} <label for='nsinvert'>" . wfMsgHtml('invert') . "</label>{$catbox}\n</div>";
599 $out .= '</form></div>';
605 * Format a diff for the newsfeed
607 function rcFormatDiff( $row ) {
608 global $wgFeedDiffCutoff, $wgContLang;
609 $fname = 'rcFormatDiff';
610 wfProfileIn( $fname );
612 require_once( 'DifferenceEngine.php' );
613 $completeText = '<p>' . htmlspecialchars( $row->rc_comment
) . "</p>\n";
615 if( $row->rc_namespace
>= 0 ) {
616 if( $row->rc_last_oldid
) {
617 wfProfileIn( "$fname-dodiff" );
619 $titleObj = Title
::makeTitle( $row->rc_namespace
, $row->rc_title
);
620 $de = new DifferenceEngine( $titleObj, $row->rc_last_oldid
, $row->rc_this_oldid
);
621 $diffText = $de->getDiff( wfMsg( 'revisionasof', $wgContLang->timeanddate( $row->rc_timestamp
) ),
622 wfMsg( 'currentrev' ) );
624 if ( strlen( $diffText ) > $wgFeedDiffCutoff ) {
626 $diffLink = $titleObj->escapeFullUrl(
627 'diff=' . $row->rc_this_oldid
.
628 '&oldid=' . $row->rc_last_oldid
);
629 $diffText = '<a href="' .
632 htmlspecialchars( wfMsgForContent( 'difference' ) ) .
634 } elseif ( $diffText === false ) {
635 // Error in diff engine, probably a missing revision
636 $diffText = "<p>Can't load revision $row->rc_this_oldid</p>";
638 // Diff output fine, clean up any illegal UTF-8
639 $diffText = UtfNormal
::cleanUp( $diffText );
640 $diffText = rcApplyDiffStyle( $diffText );
642 wfProfileOut( "$fname-dodiff" );
644 $rev = Revision
::newFromId( $row->rc_this_oldid
);
645 if( is_null( $rev ) ) {
648 $newtext = $rev->getText();
650 $diffText = '<p><b>' . wfMsg( 'newpage' ) . '</b></p>' .
651 '<div>' . nl2br( htmlspecialchars( $newtext ) ) . '</div>';
653 $completeText .= $diffText;
656 wfProfileOut( $fname );
657 return $completeText;
661 * Hacky application of diff styles for the feeds.
662 * Might be 'cleaner' to use DOM or XSLT or something,
663 * but *gack* it's a pain in the ass.
665 * @param string $text
669 function rcApplyDiffStyle( $text ) {
671 'diff' => 'background-color: white;',
672 'diff-otitle' => 'background-color: white;',
673 'diff-ntitle' => 'background-color: white;',
674 'diff-addedline' => 'background: #cfc; font-size: smaller;',
675 'diff-deletedline' => 'background: #ffa; font-size: smaller;',
676 'diff-context' => 'background: #eee; font-size: smaller;',
677 'diffchange' => 'color: red; font-weight: bold;',
680 foreach( $styles as $class => $style ) {
681 $text = preg_replace( "/(<[^>]+)class=(['\"])$class\\2([^>]*>)/",
682 "\\1style=\"$style\"\\3", $text );