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 * Show formatted char difference
105 * @param int $old bytes
106 * @param int $new bytes
109 public static function showCharacterDifference( $old, $new ) {
110 global $wgRCChangedSizeThreshold, $wgLang;
111 $szdiff = $new - $old;
112 $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape'), $wgLang->formatNum($szdiff) );
113 if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
118 if( $szdiff === 0 ) {
119 return "<$tag class='mw-plusminus-null'>($formatedSize)</$tag>";
120 } elseif( $szdiff > 0 ) {
121 return "<$tag class='mw-plusminus-pos'>(+$formatedSize)</$tag>";
123 return "<$tag class='mw-plusminus-neg'>($formatedSize)</$tag>";
128 * Returns text for the end of RC
131 public function endRecentChangesList() {
132 if( $this->rclistOpen
) {
139 protected function insertMove( &$s, $rc ) {
141 $s .= '(' . $this->message
['diff'] . ') (';
143 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $this->message
['hist'], 'action=history' ) .
146 # "[[x]] moved to [[y]]"
147 $msg = ( $rc->mAttribs
['rc_type'] == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
148 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
149 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
152 protected function insertDateHeader(&$s, $rc_timestamp) {
155 # Make date header if necessary
156 $date = $wgLang->date( $rc_timestamp, true, true );
157 if( $date != $this->lastdate
) {
158 if( '' != $this->lastdate
) {
161 $s .= '<h4>'.$date."</h4>\n<ul class=\"special\">";
162 $this->lastdate
= $date;
163 $this->rclistOpen
= true;
167 protected function insertLog(&$s, $title, $logtype) {
168 $logname = LogPage
::logName( $logtype );
169 $s .= '(' . $this->skin
->makeKnownLinkObj($title, $logname ) . ')';
172 protected function insertDiffHist(&$s, &$rc, $unpatrolled) {
174 if( !$this->userCan($rc,Revision
::DELETED_TEXT
) ) {
175 $diffLink = $this->message
['diff'];
176 } else if( $rc->mAttribs
['rc_type'] == RC_NEW ||
$rc->mAttribs
['rc_type'] == RC_LOG
) {
177 $diffLink = $this->message
['diff'];
179 $rcidparam = $unpatrolled
180 ?
array( 'rcid' => $rc->mAttribs
['rc_id'] )
182 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['diff'],
184 'curid' => $rc->mAttribs
['rc_cur_id'],
185 'diff' => $rc->mAttribs
['rc_this_oldid'],
186 'oldid' => $rc->mAttribs
['rc_last_oldid'] ),
188 '', '', ' tabindex="'.$rc->counter
.'"');
190 $s .= '('.$diffLink.') (';
193 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['hist'],
195 'curid' => $rc->mAttribs
['rc_cur_id'],
196 'action' => 'history' ) ) );
200 protected function insertArticleLink(&$s, &$rc, $unpatrolled, $watched) {
202 # If it's a new article, there is no diff link, but if it hasn't been
203 # patrolled yet, we need to give users a way to do so
204 $params = ( $unpatrolled && $rc->mAttribs
['rc_type'] == RC_NEW
)
205 ?
'rcid='.$rc->mAttribs
['rc_id']
207 if( $this->isDeleted($rc,Revision
::DELETED_TEXT
) ) {
208 $articlelink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', $params );
209 $articlelink = '<span class="history-deleted">'.$articlelink.'</span>';
211 $articlelink = ' '. $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', $params );
214 $articlelink = "<strong class=\"mw-watched\">{$articlelink}</strong>";
216 $articlelink .= $wgContLang->getDirMark();
218 wfRunHooks('ChangesListInsertArticleLink',
219 array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched));
221 $s .= ' '.$articlelink;
224 protected function insertTimestamp(&$s, $rc) {
227 $s .= $this->message
['semicolon-separator'] . $wgLang->time( $rc->mAttribs
['rc_timestamp'], true, true ) . ' . . ';
230 /** Insert links to user page, user talk page and eventually a blocking link */
231 public function insertUserRelatedLinks(&$s, &$rc) {
232 if ( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
233 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
235 $s .= $this->skin
->userLink( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
236 $s .= $this->skin
->userToolLinks( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
240 /** insert a formatted action */
241 protected function insertAction(&$s, &$rc) {
243 if( $rc->mAttribs
['rc_type'] == RC_LOG
) {
245 if ( $this->isDeleted($rc,LogPage
::DELETED_ACTION
) ) {
246 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
248 $s .= ' ' . LogPage
::actionText( $rc->mAttribs
['rc_log_type'], $rc->mAttribs
['rc_log_action'],
249 $rc->getTitle(), $this->skin
, LogPage
::extractParams($rc->mAttribs
['rc_params']), true, true );
254 /** insert a formatted comment */
255 protected function insertComment(&$s, &$rc) {
257 if( $rc->mAttribs
['rc_type'] != RC_MOVE
&& $rc->mAttribs
['rc_type'] != RC_MOVE_OVER_REDIRECT
) {
259 if ( $this->isDeleted($rc,Revision
::DELETED_COMMENT
) ) {
260 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
262 $s .= $this->skin
->commentBlock( $rc->mAttribs
['rc_comment'], $rc->getTitle() );
268 * Check whether to enable recent changes patrol features
271 public static function usePatrol() {
273 return $wgUser->useRCPatrol();
277 * Returns the string which indicates the number of watching users
279 protected function numberofWatchingusers( $count ) {
281 static $cache = array();
283 if ( !isset( $cache[$count] ) ) {
284 $cache[$count] = wfMsgExt('number_of_watching_users_RCview',
285 array('parsemag', 'escape'), $wgLang->formatNum($count));
287 return $cache[$count];
294 * Determine if said field of a revision is hidden
295 * @param RCCacheEntry $rc
296 * @param int $field one of DELETED_* bitfield constants
299 public static function isDeleted( $rc, $field ) {
300 return ($rc->mAttribs
['rc_deleted'] & $field) == $field;
304 * Determine if the current user is allowed to view a particular
305 * field of this revision, if it's marked as deleted.
306 * @param RCCacheEntry $rc
310 public static function userCan( $rc, $field ) {
311 if( ( $rc->mAttribs
['rc_deleted'] & $field ) == $field ) {
313 $permission = ( $rc->mAttribs
['rc_deleted'] & Revision
::DELETED_RESTRICTED
) == Revision
::DELETED_RESTRICTED
316 wfDebug( "Checking for $permission due to $field match on $rc->mAttribs['rc_deleted']\n" );
317 return $wgUser->isAllowed( $permission );
323 protected function maybeWatchedLink( $link, $watched=false ) {
325 // FIXME: css style might be more appropriate
326 return '<strong class="mw-watched">' . $link . '</strong>';
328 return '<span class="mw-rc-unwatched">' . $link . '</span>';
335 * Generate a list of changes using the good old system (no javascript)
337 class OldChangesList
extends ChangesList
{
339 * Format a line using the old system (aka without any javascript).
341 public function recentChangesLine( &$rc, $watched = false ) {
342 global $wgContLang, $wgRCShowChangedSize, $wgUser;
344 $fname = 'ChangesList::recentChangesLineOld';
345 wfProfileIn( $fname );
347 # Extract DB fields into local scope
348 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
349 extract( $rc->mAttribs
);
351 # Should patrol-related stuff be shown?
352 $unpatrolled = $wgUser->useRCPatrol() && $rc_patrolled == 0;
354 $dateheader = ""; // $s now contains only <li>...</li>, for hooks' convenience.
355 $this->insertDateHeader($dateheader,$rc_timestamp);
360 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
361 $this->insertMove( $s, $rc );
363 } elseif( $rc_log_type ) {
364 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
365 $this->insertLog( $s, $logtitle, $rc_log_type );
366 // Log entries (old format) or log targets, and special pages
367 } elseif( $rc_namespace == NS_SPECIAL
) {
368 list( $specialName, $specialSubpage ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
369 if ( $specialName == 'Log' ) {
370 $this->insertLog( $s, $rc->getTitle(), $specialSubpage );
372 wfDebug( "Unexpected special page in recentchanges\n" );
376 wfProfileIn($fname.'-page');
378 $this->insertDiffHist($s, $rc, $unpatrolled);
380 # M, N, b and ! (minor, new, bot and unpatrolled)
381 $s .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $unpatrolled, '', $rc_bot );
382 $this->insertArticleLink($s, $rc, $unpatrolled, $watched);
384 wfProfileOut($fname.'-page');
387 wfProfileIn( $fname.'-rest' );
389 $this->insertTimestamp($s,$rc);
391 if( $wgRCShowChangedSize ) {
392 $s .= ( $rc->getCharacterDifference() == '' ?
'' : $rc->getCharacterDifference() . ' . . ' );
395 $this->insertUserRelatedLinks($s,$rc);
396 # Log action text (if any)
397 $this->insertAction($s, $rc);
398 # Edit or log comment
399 $this->insertComment($s, $rc);
401 # Mark revision as deleted if so
402 if ( !$rc_log_type && $this->isDeleted($rc,Revision
::DELETED_TEXT
) )
403 $s .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
404 if($rc->numberofWatchingusers
> 0) {
405 $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers
));
408 wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) );
410 $s = "<li>$s</li>\n";
412 wfProfileOut( $fname.'-rest' );
414 wfProfileOut( $fname );
415 return $dateheader . $s;
421 * Generate a list of changes using an Enhanced system (use javascript).
423 class EnhancedChangesList
extends ChangesList
{
426 * Add the JavaScript file for enhanced changeslist
429 public function beginRecentChangesList() {
430 global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
431 $this->rc_cache
= array();
432 $this->rcMoveIndex
= 0;
433 $this->rcCacheIndex
= 0;
434 $this->lastdate
= '';
435 $this->rclistOpen
= false;
436 $script = Xml
::tags( 'script', array(
437 'type' => $wgJsMimeType,
438 'src' => $wgStylePath . "/common/enhancedchanges.js?$wgStyleVersion" ), '' );
442 * Format a line for enhanced recentchange (aka with javascript and block of lines).
444 public function recentChangesLine( &$baseRC, $watched = false ) {
445 global $wgLang, $wgContLang, $wgUser;
447 # Create a specialised object
448 $rc = RCCacheEntry
::newFromParent( $baseRC );
450 # Extract fields from DB into the function scope (rc_xxxx variables)
451 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
452 extract( $rc->mAttribs
);
453 $curIdEq = 'curid=' . $rc_cur_id;
455 # If it's a new day, add the headline and flush the cache
456 $date = $wgLang->date( $rc_timestamp, true);
458 if( $date != $this->lastdate
) {
459 # Process current cache
460 $ret = $this->recentChangesBlock();
461 $this->rc_cache
= array();
462 $ret .= "<h4>{$date}</h4>\n";
463 $this->lastdate
= $date;
466 # Should patrol-related stuff be shown?
467 if( $wgUser->useRCPatrol() ) {
468 $rc->unpatrolled
= !$rc_patrolled;
470 $rc->unpatrolled
= false;
473 $showdifflinks = true;
476 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
477 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
478 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
479 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
480 // Log entries (old format) and special pages
481 } elseif( $rc_namespace == NS_SPECIAL
) {
482 list( $specialName, $logtype ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
483 if ( $specialName == 'Log' ) {
485 $logname = LogPage
::logName( $logtype );
486 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
488 wfDebug( "Unexpected special page in recentchanges\n" );
491 // New unpatrolled pages
492 } else if( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
493 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
495 } else if( $rc_type == RC_LOG
) {
497 $logtitle = SpecialPage
::getTitleFor( 'Log', $rc_log_type );
498 $clink = '(' . $this->skin
->makeKnownLinkObj( $logtitle, LogPage
::logName($rc_log_type) ) . ')';
500 $clink = $this->skin
->makeLinkObj( $rc->getTitle(), '' );
505 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
508 # Don't show unusable diff links
509 if ( !ChangesList
::userCan($rc,Revision
::DELETED_TEXT
) ) {
510 $showdifflinks = false;
513 $time = $wgContLang->time( $rc_timestamp, true, true );
514 $rc->watched
= $watched;
516 $rc->timestamp
= $time;
517 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
519 # Make "cur" and "diff" links
520 if( $rc->unpatrolled
) {
521 $rcIdQuery = "&rcid={$rc_id}";
525 $querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid";
526 $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery";
527 $aprops = ' tabindex="'.$baseRC->counter
.'"';
528 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['cur'], $querycur, '' ,'', $aprops );
530 # Make "diff" an "cur" links
531 if( !$showdifflinks ) {
532 $curLink = $this->message
['cur'];
533 $diffLink = $this->message
['diff'];
534 } else if( $rc_type == RC_NEW ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
535 if( $rc_type != RC_NEW
) {
536 $curLink = $this->message
['cur'];
538 $diffLink = $this->message
['diff'];
540 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['diff'], $querydiff, '' ,'', $aprops );
544 if( !$showdifflinks ) {
545 $lastLink = $this->message
['last'];
546 } else if( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
547 $lastLink = $this->message
['last'];
549 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['last'],
550 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
554 if( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
555 $rc->userlink
= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
557 $rc->userlink
= $this->skin
->userLink( $rc_user, $rc_user_text );
558 $rc->usertalklink
= $this->skin
->userToolLinks( $rc_user, $rc_user_text );
561 $rc->lastlink
= $lastLink;
562 $rc->curlink
= $curLink;
563 $rc->difflink
= $diffLink;
565 # Put accumulated information into the cache, for later display
566 # Page moves go on their own line
567 $title = $rc->getTitle();
568 $secureName = $title->getPrefixedDBkey();
569 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
570 # Use an @ character to prevent collision with page names
571 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
573 # Logs are grouped by type
574 if( $rc_type == RC_LOG
){
575 $secureName = SpecialPage
::getTitleFor( 'Log', $rc_log_type )->getPrefixedDBkey();
577 if( !isset( $this->rc_cache
[$secureName] ) ) {
578 $this->rc_cache
[$secureName] = array();
580 array_push( $this->rc_cache
[$secureName], $rc );
588 protected function recentChangesBlockGroup( $block ) {
589 global $wgLang, $wgContLang, $wgRCShowChangedSize;
590 $r = '<table cellpadding="0" cellspacing="0" border="0" style="background: none"><tr>';
592 # Collate list of users
593 $userlinks = array();
595 $unpatrolled = false;
597 $curId = $currentRevision = 0;
598 # Some catalyst variables...
601 foreach( $block as $rcObj ) {
602 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
603 if( $rcObj->mAttribs
['rc_new'] ) {
606 // If all log actions to this page were hidden, then don't
607 // give the name of the affected page for this block!
608 if( !$this->isDeleted( $rcObj, LogPage
::DELETED_ACTION
) ) {
611 $u = $rcObj->userlink
;
612 if( !isset( $userlinks[$u] ) ) {
615 if( $rcObj->unpatrolled
) {
618 if( $rcObj->mAttribs
['rc_type'] != RC_LOG
) {
621 # Get the latest entry with a page_id and oldid
622 # since logs may not have these.
623 if( !$curId && $rcObj->mAttribs
['rc_cur_id'] ) {
624 $curId = $rcObj->mAttribs
['rc_cur_id'];
626 if( !$currentRevision && $rcObj->mAttribs
['rc_this_oldid'] ) {
627 $currentRevision = $rcObj->mAttribs
['rc_this_oldid'];
630 $bot = $rcObj->mAttribs
['rc_bot'];
634 # Sort the list and convert to text
635 krsort( $userlinks );
638 foreach( $userlinks as $userlink => $count) {
640 $text .= $wgContLang->getDirMark();
642 $text .= ' (' . $wgLang->formatNum( $count ) . '×)';
644 array_push( $users, $text );
647 $users = ' <span class="changedby">[' . implode( $this->message
['semicolon-separator'], $users ) . ']</span>';
649 # ID for JS visibility toggle
650 $jsid = $this->rcCacheIndex
;
651 # onclick handler to toggle hidden/expanded
652 $toggleLink = "onclick='toggleVisibility($jsid); return false'";
654 $expandTitle = htmlspecialchars( wfMsg('rc-enhanced-expand') );
655 $closeTitle = htmlspecialchars( wfMsg('rc-enhanced-hide') );
657 $tl = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
658 $tl .= "<span id='mw-rc-closearrow-$jsid' class='mw-changeslist-hidden' style='display:none'><a href='#' $toggleLink title='$closeTitle'>" . $this->downArrow() . "</a></span>";
659 $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.' ';
662 $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot );
665 $r .= ' '.$block[0]->timestamp
.' </tt></td><td>';
669 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
671 $r .= $this->maybeWatchedLink( $block[0]->link
, $block[0]->watched
);
674 $r .= $wgContLang->getDirMark();
676 $curIdEq = 'curid=' . $curId;
679 static $nchanges = array();
680 if ( !isset( $nchanges[$n] ) ) {
681 $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) );
687 if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
689 } else if( $isnew ) {
692 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
693 $nchanges[$n], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
699 // don't show history link for logs
700 } else if( $namehidden ||
!$block[0]->getTitle()->exists() ) {
701 $r .= $this->message
['semicolon-separator'] . $this->message
['hist'] . ')';
703 $r .= $this->message
['semicolon-separator'] . $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
704 $this->message
['hist'], $curIdEq . '&action=history' ) . ')';
708 # Character difference (does not apply if only log items)
709 if( $wgRCShowChangedSize && !$alllogs ) {
711 $first = count($block) - 1;
712 # Some events (like logs) have an "empty" size, so we need to skip those...
713 while( $last < $first && $block[$last]->mAttribs
['rc_new_len'] === NULL ) {
716 while( $first > $last && $block[$first]->mAttribs
['rc_old_len'] === NULL ) {
720 $chardiff = $rcObj->getCharacterDifference( $block[$first]->mAttribs
['rc_old_len'],
721 $block[$last]->mAttribs
['rc_new_len'] );
723 if( $chardiff == '' ) {
726 $r .= ' ' . $chardiff. ' . . ';
731 $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers
);
733 $r .= "</td></tr></table>\n";
736 $r .= '<div id="mw-rc-subentries-'.$jsid.'" class="mw-changeslist-hidden"><table cellpadding="0" cellspacing="0" border="0" style="background: none">';
737 foreach( $block as $rcObj ) {
738 # Get rc_xxxx variables
739 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
740 extract( $rcObj->mAttribs
);
742 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
743 $r .= '<tr><td valign="top">';
744 $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
745 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
746 $r .= ' </tt></td><td valign="top">';
749 if( $rc_this_oldid != 0 ) {
750 $o = 'oldid='.$rc_this_oldid;
753 if( $rc_type == RC_LOG
) {
754 $link = '<tt>'.$rcObj->timestamp
.'</tt> ';
756 } else if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
757 $link = '<span class="history-deleted"><tt>'.$rcObj->timestamp
.'</tt></span> ';
759 $rcIdEq = ($rcObj->unpatrolled
&& $rc_type == RC_NEW
) ?
'&rcid='.$rcObj->mAttribs
['rc_id'] : '';
761 $link = '<tt>'.$this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, $curIdEq.'&'.$o.$rcIdEq ).'</tt>';
762 if( $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) )
763 $link = '<span class="history-deleted">'.$link.'</span> ';
767 if ( !$rc_type == RC_LOG ||
$rc_type == RC_NEW
) {
769 $r .= $rcObj->curlink
;
770 $r .= $this->message
['semicolon-separator'];
771 $r .= $rcObj->lastlink
;
777 if( $wgRCShowChangedSize ) {
778 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : $rcObj->getCharacterDifference() . ' . . ' ) ;
781 $r .= $rcObj->userlink
;
782 $r .= $rcObj->usertalklink
;
784 parent
::insertAction( $r, $rcObj );
786 parent
::insertComment( $r, $rcObj );
787 # Mark revision as deleted
788 if( !$rc_log_type && $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) ) {
789 $r .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
792 $r .= "</td></tr>\n";
794 $r .= "</table></div>\n";
796 $this->rcCacheIndex++
;
801 * Generate HTML for an arrow or placeholder graphic
802 * @param string $dir one of '', 'd', 'l', 'r'
803 * @param string $alt text
804 * @param string $title text
805 * @return string HTML <img> tag
807 protected function arrow( $dir, $alt='', $title='' ) {
809 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
810 $encAlt = htmlspecialchars( $alt );
811 $encTitle = htmlspecialchars( $title );
812 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
816 * Generate HTML for a right- or left-facing arrow,
817 * depending on language direction.
818 * @return string HTML <img> tag
820 protected function sideArrow() {
822 $dir = $wgContLang->isRTL() ?
'l' : 'r';
823 return $this->arrow( $dir, '+', wfMsg('rc-enhanced-expand') );
827 * Generate HTML for a down-facing arrow
828 * depending on language direction.
829 * @return string HTML <img> tag
831 protected function downArrow() {
832 return $this->arrow( 'd', '-', wfMsg('rc-enhanced-hide') );
836 * Generate HTML for a spacer image
837 * @return string HTML <img> tag
839 protected function spacerArrow() {
840 return $this->arrow( '', codepointToUtf8( 0xa0 ) ); // non-breaking space
844 * Add a set of spaces
845 * @return string HTML <td> tag
847 protected function spacerIndent() {
848 return ' ';
852 * Enhanced RC ungrouped line.
853 * @return string a HTML formated line (generated using $r)
855 protected function recentChangesBlockLine( $rcObj ) {
856 global $wgContLang, $wgRCShowChangedSize;
858 # Get rc_xxxx variables
859 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
860 extract( $rcObj->mAttribs
);
861 $curIdEq = 'curid='.$rc_cur_id;
863 $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>';
865 $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . ' ';
868 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
869 $r .= ' '; // 4 flags -> 4 spaces
871 $r .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
873 $r .= ' '.$rcObj->timestamp
.' </tt></td><td>';
875 # Article or log link
877 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
878 $logname = LogPage
::logName( $rc_log_type );
879 $r .= '(' . $this->skin
->makeKnownLinkObj($logtitle, $logname ) . ')';
880 } else if( !$this->userCan($rcObj,Revision
::DELETED_TEXT
) ) {
881 $r .= '<span class="history-deleted">' . $rcObj->link
. '</span>';
883 $r .= $this->maybeWatchedLink( $rcObj->link
, $rcObj->watched
);
886 # Diff and hist links
887 if ( $rc_type != RC_LOG
) {
888 $r .= ' ('. $rcObj->difflink
. $this->message
['semicolon-separator'];
889 $r .= $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')';
894 if( $wgRCShowChangedSize ) {
895 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : $rcObj->getCharacterDifference() . ' . . ' ) ;
899 $r .= ' '.$rcObj->userlink
. $rcObj->usertalklink
;
901 # Log action (if any)
903 if( $this->isDeleted($rcObj,LogPage
::DELETED_ACTION
) ) {
904 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
906 $r .= ' ' . LogPage
::actionText( $rc_log_type, $rc_log_action, $rcObj->getTitle(),
907 $this->skin
, LogPage
::extractParams($rc_params), true, true );
911 # Edit or log comment
912 if( $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
914 if ( $this->isDeleted($rcObj,LogPage
::DELETED_COMMENT
) ) {
915 $r .= ' <span class="history-deleted">' . wfMsg('rev-deleted-comment') . '</span>';
917 $r .= $this->skin
->commentBlock( $rc_comment, $rcObj->getTitle() );
921 # Show how many people are watching this if enabled
922 $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers
);
924 $r .= "</td></tr></table>\n";
929 * If enhanced RC is in use, this function takes the previously cached
930 * RC lines, arranges them, and outputs the HTML
932 protected function recentChangesBlock() {
933 if( count ( $this->rc_cache
) == 0 ) {
937 foreach( $this->rc_cache
as $block ) {
938 if( count( $block ) < 2 ) {
939 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
941 $blockOut .= $this->recentChangesBlockGroup( $block );
945 return '<div>'.$blockOut.'</div>';
949 * Returns text for the end of RC
950 * If enhanced RC is in use, returns pretty much all the text
952 public function endRecentChangesList() {
953 return $this->recentChangesBlock() . parent
::endRecentChangesList();