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 $hidem = $hideminor ?
'AND rc_minor=0' : '';
138 $hidem .= $hidebots ?
' AND rc_bot=0' : '';
139 $hidem .= ( $hideliu && !$hidemyself ) ?
' AND rc_user=0' : '';
140 $hidem .= $hidepatrolled ?
' AND rc_patrolled=0' : '';
141 $hidem .= ( $hideanons && !$hideliu ) ?
' AND rc_user <> 0' : '';
143 if ( $wgUser->getID() ) {
144 $hidem .= ' AND rc_user <> '.$wgUser->getID();
146 $hidem .= ' AND rc_user_text<>' . $dbr->addQuotes( $wgUser->getName() );
149 $hidem .= is_null( $namespace ) ?
'' : ' AND rc_namespace' . ($invert ?
'!=' : '=') . $namespace;
151 // This is the big thing!
153 $uid = $wgUser->getID();
156 $sql2 = "SELECT * FROM $recentchanges FORCE INDEX (rc_timestamp) " .
157 ($uid ?
"LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") .
158 "WHERE rc_timestamp >= '{$cutoff}' {$hidem} " .
159 "ORDER BY rc_timestamp DESC";
160 $sql2 = $dbr->limitResult($sql2, $limit, 0);
161 $res = $dbr->query( $sql2, $fname );
163 // Fetch results, prepare a batch link existence check query
165 $batch = new LinkBatch
;
166 while( $row = $dbr->fetchObject( $res ) ){
168 if ( !$feedFormat ) {
170 $title = Title
::makeTitleSafe( NS_USER
, $row->rc_user_text
);
171 $batch->addObj( $title );
174 $title = Title
::makeTitleSafe( NS_USER_TALK
, $row->rc_user_text
);
175 $batch->addObj( $title );
179 $dbr->freeResult( $res );
182 rcOutputFeed( $rows, $feedFormat, $limit, $hideminor, $lastmod );
187 // Run existence checks
189 $any = $wgRequest->getBool( 'categories_any', $defaults['categories_any']);
192 if ( !$specialPage->including() ) {
193 $wgOut->addWikiText( wfMsgForContent( "recentchangestext" ) );
195 // Dump everything here
196 $nondefaults = array();
198 wfAppendToArrayIfNotDefault( 'days', $days, $defaults, $nondefaults);
199 wfAppendToArrayIfNotDefault( 'limit', $limit , $defaults, $nondefaults);
200 wfAppendToArrayIfNotDefault( 'hideminor', $hideminor, $defaults, $nondefaults);
201 wfAppendToArrayIfNotDefault( 'hidebots', $hidebots, $defaults, $nondefaults);
202 wfAppendToArrayIfNotDefault( 'hideanons', $hideanons, $defaults, $nondefaults );
203 wfAppendToArrayIfNotDefault( 'hideliu', $hideliu, $defaults, $nondefaults);
204 wfAppendToArrayIfNotDefault( 'hidepatrolled', $hidepatrolled, $defaults, $nondefaults);
205 wfAppendToArrayIfNotDefault( 'hidemyself', $hidemyself, $defaults, $nondefaults);
206 wfAppendToArrayIfNotDefault( 'from', $from, $defaults, $nondefaults);
207 wfAppendToArrayIfNotDefault( 'namespace', $namespace, $defaults, $nondefaults);
208 wfAppendToArrayIfNotDefault( 'invert', $invert, $defaults, $nondefaults);
209 wfAppendToArrayIfNotDefault( 'categories_any', $any, $defaults, $nondefaults);
211 // Add end of the texts
212 $wgOut->addHTML( '<div class="rcoptions">' . rcOptionsPanel( $defaults, $nondefaults ) . "\n" );
213 $wgOut->addHTML( rcNamespaceForm( $namespace, $invert, $nondefaults, $any ) . '</div>'."\n");
216 // And now for the content
217 $sk = $wgUser->getSkin();
218 $wgOut->setSyndicated( true );
220 $list = ChangesList
::newFromUser( $wgUser );
222 if ( $wgAllowCategorizedRecentChanges ) {
223 $categories = trim ( $wgRequest->getVal ( 'categories' , "" ) ) ;
224 $categories = str_replace ( "|" , "\n" , $categories ) ;
225 $categories = explode ( "\n" , $categories ) ;
226 rcFilterByCategories ( $rows , $categories , $any ) ;
229 $s = $list->beginRecentChangesList();
231 foreach( $rows as $obj ){
236 if ( ! ( $hideminor && $obj->rc_minor
) &&
237 ! ( $hidepatrolled && $obj->rc_patrolled
) ) {
238 $rc = RecentChange
::newFromRow( $obj );
239 $rc->counter
= $counter++
;
241 if ($wgShowUpdatedMarker
242 && !empty( $obj->wl_notificationtimestamp
)
243 && ($obj->rc_timestamp
>= $obj->wl_notificationtimestamp
)) {
244 $rc->notificationtimestamp
= true;
246 $rc->notificationtimestamp
= false;
249 if ($wgRCShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
250 $sql3 = "SELECT COUNT(*) AS n FROM $watchlist WHERE wl_title='" . $dbr->strencode($obj->rc_title
) ."' AND wl_namespace=$obj->rc_namespace" ;
251 $res3 = $dbr->query( $sql3, 'wfSpecialRecentChanges');
252 $x = $dbr->fetchObject( $res3 );
253 $rc->numberofWatchingusers
= $x->n
;
255 $rc->numberofWatchingusers
= 0;
257 $s .= $list->recentChangesLine( $rc, !empty( $obj->wl_user
) );
261 $s .= $list->endRecentChangesList();
262 $wgOut->addHTML( $s );
266 function rcFilterByCategories ( &$rows , $categories , $any ) {
267 require_once ( 'Categoryfinder.php' ) ;
271 foreach ( $categories AS $cat ) {
272 $cat = trim ( $cat ) ;
273 if ( $cat == "" ) continue ;
278 $articles = array () ;
280 foreach ( $rows AS $k => $r ) {
281 $nt = Title
::newFromText ( $r->rc_title
, $r->rc_namespace
) ;
282 $id = $nt->getArticleID() ;
283 if ( $id == 0 ) continue ; # Page might have been deleted...
284 if ( !in_array ( $id , $articles ) ) {
287 if ( !isset ( $a2r[$id] ) ) {
288 $a2r[$id] = array() ;
294 if ( count ( $articles ) == 0 OR count ( $cats ) == 0 )
298 $c = new Categoryfinder
;
299 $c->seed ( $articles , $cats , $any ?
"OR" : "AND" ) ;
300 $match = $c->run () ;
303 $newrows = array () ;
304 foreach ( $match AS $id ) {
305 foreach ( $a2r[$id] AS $rev ) {
307 $newrows[$k] = $rows[$k] ;
313 function rcOutputFeed( $rows, $feedFormat, $limit, $hideminor, $lastmod ) {
314 global $messageMemc, $wgDBname, $wgFeedCacheTimeout;
315 global $wgFeedClasses, $wgTitle, $wgSitename, $wgContLanguageCode;
317 if( !isset( $wgFeedClasses[$feedFormat] ) ) {
318 wfHttpError( 500, "Internal Server Error", "Unsupported feed type." );
322 $timekey = "$wgDBname:rcfeed:$feedFormat:timestamp";
323 $key = "$wgDBname:rcfeed:$feedFormat:limit:$limit:minor:$hideminor";
325 $feedTitle = $wgSitename . ' - ' . wfMsgForContent( 'recentchanges' ) .
326 ' [' . $wgContLanguageCode . ']';
327 $feed = new $wgFeedClasses[$feedFormat](
329 htmlspecialchars( wfMsgForContent( 'recentchangestext' ) ),
330 $wgTitle->getFullUrl() );
333 * Bumping around loading up diffs can be pretty slow, so where
334 * possible we want to cache the feed output so the next visitor
338 if( ( $wgFeedCacheTimeout > 0 ) && ( $feedLastmod = $messageMemc->get( $timekey ) ) ) {
340 * If the cached feed was rendered very recently, we may
341 * go ahead and use it even if there have been edits made
342 * since it was rendered. This keeps a swarm of requests
343 * from being too bad on a super-frequently edited wiki.
345 if( time() - wfTimestamp( TS_UNIX
, $feedLastmod )
346 < $wgFeedCacheTimeout
347 ||
wfTimestamp( TS_UNIX
, $feedLastmod )
348 > wfTimestamp( TS_UNIX
, $lastmod ) ) {
349 wfDebug( "RC: loading feed from cache ($key; $feedLastmod; $lastmod)...\n" );
350 $cachedFeed = $messageMemc->get( $key );
352 wfDebug( "RC: cached feed timestamp check failed ($feedLastmod; $lastmod)\n" );
355 if( is_string( $cachedFeed ) ) {
356 wfDebug( "RC: Outputting cached feed\n" );
357 $feed->httpHeaders();
360 wfDebug( "RC: rendering new feed and caching it\n" );
362 rcDoOutputFeed( $rows, $feed );
363 $cachedFeed = ob_get_contents();
366 $expire = 3600 * 24; # One day
367 $messageMemc->set( $key, $cachedFeed );
368 $messageMemc->set( $timekey, wfTimestamp( TS_MW
), $expire );
373 function rcDoOutputFeed( $rows, &$feed ) {
374 $fname = 'rcDoOutputFeed';
375 wfProfileIn( $fname );
379 # Merge adjacent edits by one user
382 foreach( $rows as $obj ) {
384 $obj->rc_namespace
>= 0 &&
385 $obj->rc_cur_id
== $sorted[$n-1]->rc_cur_id
&&
386 $obj->rc_user_text
== $sorted[$n-1]->rc_user_text
) {
387 $sorted[$n-1]->rc_last_oldid
= $obj->rc_last_oldid
;
395 foreach( $sorted as $obj ) {
396 $title = Title
::makeTitle( $obj->rc_namespace
, $obj->rc_title
);
397 $talkpage = $title->getTalkPage();
398 $item = new FeedItem(
399 $title->getPrefixedText(),
400 rcFormatDiff( $obj ),
401 $title->getFullURL(),
404 $talkpage->getFullURL()
406 $feed->outItem( $item );
409 wfProfileOut( $fname );
415 function rcCountLink( $lim, $d, $page='Recentchanges', $more='' ) {
416 global $wgUser, $wgLang, $wgContLang;
417 $sk = $wgUser->getSkin();
418 $s = $sk->makeKnownLink( $wgContLang->specialPage( $page ),
419 ($lim ?
$wgLang->formatNum( "{$lim}" ) : wfMsg( 'recentchangesall' ) ), "{$more}" .
420 ($d ?
"days={$d}&" : '') . 'limit='.$lim );
427 function rcDaysLink( $lim, $d, $page='Recentchanges', $more='' ) {
428 global $wgUser, $wgLang, $wgContLang;
429 $sk = $wgUser->getSkin();
430 $s = $sk->makeKnownLink( $wgContLang->specialPage( $page ),
431 ($d ?
$wgLang->formatNum( "{$d}" ) : wfMsg( 'recentchangesall' ) ), $more.'days='.$d .
432 ($lim ?
'&limit='.$lim : '') );
437 * Used by Recentchangeslinked
439 function rcDayLimitLinks( $days, $limit, $page='Recentchanges', $more='', $doall = false, $minorLink = '',
440 $botLink = '', $liuLink = '', $patrLink = '', $myselfLink = '' ) {
441 if ($more != '') $more .= '&';
442 $cl = rcCountLink( 50, $days, $page, $more ) . ' | ' .
443 rcCountLink( 100, $days, $page, $more ) . ' | ' .
444 rcCountLink( 250, $days, $page, $more ) . ' | ' .
445 rcCountLink( 500, $days, $page, $more ) .
446 ( $doall ?
( ' | ' . rcCountLink( 0, $days, $page, $more ) ) : '' );
447 $dl = rcDaysLink( $limit, 1, $page, $more ) . ' | ' .
448 rcDaysLink( $limit, 3, $page, $more ) . ' | ' .
449 rcDaysLink( $limit, 7, $page, $more ) . ' | ' .
450 rcDaysLink( $limit, 14, $page, $more ) . ' | ' .
451 rcDaysLink( $limit, 30, $page, $more ) .
452 ( $doall ?
( ' | ' . rcDaysLink( $limit, 0, $page, $more ) ) : '' );
453 $shm = wfMsg( 'showhideminor', $minorLink, $botLink, $liuLink, $patrLink, $myselfLink );
454 $note = wfMsg( 'rclinks', $cl, $dl, $shm );
460 * Makes change an option link which carries all the other options
462 function makeOptionsLink( $title, $override, $options ) {
463 global $wgUser, $wgContLang;
464 $sk = $wgUser->getSkin();
465 return $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchanges' ),
466 $title, wfArrayToCGI( $override, $options ) );
470 * Creates the options panel
472 function rcOptionsPanel( $defaults, $nondefaults ) {
475 $options = $nondefaults +
$defaults;
477 if( $options['from'] )
478 $note = wfMsg( 'rcnotefrom', $wgLang->formatNum( $options['limit'] ), $wgLang->timeanddate( $options['from'], true ) );
480 $note = wfMsg( 'rcnote', $wgLang->formatNum( $options['limit'] ), $wgLang->formatNum( $options['days'] ) );
484 $options_limit = array(50, 100, 250, 500);
486 while ( $i+
1 < count($options_limit) ) {
487 $cl .= makeOptionsLink( $options_limit[$i], array( 'limit' => $options_limit[$i] ), $nondefaults) . ' | ' ;
490 $cl .= makeOptionsLink( $options_limit[$i], array( 'limit' => $options_limit[$i] ), $nondefaults) ;
492 // day links, reset 'from' to none
494 $options_days = array(1, 3, 7, 14, 30);
496 while ( $i+
1 < count($options_days) ) {
497 $dl .= makeOptionsLink( $options_days[$i], array( 'days' => $options_days[$i], 'from' => '' ), $nondefaults) . ' | ' ;
500 $dl .= makeOptionsLink( $options_days[$i], array( 'days' => $options_days[$i], 'from' => '' ), $nondefaults) ;
503 $showhide = array( wfMsg( 'show' ), wfMsg( 'hide' ));
504 $minorLink = makeOptionsLink( $showhide[1-$options['hideminor']],
505 array( 'hideminor' => 1-$options['hideminor'] ), $nondefaults);
506 $botLink = makeOptionsLink( $showhide[1-$options['hidebots']],
507 array( 'hidebots' => 1-$options['hidebots'] ), $nondefaults);
508 $anonsLink = makeOptionsLink( $showhide[ 1 - $options['hideanons'] ],
509 array( 'hideanons' => 1 - $options['hideanons'] ), $nondefaults );
510 $liuLink = makeOptionsLink( $showhide[1-$options['hideliu']],
511 array( 'hideliu' => 1-$options['hideliu'] ), $nondefaults);
512 $patrLink = makeOptionsLink( $showhide[1-$options['hidepatrolled']],
513 array( 'hidepatrolled' => 1-$options['hidepatrolled'] ), $nondefaults);
514 $myselfLink = makeOptionsLink( $showhide[1-$options['hidemyself']],
515 array( 'hidemyself' => 1-$options['hidemyself'] ), $nondefaults);
516 $hl = wfMsg( 'showhideminor', $minorLink, $botLink, $liuLink, $patrLink, $myselfLink, $anonsLink );
518 // show from this onward link
519 $now = $wgLang->timeanddate( wfTimestampNow(), true );
520 $tl = makeOptionsLink( $now, array( 'from' => wfTimestampNow()), $nondefaults );
522 $rclinks = wfMsg( 'rclinks', $cl, $dl, $hl );
523 $rclistfrom = wfMsg( 'rclistfrom', $tl );
524 return "$note<br />$rclinks<br />$rclistfrom";
529 * Creates the choose namespace selection
533 * @param mixed $namespace The key of the currently selected namespace, empty string
535 * @param bool $invert Whether to invert the namespace selection
536 * @param array $nondefaults An array of non default options to be remembered
537 * @param bool $categories_any Default value for the checkbox
541 function rcNamespaceForm( $namespace, $invert, $nondefaults, $categories_any ) {
542 global $wgScript, $wgAllowCategorizedRecentChanges, $wgRequest;
543 $t = Title
::makeTitle( NS_SPECIAL
, 'Recentchanges' );
545 $namespaceselect = HTMLnamespaceselector($namespace, '');
546 $submitbutton = '<input type="submit" value="' . wfMsgHtml( 'allpagessubmit' ) . "\" />\n";
547 $invertbox = "<input type='checkbox' name='invert' value='1' id='nsinvert'" . ( $invert ?
' checked="checked"' : '' ) . ' />';
549 if ( $wgAllowCategorizedRecentChanges ) {
550 $categories = trim ( $wgRequest->getVal ( 'categories' , "" ) ) ;
551 $cb_arr = array( 'type' => 'checkbox', 'name' => 'categories_any', 'value' => "1" ) ;
552 if ( $categories_any ) $cb_arr['checked'] = "checked" ;
554 $catbox .= wfMsg('rc_categories') . " ";
555 $catbox .= wfElement('input', array( 'type' => 'text', 'name' => 'categories', 'value' => $categories));
556 $catbox .= " " ;
557 $catbox .= wfElement('input', $cb_arr );
558 $catbox .= wfMsg('rc_categories_any');
563 $out = "<div class='namespacesettings'><form method='get' action='{$wgScript}'>\n";
565 foreach ( $nondefaults as $key => $value ) {
566 if ($key != 'namespace' && $key != 'invert')
567 $out .= wfElement('input', array( 'type' => 'hidden', 'name' => $key, 'value' => $value));
570 $out .= '<input type="hidden" name="title" value="'.$t->getPrefixedText().'" />';
572 <div id='nsselect' class='recentchanges'>
573 <label for='namespace'>" . wfMsgHtml('namespace') . "</label>
574 {$namespaceselect}{$submitbutton}{$invertbox} <label for='nsinvert'>" . wfMsgHtml('invert') . "</label>{$catbox}\n</div>";
575 $out .= '</form></div>';
581 * Format a diff for the newsfeed
583 function rcFormatDiff( $row ) {
584 global $wgFeedDiffCutoff, $wgContLang;
585 $fname = 'rcFormatDiff';
586 wfProfileIn( $fname );
588 require_once( 'DifferenceEngine.php' );
589 $completeText = '<p>' . htmlspecialchars( $row->rc_comment
) . "</p>\n";
591 if( $row->rc_namespace
>= 0 ) {
592 if( $row->rc_last_oldid
) {
593 wfProfileIn( "$fname-dodiff" );
595 $titleObj = Title
::makeTitle( $row->rc_namespace
, $row->rc_title
);
596 $de = new DifferenceEngine( $titleObj, $row->rc_last_oldid
, $row->rc_this_oldid
);
597 $diffText = $de->getDiff( wfMsg( 'revisionasof', $wgContLang->timeanddate( $row->rc_timestamp
) ),
598 wfMsg( 'currentrev' ) );
600 if ( strlen( $diffText ) > $wgFeedDiffCutoff ) {
602 $diffLink = $titleObj->escapeFullUrl(
603 'diff=' . $row->rc_this_oldid
.
604 '&oldid=' . $row->rc_last_oldid
);
605 $diffText = '<a href="' .
608 htmlspecialchars( wfMsgForContent( 'difference' ) ) .
610 } elseif ( $diffText === false ) {
611 // Error in diff engine, probably a missing revision
612 $diffText = "<p>Can't load revision $row->rc_this_oldid</p>";
614 // Diff output fine, clean up any illegal UTF-8
615 $diffText = UtfNormal
::cleanUp( $diffText );
616 $diffText = rcApplyDiffStyle( $diffText );
618 wfProfileOut( "$fname-dodiff" );
620 $rev = Revision
::newFromId( $row->rc_this_oldid
);
621 if( is_null( $rev ) ) {
624 $newtext = $rev->getText();
626 $diffText = '<p><b>' . wfMsg( 'newpage' ) . '</b></p>' .
627 '<div>' . nl2br( htmlspecialchars( $newtext ) ) . '</div>';
629 $completeText .= $diffText;
632 wfProfileOut( $fname );
633 return $completeText;
637 * Hacky application of diff styles for the feeds.
638 * Might be 'cleaner' to use DOM or XSLT or something,
639 * but *gack* it's a pain in the ass.
641 * @param string $text
645 function rcApplyDiffStyle( $text ) {
647 'diff' => 'background-color: white;',
648 'diff-otitle' => 'background-color: white;',
649 'diff-ntitle' => 'background-color: white;',
650 'diff-addedline' => 'background: #cfc; font-size: smaller;',
651 'diff-deletedline' => 'background: #ffa; font-size: smaller;',
652 'diff-context' => 'background: #eee; font-size: smaller;',
653 'diffchange' => 'color: red; font-weight: bold;',
656 foreach( $styles as $class => $style ) {
657 $text = preg_replace( "/(<[^>]+)class=(['\"])$class\\2([^>]*>)/",
658 "\\1style=\"$style\"\\3", $text );