6 class RCCacheEntry
extends RecentChange
8 var $secureName, $link;
9 var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ;
10 var $userlink, $timestamp, $watched;
12 static function newFromParent( $rc ) {
13 $rc2 = new RCCacheEntry
;
14 $rc2->mAttribs
= $rc->mAttribs
;
15 $rc2->mExtra
= $rc->mExtra
;
21 * Class to show various lists of changes:
27 # Called by history lists and recent changes
31 * Changeslist contructor
34 function __construct( &$skin ) {
36 $this->preCacheMessages();
40 * Fetch an appropriate changes list class for the specified user
41 * Some users might want to use an enhanced list format, for instance
43 * @param $user User to fetch the list class for
44 * @return ChangesList derivative
46 public static function newFromUser( &$user ) {
47 $sk = $user->getSkin();
49 if( wfRunHooks( 'FetchChangesList', array( &$user, &$sk, &$list ) ) ) {
50 return $user->getOption( 'usenewrc' ) ?
new EnhancedChangesList( $sk ) : new OldChangesList( $sk );
57 * As we use the same small set of messages in various methods and that
58 * they are called often, we call them once and save them in $this->message
60 private function preCacheMessages() {
61 // Precache various messages
62 if( !isset( $this->message
) ) {
63 foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last '.
64 'blocklink history boteditletter semicolon-separator' ) as $msg ) {
65 $this->message
[$msg] = wfMsgExt( $msg, array( 'escape') );
72 * Returns the appropriate flags for new page, minor change and patrolling
75 * @param bool $patrolled
76 * @param string $nothing, string to use for empty space
80 protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = ' ', $bot = false ) {
81 $f = $new ?
'<span class="newpage">' . $this->message
['newpageletter'] . '</span>'
83 $f .= $minor ?
'<span class="minor">' . $this->message
['minoreditletter'] . '</span>'
85 $f .= $bot ?
'<span class="bot">' . $this->message
['boteditletter'] . '</span>' : $nothing;
86 $f .= $patrolled ?
'<span class="unpatrolled">!</span>' : $nothing;
91 * Returns text for the start of the tabular part of RC
94 public function beginRecentChangesList() {
95 $this->rc_cache
= array();
96 $this->rcMoveIndex
= 0;
97 $this->rcCacheIndex
= 0;
99 $this->rclistOpen
= false;
104 * Returns text for the end of RC
107 public function endRecentChangesList() {
108 if( $this->rclistOpen
) {
115 protected function insertMove( &$s, $rc ) {
117 $s .= '(' . $this->message
['diff'] . ') (';
119 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $this->message
['hist'], 'action=history' ) .
122 # "[[x]] moved to [[y]]"
123 $msg = ( $rc->mAttribs
['rc_type'] == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
124 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
125 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
128 protected function insertDateHeader(&$s, $rc_timestamp) {
131 # Make date header if necessary
132 $date = $wgLang->date( $rc_timestamp, true, true );
134 if( $date != $this->lastdate
) {
135 if( '' != $this->lastdate
) {
138 $s .= '<h4>'.$date."</h4>\n<ul class=\"special\">";
139 $this->lastdate
= $date;
140 $this->rclistOpen
= true;
144 protected function insertLog(&$s, $title, $logtype) {
145 $logname = LogPage
::logName( $logtype );
146 $s .= '(' . $this->skin
->makeKnownLinkObj($title, $logname ) . ')';
149 protected function insertDiffHist(&$s, &$rc, $unpatrolled) {
151 if( !$this->userCan($rc,Revision
::DELETED_TEXT
) ) {
152 $diffLink = $this->message
['diff'];
153 } else if( $rc->mAttribs
['rc_type'] == RC_NEW ||
$rc->mAttribs
['rc_type'] == RC_LOG
) {
154 $diffLink = $this->message
['diff'];
156 $rcidparam = $unpatrolled
157 ?
array( 'rcid' => $rc->mAttribs
['rc_id'] )
159 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['diff'],
161 'curid' => $rc->mAttribs
['rc_cur_id'],
162 'diff' => $rc->mAttribs
['rc_this_oldid'],
163 'oldid' => $rc->mAttribs
['rc_last_oldid'] ),
165 '', '', ' tabindex="'.$rc->counter
.'"');
167 $s .= '('.$diffLink.') (';
170 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['hist'],
172 'curid' => $rc->mAttribs
['rc_cur_id'],
173 'action' => 'history' ) ) );
177 protected function insertArticleLink(&$s, &$rc, $unpatrolled, $watched) {
179 # If it's a new article, there is no diff link, but if it hasn't been
180 # patrolled yet, we need to give users a way to do so
181 $params = ( $unpatrolled && $rc->mAttribs
['rc_type'] == RC_NEW
)
182 ?
'rcid='.$rc->mAttribs
['rc_id']
184 if( $this->isDeleted($rc,Revision
::DELETED_TEXT
) ) {
185 $articlelink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', $params );
186 $articlelink = '<span class="history-deleted">'.$articlelink.'</span>';
188 $articlelink = ' '. $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', $params );
191 $articlelink = "<strong class=\"mw-watched\">{$articlelink}</strong>";
193 $articlelink .= $wgContLang->getDirMark();
195 wfRunHooks('ChangesListInsertArticleLink',
196 array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched));
198 $s .= ' '.$articlelink;
201 protected function insertTimestamp(&$s, $rc) {
204 $s .= $this->message
['semicolon-separator'] . ' ' . $wgLang->time( $rc->mAttribs
['rc_timestamp'], true, true ) . ' . . ';
207 /** Insert links to user page, user talk page and eventually a blocking link */
208 protected function insertUserRelatedLinks(&$s, &$rc) {
209 if ( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
210 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
212 $s .= $this->skin
->userLink( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
213 $s .= $this->skin
->userToolLinks( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
217 /** insert a formatted action */
218 protected function insertAction(&$s, &$rc) {
220 if( $rc->mAttribs
['rc_type'] == RC_LOG
) {
222 if ( $this->isDeleted($rc,LogPage
::DELETED_ACTION
) ) {
223 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
225 $s .= ' ' . LogPage
::actionText( $rc->mAttribs
['rc_log_type'], $rc->mAttribs
['rc_log_action'],
226 $rc->getTitle(), $this->skin
, LogPage
::extractParams($rc->mAttribs
['rc_params']), true, true );
231 /** insert a formatted comment */
232 protected function insertComment(&$s, &$rc) {
234 if( $rc->mAttribs
['rc_type'] != RC_MOVE
&& $rc->mAttribs
['rc_type'] != RC_MOVE_OVER_REDIRECT
) {
236 if ( $this->isDeleted($rc,Revision
::DELETED_COMMENT
) ) {
237 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
239 $s .= $this->skin
->commentBlock( $rc->mAttribs
['rc_comment'], $rc->getTitle() );
245 * Check whether to enable recent changes patrol features
248 public static function usePatrol() {
250 return $wgUser->useRCPatrol();
254 * Returns the string which indicates the number of watching users
256 protected function numberofWatchingusers( $count ) {
258 static $cache = array();
260 if ( !isset( $cache[$count] ) ) {
261 $cache[$count] = wfMsgExt('number_of_watching_users_RCview',
262 array('parsemag', 'escape'), $wgLang->formatNum($count));
264 return $cache[$count];
271 * Determine if said field of a revision is hidden
272 * @param RCCacheEntry $rc
273 * @param int $field one of DELETED_* bitfield constants
276 public static function isDeleted( $rc, $field ) {
277 return ($rc->mAttribs
['rc_deleted'] & $field) == $field;
281 * Determine if the current user is allowed to view a particular
282 * field of this revision, if it's marked as deleted.
283 * @param RCCacheEntry $rc
287 public static function userCan( $rc, $field ) {
288 if( ( $rc->mAttribs
['rc_deleted'] & $field ) == $field ) {
290 $permission = ( $rc->mAttribs
['rc_deleted'] & Revision
::DELETED_RESTRICTED
) == Revision
::DELETED_RESTRICTED
293 wfDebug( "Checking for $permission due to $field match on $rc->mAttribs['rc_deleted']\n" );
294 return $wgUser->isAllowed( $permission );
303 * Generate a list of changes using the good old system (no javascript)
305 class OldChangesList
extends ChangesList
{
307 * Format a line using the old system (aka without any javascript).
309 public function recentChangesLine( &$rc, $watched = false ) {
310 global $wgContLang, $wgRCShowChangedSize, $wgUser;
312 $fname = 'ChangesList::recentChangesLineOld';
313 wfProfileIn( $fname );
315 # Extract DB fields into local scope
316 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
317 extract( $rc->mAttribs
);
319 # Should patrol-related stuff be shown?
320 $unpatrolled = $wgUser->useRCPatrol() && $rc_patrolled == 0;
322 $this->insertDateHeader($s,$rc_timestamp);
327 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
328 $this->insertMove( $s, $rc );
330 } elseif( $rc_log_type ) {
331 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
332 $this->insertLog( $s, $logtitle, $rc_log_type );
333 // Log entries (old format) or log targets, and special pages
334 } elseif( $rc_namespace == NS_SPECIAL
) {
335 list( $specialName, $specialSubpage ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
336 if ( $specialName == 'Log' ) {
337 $this->insertLog( $s, $rc->getTitle(), $specialSubpage );
339 wfDebug( "Unexpected special page in recentchanges\n" );
343 wfProfileIn($fname.'-page');
345 $this->insertDiffHist($s, $rc, $unpatrolled);
347 # M, N, b and ! (minor, new, bot and unpatrolled)
348 $s .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $unpatrolled, '', $rc_bot );
349 $this->insertArticleLink($s, $rc, $unpatrolled, $watched);
351 wfProfileOut($fname.'-page');
354 wfProfileIn( $fname.'-rest' );
356 $this->insertTimestamp($s,$rc);
358 if( $wgRCShowChangedSize ) {
359 $s .= ( $rc->getCharacterDifference() == '' ?
'' : $rc->getCharacterDifference() . ' . . ' );
362 $this->insertUserRelatedLinks($s,$rc);
363 # Log action text (if any)
364 $this->insertAction($s, $rc);
365 # Edit or log comment
366 $this->insertComment($s, $rc);
368 # Mark revision as deleted if so
369 if ( !$rc_log_type && $this->isDeleted($rc,Revision
::DELETED_TEXT
) )
370 $s .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
371 if($rc->numberofWatchingusers
> 0) {
372 $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers
));
377 wfProfileOut( $fname.'-rest' );
379 wfProfileOut( $fname );
386 * Generate a list of changes using an Enhanced system (use javascript).
388 class EnhancedChangesList
extends ChangesList
{
390 * Format a line for enhanced recentchange (aka with javascript and block of lines).
392 public function recentChangesLine( &$baseRC, $watched = false ) {
393 global $wgLang, $wgContLang, $wgUser;
395 # Create a specialised object
396 $rc = RCCacheEntry
::newFromParent( $baseRC );
398 # Extract fields from DB into the function scope (rc_xxxx variables)
399 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
400 extract( $rc->mAttribs
);
401 $curIdEq = 'curid=' . $rc_cur_id;
403 # If it's a new day, add the headline and flush the cache
404 $date = $wgLang->date( $rc_timestamp, true);
406 if( $date != $this->lastdate
) {
407 # Process current cache
408 $ret = $this->recentChangesBlock();
409 $this->rc_cache
= array();
410 $ret .= "<h4>{$date}</h4>\n";
411 $this->lastdate
= $date;
414 # Should patrol-related stuff be shown?
415 if( $wgUser->useRCPatrol() ) {
416 $rc->unpatrolled
= !$rc_patrolled;
418 $rc->unpatrolled
= false;
421 $showdifflinks = true;
424 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
425 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
426 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
427 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
428 // Log entries (old format) and special pages
429 } elseif( $rc_namespace == NS_SPECIAL
) {
430 list( $specialName, $logtype ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
431 if ( $specialName == 'Log' ) {
433 $logname = LogPage
::logName( $logtype );
434 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
436 wfDebug( "Unexpected special page in recentchanges\n" );
439 // New unpatrolled pages
440 } else if( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
441 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
443 } else if( $rc_type == RC_LOG
) {
444 global $wgRCTypeGroupedLogs;
445 if( $rc_log_type && in_array($rc_log_type,$wgRCTypeGroupedLogs) ) {
446 $logtitle = SpecialPage
::getTitleFor( 'Log', $rc_log_type );
447 $clink = '(' . $this->skin
->makeKnownLinkObj( $logtitle, LogPage
::logName($rc_log_type) ) . ')';
449 $clink = $this->skin
->makeLinkObj( $rc->getTitle(), '' );
454 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
457 # Don't show unusable diff links
458 if ( !ChangesList
::userCan($rc,Revision
::DELETED_TEXT
) ) {
459 $showdifflinks = false;
462 $time = $wgContLang->time( $rc_timestamp, true, true );
463 $rc->watched
= $watched;
465 $rc->timestamp
= $time;
466 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
468 # Make "cur" and "diff" links
469 if( $rc->unpatrolled
) {
470 $rcIdQuery = "&rcid={$rc_id}";
474 $querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid";
475 $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery";
476 $aprops = ' tabindex="'.$baseRC->counter
.'"';
477 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['cur'], $querycur, '' ,'', $aprops );
479 # Make "diff" an "cur" links
480 if( !$showdifflinks ) {
481 $curLink = $this->message
['cur'];
482 $diffLink = $this->message
['diff'];
483 } else if( $rc_type == RC_NEW ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
484 if( $rc_type != RC_NEW
) {
485 $curLink = $this->message
['cur'];
487 $diffLink = $this->message
['diff'];
489 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['diff'], $querydiff, '' ,'', $aprops );
493 if( !$showdifflinks ) {
494 $lastLink = $this->message
['last'];
495 } else if( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
496 $lastLink = $this->message
['last'];
498 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['last'],
499 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
503 if( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
504 $rc->userlink
= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
506 $rc->userlink
= $this->skin
->userLink( $rc_user, $rc_user_text );
507 $rc->usertalklink
= $this->skin
->userToolLinks( $rc_user, $rc_user_text );
510 $rc->lastlink
= $lastLink;
511 $rc->curlink
= $curLink;
512 $rc->difflink
= $diffLink;
514 # Put accumulated information into the cache, for later display
515 # Page moves go on their own line
516 $title = $rc->getTitle();
517 $secureName = $title->getPrefixedDBkey();
518 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
519 # Use an @ character to prevent collision with page names
520 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
522 global $wgRCTypeGroupedLogs;
523 # Some logs are best grouped by type (block,rights)
524 if( $rc_type == RC_LOG
&& in_array($rc_log_type,$wgRCTypeGroupedLogs) ){
525 $secureName = SpecialPage
::getTitleFor( 'Log', $rc_log_type )->getPrefixedDBkey();
527 if( !isset( $this->rc_cache
[$secureName] ) ) {
528 $this->rc_cache
[$secureName] = array();
530 array_push( $this->rc_cache
[$secureName], $rc );
538 protected function recentChangesBlockGroup( $block ) {
539 global $wgLang, $wgContLang, $wgRCShowChangedSize;
540 $r = '<table cellpadding="0" cellspacing="0" border="0" style="background: none"><tr>';
542 # Collate list of users
543 $userlinks = array();
545 $unpatrolled = false;
547 $curId = $currentRevision = 0;
548 # Some catalyst variables...
551 foreach( $block as $rcObj ) {
552 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
553 if( $rcObj->mAttribs
['rc_new'] ) {
556 // If all log actions to this page were hidden, then don't
557 // give the name of the affected page for this block!
558 if( !$this->isDeleted( $rcObj, LogPage
::DELETED_ACTION
) ) {
561 $u = $rcObj->userlink
;
562 if( !isset( $userlinks[$u] ) ) {
565 if( $rcObj->unpatrolled
) {
568 if( $rcObj->mAttribs
['rc_type'] != RC_LOG
) {
571 # Get the latest entry with a page_id and oldid
572 # since logs may not have these.
573 if( !$curId && $rcObj->mAttribs
['rc_cur_id'] ) {
574 $curId = $rcObj->mAttribs
['rc_cur_id'];
576 if( !$currentRevision && $rcObj->mAttribs
['rc_this_oldid'] ) {
577 $currentRevision = $rcObj->mAttribs
['rc_this_oldid'];
580 $bot = $rcObj->mAttribs
['rc_bot'];
584 # Sort the list and convert to text
585 krsort( $userlinks );
588 foreach( $userlinks as $userlink => $count) {
590 $text .= $wgContLang->getDirMark();
592 $text .= ' ('.$count.'×)';
594 array_push( $users, $text );
597 $users = ' <span class="changedby">[' . implode( $this->message
['semicolon-separator'] . ' ', $users ) . ']</span>';
600 $rci = 'RCI'.$this->rcCacheIndex
;
601 $rcl = 'RCL'.$this->rcCacheIndex
;
602 $rcm = 'RCM'.$this->rcCacheIndex
;
603 $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')";
604 $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'">' . $this->sideArrow() . '</a></span>';
605 $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'">' . $this->downArrow() . '</a></span>';
606 $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.' ';
609 $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot );
612 $r .= ' '.$block[0]->timestamp
.' </tt></td><td>';
616 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
618 $r .= $this->maybeWatchedLink( $block[0]->link
, $block[0]->watched
);
621 $r .= $wgContLang->getDirMark();
623 $curIdEq = 'curid=' . $curId;
626 static $nchanges = array();
627 if ( !isset( $nchanges[$n] ) ) {
628 $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) );
634 if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
636 } else if( $isnew ) {
639 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
640 $nchanges[$n], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
645 # Character difference (does not apply if only log items)
646 if( $wgRCShowChangedSize && !$alllogs ) {
648 $first = count($block) - 1;
649 # Some events (like logs) have an "empty" size, so we need to skip those...
650 while( $last < $first && $block[$last]->mAttribs
['rc_new_len'] === NULL ) {
653 while( $first > $last && $block[$first]->mAttribs
['rc_old_len'] === NULL ) {
657 $chardiff = $rcObj->getCharacterDifference( $block[$first]->mAttribs
['rc_old_len'],
658 $block[$last]->mAttribs
['rc_new_len'] );
660 if( $chardiff == '' ) {
663 $r .= ' ' . $chardiff. ' . . ';
668 if( $namehidden ||
!$block[0]->getTitle()->exists() ) {
669 $r .= '(' . $this->message
['history'] . ')';
671 $r .= '(' . $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
672 $this->message
['history'], $curIdEq.'&action=history' ) . ')';
676 $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers
);
678 $r .= "</td></tr></table>\n";
681 $r .= '<div id="'.$rci.'" style="display:none;"><table cellpadding="0" cellspacing="0" border="0" style="background: none">';
682 foreach( $block as $rcObj ) {
683 # Get rc_xxxx variables
684 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
685 extract( $rcObj->mAttribs
);
687 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
688 $r .= '<tr><td valign="top">';
689 $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
690 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
691 $r .= ' </tt></td><td valign="top">';
694 if( $rc_this_oldid != 0 ) {
695 $o = 'oldid='.$rc_this_oldid;
698 if( $rc_type == RC_LOG
) {
699 $link = '<tt>'.$rcObj->timestamp
.'</tt> ';
700 } else if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
701 $link = '<span class="history-deleted"><tt>'.$rcObj->timestamp
.'</tt></span> ';
703 $link = '<tt>'.$this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, $curIdEq.'&'.$o ).'</tt>';
704 if( $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) )
705 $link = '<span class="history-deleted">'.$link.'</span> ';
709 if ( !$rc_type == RC_LOG ||
$rc_type == RC_NEW
) {
711 $r .= $rcObj->curlink
;
712 $r .= $this->message
['semicolon-separator'] . ' ';
713 $r .= $rcObj->lastlink
;
719 if( $wgRCShowChangedSize ) {
720 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : $rcObj->getCharacterDifference() . ' . . ' ) ;
723 $r .= $rcObj->userlink
;
724 $r .= $rcObj->usertalklink
;
726 parent
::insertAction( $r, $rcObj );
728 parent
::insertComment( $r, $rcObj );
729 # Mark revision as deleted
730 if( !$rc_log_type && $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) ) {
731 $r .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
734 $r .= "</td></tr>\n";
736 $r .= "</table></div>\n";
738 $this->rcCacheIndex++
;
742 protected function maybeWatchedLink( $link, $watched=false ) {
744 // FIXME: css style might be more appropriate
745 return '<strong class="mw-watched">' . $link . '</strong>';
752 * Generate HTML for an arrow or placeholder graphic
753 * @param string $dir one of '', 'd', 'l', 'r'
754 * @param string $alt text
755 * @return string HTML <img> tag
757 protected function arrow( $dir, $alt='' ) {
759 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
760 $encAlt = htmlspecialchars( $alt );
761 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" />";
765 * Generate HTML for a right- or left-facing arrow,
766 * depending on language direction.
767 * @return string HTML <img> tag
769 protected function sideArrow() {
771 $dir = $wgContLang->isRTL() ?
'l' : 'r';
772 return $this->arrow( $dir, '+' );
776 * Generate HTML for a down-facing arrow
777 * depending on language direction.
778 * @return string HTML <img> tag
780 protected function downArrow() {
781 return $this->arrow( 'd', '-' );
785 * Generate HTML for a spacer image
786 * @return string HTML <img> tag
788 protected function spacerArrow() {
789 return $this->arrow( '', ' ' );
793 * Add a set of spaces
794 * @return string HTML <td> tag
796 protected function spacerIndent() {
797 return ' ';
801 * Enhanced RC ungrouped line.
802 * @return string a HTML formated line (generated using $r)
804 protected function recentChangesBlockLine( $rcObj ) {
805 global $wgContLang, $wgRCShowChangedSize;
807 # Get rc_xxxx variables
808 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
809 extract( $rcObj->mAttribs
);
810 $curIdEq = 'curid='.$rc_cur_id;
812 $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>';
814 $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . ' ';
817 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
818 $r .= ' '; // 4 flags -> 4 spaces
820 $r .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
822 $r .= ' '.$rcObj->timestamp
.' </tt></td><td>';
824 # Article or log link
826 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
827 $logname = LogPage
::logName( $rc_log_type );
828 $r .= '(' . $this->skin
->makeKnownLinkObj($logtitle, $logname ) . ')';
829 } else if( !$this->userCan($rcObj,Revision
::DELETED_TEXT
) ) {
830 $r .= '<span class="history-deleted">' . $rcObj->link
. '</span>';
832 $r .= $this->maybeWatchedLink( $rcObj->link
, $rcObj->watched
);
835 # Diff and hist links
836 if ( $rc_type != RC_LOG
) {
837 $r .= ' ('. $rcObj->difflink
. $this->message
['semicolon-separator'] . ' ';
838 $r .= $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')';
843 if( $wgRCShowChangedSize ) {
844 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : ' ' . $rcObj->getCharacterDifference() . ' . . ' ) ;
848 $r .= ' '.$rcObj->userlink
. $rcObj->usertalklink
;
850 # Log action (if any)
852 if( $this->isDeleted($rcObj,LogPage
::DELETED_ACTION
) ) {
853 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
855 $r .= ' ' . LogPage
::actionText( $rc_log_type, $rc_log_action, $rcObj->getTitle(), $this->skin
, LogPage
::extractParams($rc_params), true, true );
859 # Edit or log comment
860 if( $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
862 if ( $this->isDeleted($rcObj,LogPage
::DELETED_COMMENT
) ) {
863 $r .= ' <span class="history-deleted">' . wfMsg('rev-deleted-comment') . '</span>';
865 $r .= $this->skin
->commentBlock( $rc_comment, $rcObj->getTitle() );
869 # Show how many people are watching this if enabled
870 $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers
);
872 $r .= "</td></tr></table>\n";
877 * If enhanced RC is in use, this function takes the previously cached
878 * RC lines, arranges them, and outputs the HTML
880 protected function recentChangesBlock() {
881 if( count ( $this->rc_cache
) == 0 ) {
885 foreach( $this->rc_cache
as $block ) {
886 if( count( $block ) < 2 ) {
887 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
889 $blockOut .= $this->recentChangesBlockGroup( $block );
893 return '<div>'.$blockOut.'</div>';
897 * Returns text for the end of RC
898 * If enhanced RC is in use, returns pretty much all the text
900 public function endRecentChangesList() {
901 return $this->recentChangesBlock() . parent
::endRecentChangesList();