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 .= '<span class="mw-rc-move">(' . $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 .= '<span class="mw-rc-log">(' . $this->skin
->makeKnownLinkObj( $title, $logname ) . ')</span>';
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 .= '<span class="mw-rc-diffhist">('.$diffLink.') (';
169 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['hist'],
171 'curid' => $rc->mAttribs
['rc_cur_id'],
172 'action' => 'history' ) ) );
173 $s .= ')</span> . . ';
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 = '<span class="mw-rc-unwatched">' . $articlelink . '</span>';
195 $articlelink .= $wgContLang->getDirMark();
197 wfRunHooks('ChangesListInsertArticleLink',
198 array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched));
200 $s .= ' '.$articlelink;
203 protected function insertTimestamp(&$s, $rc) {
206 $s .= $this->message
['semicolon-separator'] . $wgLang->time( $rc->mAttribs
['rc_timestamp'], true, true ) . ' . . ';
209 /** Insert links to user page, user talk page and eventually a blocking link */
210 public function insertUserRelatedLinks( &$s, &$rc ) {
211 if ( $this->isDeleted( $rc,Revision
::DELETED_USER
) ) {
212 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
214 $s .= '<span class="mw-rc-user">' .
215 $this->skin
->userLink( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] ) .
216 '</span><span class="mw-rc-usertoollinks">' .
217 $this->skin
->userToolLinks( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] ) .
222 /** insert a formatted action */
223 protected function insertAction(&$s, &$rc) {
225 if( $rc->mAttribs
['rc_type'] == RC_LOG
) {
227 if ( $this->isDeleted($rc,LogPage
::DELETED_ACTION
) ) {
228 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
230 $s .= ' ' . LogPage
::actionText( $rc->mAttribs
['rc_log_type'], $rc->mAttribs
['rc_log_action'],
231 $rc->getTitle(), $this->skin
, LogPage
::extractParams($rc->mAttribs
['rc_params']), true, true );
236 /** insert a formatted comment */
237 protected function insertComment(&$s, &$rc) {
239 if( $rc->mAttribs
['rc_type'] != RC_MOVE
&& $rc->mAttribs
['rc_type'] != RC_MOVE_OVER_REDIRECT
) {
241 if ( $this->isDeleted($rc,Revision
::DELETED_COMMENT
) ) {
242 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
244 $s .= $this->skin
->commentBlock( $rc->mAttribs
['rc_comment'], $rc->getTitle() );
250 * Check whether to enable recent changes patrol features
253 public static function usePatrol() {
255 return $wgUser->useRCPatrol();
259 * Returns the string which indicates the number of watching users
261 protected function numberofWatchingusers( $count ) {
263 static $cache = array();
265 if ( !isset( $cache[$count] ) ) {
266 $cache[$count] = wfMsgExt('number_of_watching_users_RCview',
267 array('parsemag', 'escape'), $wgLang->formatNum($count));
269 return $cache[$count];
276 * Determine if said field of a revision is hidden
277 * @param RCCacheEntry $rc
278 * @param int $field one of DELETED_* bitfield constants
281 public static function isDeleted( $rc, $field ) {
282 return ($rc->mAttribs
['rc_deleted'] & $field) == $field;
286 * Determine if the current user is allowed to view a particular
287 * field of this revision, if it's marked as deleted.
288 * @param RCCacheEntry $rc
292 public static function userCan( $rc, $field ) {
293 if( ( $rc->mAttribs
['rc_deleted'] & $field ) == $field ) {
295 $permission = ( $rc->mAttribs
['rc_deleted'] & Revision
::DELETED_RESTRICTED
) == Revision
::DELETED_RESTRICTED
298 wfDebug( "Checking for $permission due to $field match on $rc->mAttribs['rc_deleted']\n" );
299 return $wgUser->isAllowed( $permission );
308 * Generate a list of changes using the good old system (no javascript)
310 class OldChangesList
extends ChangesList
{
312 * Format a line using the old system (aka without any javascript).
314 public function recentChangesLine( &$rc, $watched = false ) {
315 global $wgContLang, $wgRCShowChangedSize, $wgUser;
317 $fname = 'ChangesList::recentChangesLineOld';
318 wfProfileIn( $fname );
320 # Extract DB fields into local scope
321 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
322 extract( $rc->mAttribs
);
324 # Should patrol-related stuff be shown?
325 $unpatrolled = $wgUser->useRCPatrol() && $rc_patrolled == 0;
327 $dateheader = ""; // $s now contains only <li>...</li>, for hooks' convenience.
328 $this->insertDateHeader($dateheader,$rc_timestamp);
333 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
334 $this->insertMove( $s, $rc );
336 } elseif( $rc_log_type ) {
337 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
338 $this->insertLog( $s, $logtitle, $rc_log_type );
339 // Log entries (old format) or log targets, and special pages
340 } elseif( $rc_namespace == NS_SPECIAL
) {
341 list( $specialName, $specialSubpage ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
342 if ( $specialName == 'Log' ) {
343 $this->insertLog( $s, $rc->getTitle(), $specialSubpage );
345 wfDebug( "Unexpected special page in recentchanges\n" );
349 wfProfileIn($fname.'-page');
351 $this->insertDiffHist($s, $rc, $unpatrolled);
353 # M, N, b and ! (minor, new, bot and unpatrolled)
354 $s .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $unpatrolled, '', $rc_bot );
355 $this->insertArticleLink($s, $rc, $unpatrolled, $watched);
357 wfProfileOut($fname.'-page');
360 wfProfileIn( $fname.'-rest' );
362 $this->insertTimestamp($s,$rc);
364 if( $wgRCShowChangedSize ) {
365 $s .= ( $rc->getCharacterDifference() == '' ?
'' : $rc->getCharacterDifference() . ' . . ' );
368 $this->insertUserRelatedLinks($s,$rc);
369 # Log action text (if any)
370 $this->insertAction($s, $rc);
371 # Edit or log comment
372 $this->insertComment($s, $rc);
374 # Mark revision as deleted if so
375 if ( !$rc_log_type && $this->isDeleted($rc,Revision
::DELETED_TEXT
) )
376 $s .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
377 if($rc->numberofWatchingusers
> 0) {
378 $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers
));
381 wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) );
383 $s = "<li>$s</li>\n";
385 wfProfileOut( $fname.'-rest' );
387 wfProfileOut( $fname );
388 return $dateheader . $s;
394 * Generate a list of changes using an Enhanced system (use javascript).
396 class EnhancedChangesList
extends ChangesList
{
399 * Add the JavaScript file for enhanced changeslist
402 public function beginRecentChangesList() {
403 global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
404 $this->rc_cache
= array();
405 $this->rcMoveIndex
= 0;
406 $this->rcCacheIndex
= 0;
407 $this->lastdate
= '';
408 $this->rclistOpen
= false;
409 $script = Xml
::tags( 'script', array(
410 'type' => $wgJsMimeType,
411 'src' => $wgStylePath . "/common/enhancedchanges.js?$wgStyleVersion" ), '' );
415 * Format a line for enhanced recentchange (aka with javascript and block of lines).
417 public function recentChangesLine( &$baseRC, $watched = false ) {
418 global $wgLang, $wgContLang, $wgUser;
420 # Create a specialised object
421 $rc = RCCacheEntry
::newFromParent( $baseRC );
423 # Extract fields from DB into the function scope (rc_xxxx variables)
424 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
425 extract( $rc->mAttribs
);
426 $curIdEq = 'curid=' . $rc_cur_id;
428 # If it's a new day, add the headline and flush the cache
429 $date = $wgLang->date( $rc_timestamp, true);
431 if( $date != $this->lastdate
) {
432 # Process current cache
433 $ret = $this->recentChangesBlock();
434 $this->rc_cache
= array();
435 $ret .= "<h4>{$date}</h4>\n";
436 $this->lastdate
= $date;
439 # Should patrol-related stuff be shown?
440 if( $wgUser->useRCPatrol() ) {
441 $rc->unpatrolled
= !$rc_patrolled;
443 $rc->unpatrolled
= false;
446 $showdifflinks = true;
449 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
450 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
451 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
452 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
453 // Log entries (old format) and special pages
454 } elseif( $rc_namespace == NS_SPECIAL
) {
455 list( $specialName, $logtype ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
456 if ( $specialName == 'Log' ) {
458 $logname = LogPage
::logName( $logtype );
459 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
461 wfDebug( "Unexpected special page in recentchanges\n" );
464 // New unpatrolled pages
465 } else if( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
466 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
468 } else if( $rc_type == RC_LOG
) {
470 $logtitle = SpecialPage
::getTitleFor( 'Log', $rc_log_type );
471 $clink = '(' . $this->skin
->makeKnownLinkObj( $logtitle, LogPage
::logName($rc_log_type) ) . ')';
473 $clink = $this->skin
->makeLinkObj( $rc->getTitle(), '' );
478 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
481 # Don't show unusable diff links
482 if ( !ChangesList
::userCan($rc,Revision
::DELETED_TEXT
) ) {
483 $showdifflinks = false;
486 $time = $wgContLang->time( $rc_timestamp, true, true );
487 $rc->watched
= $watched;
489 $rc->timestamp
= $time;
490 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
492 # Make "cur" and "diff" links
493 if( $rc->unpatrolled
) {
494 $rcIdQuery = "&rcid={$rc_id}";
498 $querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid";
499 $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery";
500 $aprops = ' tabindex="'.$baseRC->counter
.'"';
501 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['cur'], $querycur, '' ,'', $aprops );
503 # Make "diff" an "cur" links
504 if( !$showdifflinks ) {
505 $curLink = $this->message
['cur'];
506 $diffLink = $this->message
['diff'];
507 } else if( $rc_type == RC_NEW ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
508 if( $rc_type != RC_NEW
) {
509 $curLink = $this->message
['cur'];
511 $diffLink = $this->message
['diff'];
513 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['diff'], $querydiff, '' ,'', $aprops );
517 if( !$showdifflinks ) {
518 $lastLink = $this->message
['last'];
519 } else if( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
520 $lastLink = $this->message
['last'];
522 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['last'],
523 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
527 if( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
528 $rc->userlink
= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
530 $rc->userlink
= $this->skin
->userLink( $rc_user, $rc_user_text );
531 $rc->usertalklink
= $this->skin
->userToolLinks( $rc_user, $rc_user_text );
534 $rc->lastlink
= $lastLink;
535 $rc->curlink
= $curLink;
536 $rc->difflink
= $diffLink;
538 # Put accumulated information into the cache, for later display
539 # Page moves go on their own line
540 $title = $rc->getTitle();
541 $secureName = $title->getPrefixedDBkey();
542 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
543 # Use an @ character to prevent collision with page names
544 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
546 # Logs are grouped by type
547 if( $rc_type == RC_LOG
){
548 $secureName = SpecialPage
::getTitleFor( 'Log', $rc_log_type )->getPrefixedDBkey();
550 if( !isset( $this->rc_cache
[$secureName] ) ) {
551 $this->rc_cache
[$secureName] = array();
553 array_push( $this->rc_cache
[$secureName], $rc );
561 protected function recentChangesBlockGroup( $block ) {
562 global $wgLang, $wgContLang, $wgRCShowChangedSize;
563 $r = '<table cellpadding="0" cellspacing="0" border="0" style="background: none"><tr>';
565 # Collate list of users
566 $userlinks = array();
568 $unpatrolled = false;
570 $curId = $currentRevision = 0;
571 # Some catalyst variables...
574 foreach( $block as $rcObj ) {
575 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
576 if( $rcObj->mAttribs
['rc_new'] ) {
579 // If all log actions to this page were hidden, then don't
580 // give the name of the affected page for this block!
581 if( !$this->isDeleted( $rcObj, LogPage
::DELETED_ACTION
) ) {
584 $u = $rcObj->userlink
;
585 if( !isset( $userlinks[$u] ) ) {
588 if( $rcObj->unpatrolled
) {
591 if( $rcObj->mAttribs
['rc_type'] != RC_LOG
) {
594 # Get the latest entry with a page_id and oldid
595 # since logs may not have these.
596 if( !$curId && $rcObj->mAttribs
['rc_cur_id'] ) {
597 $curId = $rcObj->mAttribs
['rc_cur_id'];
599 if( !$currentRevision && $rcObj->mAttribs
['rc_this_oldid'] ) {
600 $currentRevision = $rcObj->mAttribs
['rc_this_oldid'];
603 $bot = $rcObj->mAttribs
['rc_bot'];
607 # Sort the list and convert to text
608 krsort( $userlinks );
611 foreach( $userlinks as $userlink => $count) {
613 $text .= $wgContLang->getDirMark();
615 $text .= ' (' . $wgLang->formatNum( $count ) . '×)';
617 array_push( $users, $text );
620 $users = ' <span class="changedby">[' . implode( $this->message
['semicolon-separator'], $users ) . ']</span>';
622 # ID for JS visibility toggle
623 $jsid = $this->rcCacheIndex
;
624 # onclick handler to toggle hidden/expanded
625 $toggleLink = "onclick='toggleVisibility($jsid); return false'";
627 $expandTitle = htmlspecialchars( wfMsg('rc-enhanced-expand') );
628 $closeTitle = htmlspecialchars( wfMsg('rc-enhanced-hide') );
630 $tl = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
631 $tl .= "<span id='mw-rc-closearrow-$jsid' class='mw-changeslist-hidden' style='display:none'><a href='#' $toggleLink title='$closeTitle'>" . $this->downArrow() . "</a></span>";
632 $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.' ';
635 $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot );
638 $r .= ' '.$block[0]->timestamp
.' </tt></td><td>';
642 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
644 $r .= $this->maybeWatchedLink( $block[0]->link
, $block[0]->watched
);
647 $r .= $wgContLang->getDirMark();
649 $curIdEq = 'curid=' . $curId;
652 static $nchanges = array();
653 if ( !isset( $nchanges[$n] ) ) {
654 $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) );
660 if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
662 } else if( $isnew ) {
665 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
666 $nchanges[$n], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
671 # Character difference (does not apply if only log items)
672 if( $wgRCShowChangedSize && !$alllogs ) {
674 $first = count($block) - 1;
675 # Some events (like logs) have an "empty" size, so we need to skip those...
676 while( $last < $first && $block[$last]->mAttribs
['rc_new_len'] === NULL ) {
679 while( $first > $last && $block[$first]->mAttribs
['rc_old_len'] === NULL ) {
683 $chardiff = $rcObj->getCharacterDifference( $block[$first]->mAttribs
['rc_old_len'],
684 $block[$last]->mAttribs
['rc_new_len'] );
686 if( $chardiff == '' ) {
689 $r .= ' ' . $chardiff. ' . . ';
695 // don't show history link for logs
696 } else if( $namehidden ||
!$block[0]->getTitle()->exists() ) {
697 $r .= '(' . $this->message
['history'] . ')';
699 $r .= '(' . $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
700 $this->message
['history'], $curIdEq.'&action=history' ) . ')';
704 $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers
);
706 $r .= "</td></tr></table>\n";
709 $r .= '<div id="mw-rc-subentries-'.$jsid.'" class="mw-changeslist-hidden"><table cellpadding="0" cellspacing="0" border="0" style="background: none">';
710 foreach( $block as $rcObj ) {
711 # Get rc_xxxx variables
712 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
713 extract( $rcObj->mAttribs
);
715 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
716 $r .= '<tr><td valign="top">';
717 $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
718 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
719 $r .= ' </tt></td><td valign="top">';
722 if( $rc_this_oldid != 0 ) {
723 $o = 'oldid='.$rc_this_oldid;
726 if( $rc_type == RC_LOG
) {
727 $link = '<tt>'.$rcObj->timestamp
.'</tt> ';
729 } else if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
730 $link = '<span class="history-deleted"><tt>'.$rcObj->timestamp
.'</tt></span> ';
732 $rcIdEq = ($rcObj->unpatrolled
&& $rc_type == RC_NEW
) ?
'&rcid='.$rcObj->mAttribs
['rc_id'] : '';
734 $link = '<tt>'.$this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, $curIdEq.'&'.$o.$rcIdEq ).'</tt>';
735 if( $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) )
736 $link = '<span class="history-deleted">'.$link.'</span> ';
740 if ( !$rc_type == RC_LOG ||
$rc_type == RC_NEW
) {
742 $r .= $rcObj->curlink
;
743 $r .= $this->message
['semicolon-separator'];
744 $r .= $rcObj->lastlink
;
750 if( $wgRCShowChangedSize ) {
751 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : $rcObj->getCharacterDifference() . ' . . ' ) ;
754 $r .= $rcObj->userlink
;
755 $r .= $rcObj->usertalklink
;
757 parent
::insertAction( $r, $rcObj );
759 parent
::insertComment( $r, $rcObj );
760 # Mark revision as deleted
761 if( !$rc_log_type && $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) ) {
762 $r .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
765 $r .= "</td></tr>\n";
767 $r .= "</table></div>\n";
769 $this->rcCacheIndex++
;
773 protected function maybeWatchedLink( $link, $watched=false ) {
775 // FIXME: css style might be more appropriate
776 return '<strong class="mw-watched">' . $link . '</strong>';
778 return '<span class="mw-rc-unwatched">' . $link . '</span>';
783 * Generate HTML for an arrow or placeholder graphic
784 * @param string $dir one of '', 'd', 'l', 'r'
785 * @param string $alt text
786 * @param string $title text
787 * @return string HTML <img> tag
789 protected function arrow( $dir, $alt='', $title='' ) {
791 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
792 $encAlt = htmlspecialchars( $alt );
793 $encTitle = htmlspecialchars( $title );
794 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
798 * Generate HTML for a right- or left-facing arrow,
799 * depending on language direction.
800 * @return string HTML <img> tag
802 protected function sideArrow() {
804 $dir = $wgContLang->isRTL() ?
'l' : 'r';
805 return $this->arrow( $dir, '+', wfMsg('rc-enhanced-expand') );
809 * Generate HTML for a down-facing arrow
810 * depending on language direction.
811 * @return string HTML <img> tag
813 protected function downArrow() {
814 return $this->arrow( 'd', '-', wfMsg('rc-enhanced-hide') );
818 * Generate HTML for a spacer image
819 * @return string HTML <img> tag
821 protected function spacerArrow() {
822 return $this->arrow( '', codepointToUtf8( 0xa0 ) ); // non-breaking space
826 * Add a set of spaces
827 * @return string HTML <td> tag
829 protected function spacerIndent() {
830 return ' ';
834 * Enhanced RC ungrouped line.
835 * @return string a HTML formated line (generated using $r)
837 protected function recentChangesBlockLine( $rcObj ) {
838 global $wgContLang, $wgRCShowChangedSize;
840 # Get rc_xxxx variables
841 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
842 extract( $rcObj->mAttribs
);
843 $curIdEq = 'curid='.$rc_cur_id;
845 $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>';
847 $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . ' ';
850 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
851 $r .= ' '; // 4 flags -> 4 spaces
853 $r .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
855 $r .= ' '.$rcObj->timestamp
.' </tt></td><td>';
857 # Article or log link
859 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
860 $logname = LogPage
::logName( $rc_log_type );
861 $r .= '(' . $this->skin
->makeKnownLinkObj($logtitle, $logname ) . ')';
862 } else if( !$this->userCan($rcObj,Revision
::DELETED_TEXT
) ) {
863 $r .= '<span class="history-deleted">' . $rcObj->link
. '</span>';
865 $r .= $this->maybeWatchedLink( $rcObj->link
, $rcObj->watched
);
868 # Diff and hist links
869 if ( $rc_type != RC_LOG
) {
870 $r .= ' ('. $rcObj->difflink
. $this->message
['semicolon-separator'];
871 $r .= $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')';
876 if( $wgRCShowChangedSize ) {
877 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : ' ' . $rcObj->getCharacterDifference() . ' . . ' ) ;
881 $r .= ' '.$rcObj->userlink
. $rcObj->usertalklink
;
883 # Log action (if any)
885 if( $this->isDeleted($rcObj,LogPage
::DELETED_ACTION
) ) {
886 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
888 $r .= ' ' . LogPage
::actionText( $rc_log_type, $rc_log_action, $rcObj->getTitle(),
889 $this->skin
, LogPage
::extractParams($rc_params), true, true );
893 # Edit or log comment
894 if( $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
896 if ( $this->isDeleted($rcObj,LogPage
::DELETED_COMMENT
) ) {
897 $r .= ' <span class="history-deleted">' . wfMsg('rev-deleted-comment') . '</span>';
899 $r .= $this->skin
->commentBlock( $rc_comment, $rcObj->getTitle() );
903 # Show how many people are watching this if enabled
904 $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers
);
906 $r .= "</td></tr></table>\n";
911 * If enhanced RC is in use, this function takes the previously cached
912 * RC lines, arranges them, and outputs the HTML
914 protected function recentChangesBlock() {
915 if( count ( $this->rc_cache
) == 0 ) {
919 foreach( $this->rc_cache
as $block ) {
920 if( count( $block ) < 2 ) {
921 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
923 $blockOut .= $this->recentChangesBlockGroup( $block );
927 return '<div>'.$blockOut.'</div>';
931 * Returns text for the end of RC
932 * If enhanced RC is in use, returns pretty much all the text
934 public function endRecentChangesList() {
935 return $this->recentChangesBlock() . parent
::endRecentChangesList();