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( 'escapenoentities' ) );
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 );
133 if( $date != $this->lastdate
) {
134 if( '' != $this->lastdate
) {
137 $s .= '<h4>'.$date."</h4>\n<ul class=\"special\">";
138 $this->lastdate
= $date;
139 $this->rclistOpen
= true;
143 protected function insertLog(&$s, $title, $logtype) {
144 $logname = LogPage
::logName( $logtype );
145 $s .= '(' . $this->skin
->makeKnownLinkObj($title, $logname ) . ')';
148 protected function insertDiffHist(&$s, &$rc, $unpatrolled) {
150 if( !$this->userCan($rc,Revision
::DELETED_TEXT
) ) {
151 $diffLink = $this->message
['diff'];
152 } else if( $rc->mAttribs
['rc_type'] == RC_NEW ||
$rc->mAttribs
['rc_type'] == RC_LOG
) {
153 $diffLink = $this->message
['diff'];
155 $rcidparam = $unpatrolled
156 ?
array( 'rcid' => $rc->mAttribs
['rc_id'] )
158 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['diff'],
160 'curid' => $rc->mAttribs
['rc_cur_id'],
161 'diff' => $rc->mAttribs
['rc_this_oldid'],
162 'oldid' => $rc->mAttribs
['rc_last_oldid'] ),
164 '', '', ' tabindex="'.$rc->counter
.'"');
166 $s .= '('.$diffLink.') (';
169 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['hist'],
171 'curid' => $rc->mAttribs
['rc_cur_id'],
172 'action' => 'history' ) ) );
176 protected function insertArticleLink(&$s, &$rc, $unpatrolled, $watched) {
178 # If it's a new article, there is no diff link, but if it hasn't been
179 # patrolled yet, we need to give users a way to do so
180 $params = ( $unpatrolled && $rc->mAttribs
['rc_type'] == RC_NEW
)
181 ?
'rcid='.$rc->mAttribs
['rc_id']
183 if( $this->isDeleted($rc,Revision
::DELETED_TEXT
) ) {
184 $articlelink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', $params );
185 $articlelink = '<span class="history-deleted">'.$articlelink.'</span>';
187 $articlelink = ' '. $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', $params );
190 $articlelink = "<strong class=\"mw-watched\">{$articlelink}</strong>";
192 $articlelink .= $wgContLang->getDirMark();
194 wfRunHooks('ChangesListInsertArticleLink',
195 array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched));
197 $s .= ' '.$articlelink;
200 protected function insertTimestamp(&$s, $rc) {
203 $s .= $this->message
['semicolon-separator'] . $wgLang->time( $rc->mAttribs
['rc_timestamp'], true, true ) . ' . . ';
206 /** Insert links to user page, user talk page and eventually a blocking link */
207 public function insertUserRelatedLinks(&$s, &$rc) {
208 if ( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
209 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
211 $s .= $this->skin
->userLink( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
212 $s .= $this->skin
->userToolLinks( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
216 /** insert a formatted action */
217 protected function insertAction(&$s, &$rc) {
219 if( $rc->mAttribs
['rc_type'] == RC_LOG
) {
221 if ( $this->isDeleted($rc,LogPage
::DELETED_ACTION
) ) {
222 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
224 $s .= ' ' . LogPage
::actionText( $rc->mAttribs
['rc_log_type'], $rc->mAttribs
['rc_log_action'],
225 $rc->getTitle(), $this->skin
, LogPage
::extractParams($rc->mAttribs
['rc_params']), true, true );
230 /** insert a formatted comment */
231 protected function insertComment(&$s, &$rc) {
233 if( $rc->mAttribs
['rc_type'] != RC_MOVE
&& $rc->mAttribs
['rc_type'] != RC_MOVE_OVER_REDIRECT
) {
235 if ( $this->isDeleted($rc,Revision
::DELETED_COMMENT
) ) {
236 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
238 $s .= $this->skin
->commentBlock( $rc->mAttribs
['rc_comment'], $rc->getTitle() );
244 * Check whether to enable recent changes patrol features
247 public static function usePatrol() {
249 return $wgUser->useRCPatrol();
253 * Returns the string which indicates the number of watching users
255 protected function numberofWatchingusers( $count ) {
257 static $cache = array();
259 if ( !isset( $cache[$count] ) ) {
260 $cache[$count] = wfMsgExt('number_of_watching_users_RCview',
261 array('parsemag', 'escape'), $wgLang->formatNum($count));
263 return $cache[$count];
270 * Determine if said field of a revision is hidden
271 * @param RCCacheEntry $rc
272 * @param int $field one of DELETED_* bitfield constants
275 public static function isDeleted( $rc, $field ) {
276 return ($rc->mAttribs
['rc_deleted'] & $field) == $field;
280 * Determine if the current user is allowed to view a particular
281 * field of this revision, if it's marked as deleted.
282 * @param RCCacheEntry $rc
286 public static function userCan( $rc, $field ) {
287 if( ( $rc->mAttribs
['rc_deleted'] & $field ) == $field ) {
289 $permission = ( $rc->mAttribs
['rc_deleted'] & Revision
::DELETED_RESTRICTED
) == Revision
::DELETED_RESTRICTED
292 wfDebug( "Checking for $permission due to $field match on $rc->mAttribs['rc_deleted']\n" );
293 return $wgUser->isAllowed( $permission );
302 * Generate a list of changes using the good old system (no javascript)
304 class OldChangesList
extends ChangesList
{
306 * Format a line using the old system (aka without any javascript).
308 public function recentChangesLine( &$rc, $watched = false ) {
309 global $wgContLang, $wgRCShowChangedSize, $wgUser;
311 $fname = 'ChangesList::recentChangesLineOld';
312 wfProfileIn( $fname );
314 # Extract DB fields into local scope
315 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
316 extract( $rc->mAttribs
);
318 # Should patrol-related stuff be shown?
319 $unpatrolled = $wgUser->useRCPatrol() && $rc_patrolled == 0;
321 $dateheader = ""; // $s now contains only <li>...</li>, for hooks' convenience.
322 $this->insertDateHeader($dateheader,$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
));
375 wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) );
377 $s = "<li>$s</li>\n";
379 wfProfileOut( $fname.'-rest' );
381 wfProfileOut( $fname );
382 return $dateheader . $s;
388 * Generate a list of changes using an Enhanced system (use javascript).
390 class EnhancedChangesList
extends ChangesList
{
392 * Format a line for enhanced recentchange (aka with javascript and block of lines).
394 public function recentChangesLine( &$baseRC, $watched = false ) {
395 global $wgLang, $wgContLang, $wgUser;
397 # Create a specialised object
398 $rc = RCCacheEntry
::newFromParent( $baseRC );
400 # Extract fields from DB into the function scope (rc_xxxx variables)
401 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
402 extract( $rc->mAttribs
);
403 $curIdEq = 'curid=' . $rc_cur_id;
405 # If it's a new day, add the headline and flush the cache
406 $date = $wgLang->date( $rc_timestamp, true);
408 if( $date != $this->lastdate
) {
409 # Process current cache
410 $ret = $this->recentChangesBlock();
411 $this->rc_cache
= array();
412 $ret .= "<h4>{$date}</h4>\n";
413 $this->lastdate
= $date;
416 # Should patrol-related stuff be shown?
417 if( $wgUser->useRCPatrol() ) {
418 $rc->unpatrolled
= !$rc_patrolled;
420 $rc->unpatrolled
= false;
423 $showdifflinks = true;
426 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
427 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
428 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
429 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
430 // Log entries (old format) and special pages
431 } elseif( $rc_namespace == NS_SPECIAL
) {
432 list( $specialName, $logtype ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
433 if ( $specialName == 'Log' ) {
435 $logname = LogPage
::logName( $logtype );
436 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
438 wfDebug( "Unexpected special page in recentchanges\n" );
441 // New unpatrolled pages
442 } else if( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
443 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
445 } else if( $rc_type == RC_LOG
) {
447 $logtitle = SpecialPage
::getTitleFor( 'Log', $rc_log_type );
448 $clink = '(' . $this->skin
->makeKnownLinkObj( $logtitle, LogPage
::logName($rc_log_type) ) . ')';
450 $clink = $this->skin
->makeLinkObj( $rc->getTitle(), '' );
455 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
458 # Don't show unusable diff links
459 if ( !ChangesList
::userCan($rc,Revision
::DELETED_TEXT
) ) {
460 $showdifflinks = false;
463 $time = $wgContLang->time( $rc_timestamp, true, true );
464 $rc->watched
= $watched;
466 $rc->timestamp
= $time;
467 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
469 # Make "cur" and "diff" links
470 if( $rc->unpatrolled
) {
471 $rcIdQuery = "&rcid={$rc_id}";
475 $querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid";
476 $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery";
477 $aprops = ' tabindex="'.$baseRC->counter
.'"';
478 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['cur'], $querycur, '' ,'', $aprops );
480 # Make "diff" an "cur" links
481 if( !$showdifflinks ) {
482 $curLink = $this->message
['cur'];
483 $diffLink = $this->message
['diff'];
484 } else if( $rc_type == RC_NEW ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
485 if( $rc_type != RC_NEW
) {
486 $curLink = $this->message
['cur'];
488 $diffLink = $this->message
['diff'];
490 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['diff'], $querydiff, '' ,'', $aprops );
494 if( !$showdifflinks ) {
495 $lastLink = $this->message
['last'];
496 } else if( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
497 $lastLink = $this->message
['last'];
499 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['last'],
500 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
504 if( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
505 $rc->userlink
= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
507 $rc->userlink
= $this->skin
->userLink( $rc_user, $rc_user_text );
508 $rc->usertalklink
= $this->skin
->userToolLinks( $rc_user, $rc_user_text );
511 $rc->lastlink
= $lastLink;
512 $rc->curlink
= $curLink;
513 $rc->difflink
= $diffLink;
515 # Put accumulated information into the cache, for later display
516 # Page moves go on their own line
517 $title = $rc->getTitle();
518 $secureName = $title->getPrefixedDBkey();
519 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
520 # Use an @ character to prevent collision with page names
521 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
523 # Logs are grouped by type
524 if( $rc_type == RC_LOG
){
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 .= ' (' . $wgLang->formatNum( $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. ' . . ';
669 // don't show history link for logs
670 } else if( $namehidden ||
!$block[0]->getTitle()->exists() ) {
671 $r .= '(' . $this->message
['history'] . ')';
673 $r .= '(' . $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
674 $this->message
['history'], $curIdEq.'&action=history' ) . ')';
678 $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers
);
680 $r .= "</td></tr></table>\n";
683 $r .= '<div id="'.$rci.'" style="display:none;"><table cellpadding="0" cellspacing="0" border="0" style="background: none">';
684 foreach( $block as $rcObj ) {
685 # Get rc_xxxx variables
686 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
687 extract( $rcObj->mAttribs
);
689 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
690 $r .= '<tr><td valign="top">';
691 $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
692 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
693 $r .= ' </tt></td><td valign="top">';
696 if( $rc_this_oldid != 0 ) {
697 $o = 'oldid='.$rc_this_oldid;
700 if( $rc_type == RC_LOG
) {
701 $link = '<tt>'.$rcObj->timestamp
.'</tt> ';
703 } else if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
704 $link = '<span class="history-deleted"><tt>'.$rcObj->timestamp
.'</tt></span> ';
706 $rcIdEq = ($rcObj->unpatrolled
&& $rc_type == RC_NEW
) ?
'&rcid='.$rcObj->mAttribs
['rc_id'] : '';
708 $link = '<tt>'.$this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, $curIdEq.'&'.$o.$rcIdEq ).'</tt>';
709 if( $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) )
710 $link = '<span class="history-deleted">'.$link.'</span> ';
714 if ( !$rc_type == RC_LOG ||
$rc_type == RC_NEW
) {
716 $r .= $rcObj->curlink
;
717 $r .= $this->message
['semicolon-separator'];
718 $r .= $rcObj->lastlink
;
724 if( $wgRCShowChangedSize ) {
725 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : $rcObj->getCharacterDifference() . ' . . ' ) ;
728 $r .= $rcObj->userlink
;
729 $r .= $rcObj->usertalklink
;
731 parent
::insertAction( $r, $rcObj );
733 parent
::insertComment( $r, $rcObj );
734 # Mark revision as deleted
735 if( !$rc_log_type && $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) ) {
736 $r .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
739 $r .= "</td></tr>\n";
741 $r .= "</table></div>\n";
743 $this->rcCacheIndex++
;
747 protected function maybeWatchedLink( $link, $watched=false ) {
749 // FIXME: css style might be more appropriate
750 return '<strong class="mw-watched">' . $link . '</strong>';
757 * Generate HTML for an arrow or placeholder graphic
758 * @param string $dir one of '', 'd', 'l', 'r'
759 * @param string $alt text
760 * @return string HTML <img> tag
762 protected function arrow( $dir, $alt='' ) {
764 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
765 $encAlt = htmlspecialchars( $alt );
766 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" />";
770 * Generate HTML for a right- or left-facing arrow,
771 * depending on language direction.
772 * @return string HTML <img> tag
774 protected function sideArrow() {
776 $dir = $wgContLang->isRTL() ?
'l' : 'r';
777 return $this->arrow( $dir, '+' );
781 * Generate HTML for a down-facing arrow
782 * depending on language direction.
783 * @return string HTML <img> tag
785 protected function downArrow() {
786 return $this->arrow( 'd', '-' );
790 * Generate HTML for a spacer image
791 * @return string HTML <img> tag
793 protected function spacerArrow() {
794 return $this->arrow( '', ' ' );
798 * Add a set of spaces
799 * @return string HTML <td> tag
801 protected function spacerIndent() {
802 return ' ';
806 * Enhanced RC ungrouped line.
807 * @return string a HTML formated line (generated using $r)
809 protected function recentChangesBlockLine( $rcObj ) {
810 global $wgContLang, $wgRCShowChangedSize;
812 # Get rc_xxxx variables
813 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
814 extract( $rcObj->mAttribs
);
815 $curIdEq = 'curid='.$rc_cur_id;
817 $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>';
819 $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . ' ';
822 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
823 $r .= ' '; // 4 flags -> 4 spaces
825 $r .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
827 $r .= ' '.$rcObj->timestamp
.' </tt></td><td>';
829 # Article or log link
831 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
832 $logname = LogPage
::logName( $rc_log_type );
833 $r .= '(' . $this->skin
->makeKnownLinkObj($logtitle, $logname ) . ')';
834 } else if( !$this->userCan($rcObj,Revision
::DELETED_TEXT
) ) {
835 $r .= '<span class="history-deleted">' . $rcObj->link
. '</span>';
837 $r .= $this->maybeWatchedLink( $rcObj->link
, $rcObj->watched
);
840 # Diff and hist links
841 if ( $rc_type != RC_LOG
) {
842 $r .= ' ('. $rcObj->difflink
. $this->message
['semicolon-separator'];
843 $r .= $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')';
848 if( $wgRCShowChangedSize ) {
849 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : ' ' . $rcObj->getCharacterDifference() . ' . . ' ) ;
853 $r .= ' '.$rcObj->userlink
. $rcObj->usertalklink
;
855 # Log action (if any)
857 if( $this->isDeleted($rcObj,LogPage
::DELETED_ACTION
) ) {
858 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
860 $r .= ' ' . LogPage
::actionText( $rc_log_type, $rc_log_action, $rcObj->getTitle(),
861 $this->skin
, LogPage
::extractParams($rc_params), true, true );
865 # Edit or log comment
866 if( $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
868 if ( $this->isDeleted($rcObj,LogPage
::DELETED_COMMENT
) ) {
869 $r .= ' <span class="history-deleted">' . wfMsg('rev-deleted-comment') . '</span>';
871 $r .= $this->skin
->commentBlock( $rc_comment, $rcObj->getTitle() );
875 # Show how many people are watching this if enabled
876 $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers
);
878 $r .= "</td></tr></table>\n";
883 * If enhanced RC is in use, this function takes the previously cached
884 * RC lines, arranges them, and outputs the HTML
886 protected function recentChangesBlock() {
887 if( count ( $this->rc_cache
) == 0 ) {
891 foreach( $this->rc_cache
as $block ) {
892 if( count( $block ) < 2 ) {
893 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
895 $blockOut .= $this->recentChangesBlockGroup( $block );
899 return '<div>'.$blockOut.'</div>';
903 * Returns text for the end of RC
904 * If enhanced RC is in use, returns pretty much all the text
906 public function endRecentChangesList() {
907 return $this->recentChangesBlock() . parent
::endRecentChangesList();