6 class RCCacheEntry
extends RecentChange
{
7 var $secureName, $link;
8 var $curlink , $difflink, $lastlink, $usertalklink, $versionlink;
9 var $userlink, $timestamp, $watched;
11 static function newFromParent( $rc ) {
12 $rc2 = new RCCacheEntry
;
13 $rc2->mAttribs
= $rc->mAttribs
;
14 $rc2->mExtra
= $rc->mExtra
;
20 * Class to show various lists of changes:
26 # Called by history lists and recent changes
30 * Changeslist contructor
33 public function __construct( &$skin ) {
35 $this->preCacheMessages();
39 * Fetch an appropriate changes list class for the specified user
40 * Some users might want to use an enhanced list format, for instance
42 * @param $user User to fetch the list class for
43 * @return ChangesList derivative
45 public static function newFromUser( &$user ) {
46 $sk = $user->getSkin();
48 if( wfRunHooks( 'FetchChangesList', array( &$user, &$sk, &$list ) ) ) {
49 return $user->getOption( 'usenewrc' ) ?
50 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 if( !isset( $this->message
) ) {
62 foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last '.
63 'blocklink history boteditletter semicolon-separator' ) as $msg ) {
64 $this->message
[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
71 * Returns the appropriate flags for new page, minor change and patrolling
74 * @param bool $patrolled
75 * @param string $nothing, string to use for empty space
79 protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = ' ', $bot = false ) {
81 '<span class="newpage">' . $this->message
['newpageletter'] . '</span>' : $nothing;
83 '<span class="minor">' . $this->message
['minoreditletter'] . '</span>' : $nothing;
84 $f .= $bot ?
'<span class="bot">' . $this->message
['boteditletter'] . '</span>' : $nothing;
85 $f .= $patrolled ?
'<span class="unpatrolled">!</span>' : $nothing;
90 * Returns text for the start of the tabular part of RC
93 public function beginRecentChangesList() {
94 $this->rc_cache
= array();
95 $this->rcMoveIndex
= 0;
96 $this->rcCacheIndex
= 0;
98 $this->rclistOpen
= false;
103 * Show formatted char difference
104 * @param int $old bytes
105 * @param int $new bytes
108 public static function showCharacterDifference( $old, $new ) {
109 global $wgRCChangedSizeThreshold, $wgLang;
110 $szdiff = $new - $old;
111 $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape'), $wgLang->formatNum($szdiff) );
112 if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
117 if( $szdiff === 0 ) {
118 return "<$tag class='mw-plusminus-null'>($formatedSize)</$tag>";
119 } elseif( $szdiff > 0 ) {
120 return "<$tag class='mw-plusminus-pos'>(+$formatedSize)</$tag>";
122 return "<$tag class='mw-plusminus-neg'>($formatedSize)</$tag>";
127 * Returns text for the end of RC
130 public function endRecentChangesList() {
131 if( $this->rclistOpen
) {
138 protected function insertMove( &$s, $rc ) {
140 $s .= '(' . $this->message
['diff'] . ') (';
142 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $this->message
['hist'], 'action=history' ) .
144 # "[[x]] moved to [[y]]"
145 $msg = ( $rc->mAttribs
['rc_type'] == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
146 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
147 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
150 protected function insertDateHeader( &$s, $rc_timestamp ) {
152 # Make date header if necessary
153 $date = $wgLang->date( $rc_timestamp, true, true );
154 if( $date != $this->lastdate
) {
155 if( '' != $this->lastdate
) {
158 $s .= '<h4>'.$date."</h4>\n<ul class=\"special\">";
159 $this->lastdate
= $date;
160 $this->rclistOpen
= true;
164 protected function insertLog( &$s, $title, $logtype ) {
165 $logname = LogPage
::logName( $logtype );
166 $s .= '(' . $this->skin
->makeKnownLinkObj($title, $logname ) . ')';
169 protected function insertDiffHist( &$s, &$rc, $unpatrolled ) {
171 if( !$this->userCan($rc,Revision
::DELETED_TEXT
) ) {
172 $diffLink = $this->message
['diff'];
173 } else if( $rc->mAttribs
['rc_type'] == RC_NEW ||
$rc->mAttribs
['rc_type'] == RC_LOG
) {
174 $diffLink = $this->message
['diff'];
176 $rcidparam = $unpatrolled ?
177 array( 'rcid' => $rc->mAttribs
['rc_id'] ) : array();
178 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['diff'],
180 'curid' => $rc->mAttribs
['rc_cur_id'],
181 'diff' => $rc->mAttribs
['rc_this_oldid'],
182 'oldid' => $rc->mAttribs
['rc_last_oldid'] ),
184 '', '', ' tabindex="'.$rc->counter
.'"');
186 $s .= '('.$diffLink.') (';
188 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['hist'],
190 'curid' => $rc->mAttribs
['rc_cur_id'],
191 'action' => 'history' ) ) );
195 protected function insertArticleLink( &$s, &$rc, $unpatrolled, $watched ) {
197 # If it's a new article, there is no diff link, but if it hasn't been
198 # patrolled yet, we need to give users a way to do so
199 $params = ( $unpatrolled && $rc->mAttribs
['rc_type'] == RC_NEW
) ?
200 'rcid='.$rc->mAttribs
['rc_id'] : '';
201 if( $this->isDeleted($rc,Revision
::DELETED_TEXT
) ) {
202 $articlelink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', $params );
203 $articlelink = '<span class="history-deleted">'.$articlelink.'</span>';
205 $articlelink = ' '. $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', $params );
207 # Bolden pages watched by this user
209 $articlelink = "<strong class=\"mw-watched\">{$articlelink}</strong>";
212 $articlelink .= $wgContLang->getDirMark();
214 wfRunHooks( 'ChangesListInsertArticleLink',
215 array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched) );
217 $s .= " $articlelink";
220 protected function insertTimestamp( &$s, $rc ) {
222 $s .= $this->message
['semicolon-separator'] . $wgLang->time( $rc->mAttribs
['rc_timestamp'], true, true ) . ' . . ';
225 /** Insert links to user page, user talk page and eventually a blocking link */
226 public function insertUserRelatedLinks(&$s, &$rc) {
227 if ( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
228 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
230 $s .= $this->skin
->userLink( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
231 $s .= $this->skin
->userToolLinks( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
235 /** insert a formatted action */
236 protected function insertAction(&$s, &$rc) {
238 if( $rc->mAttribs
['rc_type'] == RC_LOG
) {
240 if ( $this->isDeleted($rc,LogPage
::DELETED_ACTION
) ) {
241 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
243 $s .= ' ' . LogPage
::actionText( $rc->mAttribs
['rc_log_type'], $rc->mAttribs
['rc_log_action'],
244 $rc->getTitle(), $this->skin
, LogPage
::extractParams($rc->mAttribs
['rc_params']), true, true );
249 /** insert a formatted comment */
250 protected function insertComment(&$s, &$rc) {
252 if( $rc->mAttribs
['rc_type'] != RC_MOVE
&& $rc->mAttribs
['rc_type'] != RC_MOVE_OVER_REDIRECT
) {
254 if ( $this->isDeleted($rc,Revision
::DELETED_COMMENT
) ) {
255 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
257 $s .= $this->skin
->commentBlock( $rc->mAttribs
['rc_comment'], $rc->getTitle() );
263 * Check whether to enable recent changes patrol features
266 public static function usePatrol() {
268 return $wgUser->useRCPatrol();
272 * Returns the string which indicates the number of watching users
274 protected function numberofWatchingusers( $count ) {
276 static $cache = array();
278 if ( !isset( $cache[$count] ) ) {
279 $cache[$count] = wfMsgExt('number_of_watching_users_RCview',
280 array('parsemag', 'escape'), $wgLang->formatNum($count));
282 return $cache[$count];
289 * Determine if said field of a revision is hidden
290 * @param RCCacheEntry $rc
291 * @param int $field one of DELETED_* bitfield constants
294 public static function isDeleted( $rc, $field ) {
295 return ($rc->mAttribs
['rc_deleted'] & $field) == $field;
299 * Determine if the current user is allowed to view a particular
300 * field of this revision, if it's marked as deleted.
301 * @param RCCacheEntry $rc
305 public static function userCan( $rc, $field ) {
306 if( ( $rc->mAttribs
['rc_deleted'] & $field ) == $field ) {
308 $permission = ( $rc->mAttribs
['rc_deleted'] & Revision
::DELETED_RESTRICTED
) == Revision
::DELETED_RESTRICTED
311 wfDebug( "Checking for $permission due to $field match on $rc->mAttribs['rc_deleted']\n" );
312 return $wgUser->isAllowed( $permission );
318 protected function maybeWatchedLink( $link, $watched=false ) {
320 // FIXME: css style might be more appropriate
321 return '<strong class="mw-watched">' . $link . '</strong>';
323 return '<span class="mw-rc-unwatched">' . $link . '</span>';
330 * Generate a list of changes using the good old system (no javascript)
332 class OldChangesList
extends ChangesList
{
334 * Format a line using the old system (aka without any javascript).
336 public function recentChangesLine( &$rc, $watched = false ) {
337 global $wgContLang, $wgRCShowChangedSize, $wgUser;
339 wfProfileIn( __METHOD__
);
341 # Extract DB fields into local scope
342 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
343 extract( $rc->mAttribs
);
345 # Should patrol-related stuff be shown?
346 $unpatrolled = $wgUser->useRCPatrol() && $rc_patrolled == 0;
348 $dateheader = ""; // $s now contains only <li>...</li>, for hooks' convenience.
349 $this->insertDateHeader($dateheader,$rc_timestamp);
354 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
355 $this->insertMove( $s, $rc );
357 } elseif( $rc_log_type ) {
358 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
359 $this->insertLog( $s, $logtitle, $rc_log_type );
360 // Log entries (old format) or log targets, and special pages
361 } elseif( $rc_namespace == NS_SPECIAL
) {
362 list( $specialName, $specialSubpage ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
363 if ( $specialName == 'Log' ) {
364 $this->insertLog( $s, $rc->getTitle(), $specialSubpage );
366 wfDebug( "Unexpected special page in recentchanges\n" );
370 $this->insertDiffHist($s, $rc, $unpatrolled);
371 # M, N, b and ! (minor, new, bot and unpatrolled)
372 $s .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $unpatrolled, '', $rc_bot );
373 $this->insertArticleLink($s, $rc, $unpatrolled, $watched);
376 $this->insertTimestamp($s,$rc);
378 if( $wgRCShowChangedSize ) {
379 $s .= ( $rc->getCharacterDifference() == '' ?
'' : $rc->getCharacterDifference() . ' . . ' );
382 $this->insertUserRelatedLinks($s,$rc);
383 # Log action text (if any)
384 $this->insertAction($s, $rc);
385 # Edit or log comment
386 $this->insertComment($s, $rc);
388 # Mark revision as deleted if so
389 if ( !$rc_log_type && $this->isDeleted($rc,Revision
::DELETED_TEXT
) )
390 $s .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
391 if($rc->numberofWatchingusers
> 0) {
392 $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers
));
395 wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) );
397 $s = "<li>$s</li>\n";
399 wfProfileOut( __METHOD__
);
400 return $dateheader . $s;
406 * Generate a list of changes using an Enhanced system (use javascript).
408 class EnhancedChangesList
extends ChangesList
{
411 * Add the JavaScript file for enhanced changeslist
414 public function beginRecentChangesList() {
415 global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
416 $this->rc_cache
= array();
417 $this->rcMoveIndex
= 0;
418 $this->rcCacheIndex
= 0;
419 $this->lastdate
= '';
420 $this->rclistOpen
= false;
421 $script = Xml
::tags( 'script', array(
422 'type' => $wgJsMimeType,
423 'src' => $wgStylePath . "/common/enhancedchanges.js?$wgStyleVersion" ), '' );
427 * Format a line for enhanced recentchange (aka with javascript and block of lines).
429 public function recentChangesLine( &$baseRC, $watched = false ) {
430 global $wgLang, $wgContLang, $wgUser;
432 # Create a specialised object
433 $rc = RCCacheEntry
::newFromParent( $baseRC );
435 # Extract fields from DB into the function scope (rc_xxxx variables)
436 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
437 extract( $rc->mAttribs
);
438 $curIdEq = 'curid=' . $rc_cur_id;
440 # If it's a new day, add the headline and flush the cache
441 $date = $wgLang->date( $rc_timestamp, true );
443 if( $date != $this->lastdate
) {
444 # Process current cache
445 $ret = $this->recentChangesBlock();
446 $this->rc_cache
= array();
447 $ret .= "<h4>{$date}</h4>\n";
448 $this->lastdate
= $date;
451 # Should patrol-related stuff be shown?
452 if( $wgUser->useRCPatrol() ) {
453 $rc->unpatrolled
= !$rc_patrolled;
455 $rc->unpatrolled
= false;
458 $showdifflinks = true;
461 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
462 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
463 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
464 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
465 // New unpatrolled pages
466 } else if( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
467 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
469 } else if( $rc_type == RC_LOG
) {
470 var_dump( $rc_log_type );
472 $logtitle = SpecialPage
::getTitleFor( 'Log', $rc_log_type );
473 $clink = '(' . $this->skin
->makeKnownLinkObj( $logtitle, LogPage
::logName($rc_log_type) ) . ')';
475 $clink = $this->skin
->makeLinkObj( $rc->getTitle(), '' );
478 // Log entries (old format) and special pages
479 } elseif( $rc_namespace == NS_SPECIAL
) {
480 list( $specialName, $logtype ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
481 if ( $specialName == 'Log' ) {
483 $logname = LogPage
::logName( $logtype );
484 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
486 wfDebug( "Unexpected special page in recentchanges\n" );
491 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
494 # Don't show unusable diff links
495 if ( !ChangesList
::userCan($rc,Revision
::DELETED_TEXT
) ) {
496 $showdifflinks = false;
499 $time = $wgContLang->time( $rc_timestamp, true, true );
500 $rc->watched
= $watched;
502 $rc->timestamp
= $time;
503 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
505 # Make "cur" and "diff" links
506 if( $rc->unpatrolled
) {
507 $rcIdQuery = "&rcid={$rc_id}";
511 $querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid";
512 $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery";
513 $aprops = ' tabindex="'.$baseRC->counter
.'"';
514 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['cur'], $querycur, '' ,'', $aprops );
516 # Make "diff" an "cur" links
517 if( !$showdifflinks ) {
518 $curLink = $this->message
['cur'];
519 $diffLink = $this->message
['diff'];
520 } else if( $rc_type == RC_NEW ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
521 if( $rc_type != RC_NEW
) {
522 $curLink = $this->message
['cur'];
524 $diffLink = $this->message
['diff'];
526 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['diff'], $querydiff, '' ,'', $aprops );
530 if( !$showdifflinks ) {
531 $lastLink = $this->message
['last'];
532 } else if( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
533 $lastLink = $this->message
['last'];
535 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['last'],
536 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
540 if( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
541 $rc->userlink
= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
543 $rc->userlink
= $this->skin
->userLink( $rc_user, $rc_user_text );
544 $rc->usertalklink
= $this->skin
->userToolLinks( $rc_user, $rc_user_text );
547 $rc->lastlink
= $lastLink;
548 $rc->curlink
= $curLink;
549 $rc->difflink
= $diffLink;
551 # Put accumulated information into the cache, for later display
552 # Page moves go on their own line
553 $title = $rc->getTitle();
554 $secureName = $title->getPrefixedDBkey();
555 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
556 # Use an @ character to prevent collision with page names
557 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
559 # Logs are grouped by type
560 if( $rc_type == RC_LOG
){
561 $secureName = SpecialPage
::getTitleFor( 'Log', $rc_log_type )->getPrefixedDBkey();
563 if( !isset( $this->rc_cache
[$secureName] ) ) {
564 $this->rc_cache
[$secureName] = array();
566 array_push( $this->rc_cache
[$secureName], $rc );
574 protected function recentChangesBlockGroup( $block ) {
575 global $wgLang, $wgContLang, $wgRCShowChangedSize;
576 $r = '<table cellpadding="0" cellspacing="0" border="0" style="background: none"><tr>';
578 # Collate list of users
579 $userlinks = array();
581 $unpatrolled = false;
583 $curId = $currentRevision = 0;
584 # Some catalyst variables...
587 foreach( $block as $rcObj ) {
588 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
589 if( $rcObj->mAttribs
['rc_new'] ) {
592 // If all log actions to this page were hidden, then don't
593 // give the name of the affected page for this block!
594 if( !$this->isDeleted( $rcObj, LogPage
::DELETED_ACTION
) ) {
597 $u = $rcObj->userlink
;
598 if( !isset( $userlinks[$u] ) ) {
601 if( $rcObj->unpatrolled
) {
604 if( $rcObj->mAttribs
['rc_type'] != RC_LOG
) {
607 # Get the latest entry with a page_id and oldid
608 # since logs may not have these.
609 if( !$curId && $rcObj->mAttribs
['rc_cur_id'] ) {
610 $curId = $rcObj->mAttribs
['rc_cur_id'];
612 if( !$currentRevision && $rcObj->mAttribs
['rc_this_oldid'] ) {
613 $currentRevision = $rcObj->mAttribs
['rc_this_oldid'];
616 $bot = $rcObj->mAttribs
['rc_bot'];
620 # Sort the list and convert to text
621 krsort( $userlinks );
624 foreach( $userlinks as $userlink => $count) {
626 $text .= $wgContLang->getDirMark();
628 $text .= ' (' . $wgLang->formatNum( $count ) . '×)';
630 array_push( $users, $text );
633 $users = ' <span class="changedby">[' . implode( $this->message
['semicolon-separator'], $users ) . ']</span>';
635 # ID for JS visibility toggle
636 $jsid = $this->rcCacheIndex
;
637 # onclick handler to toggle hidden/expanded
638 $toggleLink = "onclick='toggleVisibility($jsid); return false'";
640 $expandTitle = htmlspecialchars( wfMsg('rc-enhanced-expand') );
641 $closeTitle = htmlspecialchars( wfMsg('rc-enhanced-hide') );
643 $tl = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
644 $tl .= "<span id='mw-rc-closearrow-$jsid' class='mw-changeslist-hidden' style='display:none'><a href='#' $toggleLink title='$closeTitle'>" . $this->downArrow() . "</a></span>";
645 $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.' ';
648 $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot );
651 $r .= ' '.$block[0]->timestamp
.' </tt></td><td>';
655 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
656 } else if( $allLogs ) {
657 $r .= $this->maybeWatchedLink( $block[0]->link
, $block[0]->watched
);
659 $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled
, $block[0]->watched
);
662 $r .= $wgContLang->getDirMark();
664 $curIdEq = 'curid=' . $curId;
667 static $nchanges = array();
668 if ( !isset( $nchanges[$n] ) ) {
669 $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) );
675 if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
677 } else if( $isnew ) {
680 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
681 $nchanges[$n], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
687 // don't show history link for logs
688 } else if( $namehidden ||
!$block[0]->getTitle()->exists() ) {
689 $r .= $this->message
['semicolon-separator'] . $this->message
['hist'] . ')';
691 $r .= $this->message
['semicolon-separator'] . $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
692 $this->message
['hist'], $curIdEq . '&action=history' ) . ')';
696 # Character difference (does not apply if only log items)
697 if( $wgRCShowChangedSize && !$allLogs ) {
699 $first = count($block) - 1;
700 # Some events (like logs) have an "empty" size, so we need to skip those...
701 while( $last < $first && $block[$last]->mAttribs
['rc_new_len'] === NULL ) {
704 while( $first > $last && $block[$first]->mAttribs
['rc_old_len'] === NULL ) {
708 $chardiff = $rcObj->getCharacterDifference( $block[$first]->mAttribs
['rc_old_len'],
709 $block[$last]->mAttribs
['rc_new_len'] );
711 if( $chardiff == '' ) {
714 $r .= ' ' . $chardiff. ' . . ';
719 $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers
);
721 $r .= "</td></tr></table>\n";
724 $r .= '<div id="mw-rc-subentries-'.$jsid.'" class="mw-changeslist-hidden">';
725 $r .= '<table cellpadding="0" cellspacing="0" border="0" style="background: none">';
726 foreach( $block as $rcObj ) {
727 # Get rc_xxxx variables
728 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
729 extract( $rcObj->mAttribs
);
731 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
732 $r .= '<tr><td valign="top">';
733 $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
734 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
735 $r .= ' </tt></td><td valign="top">';
738 if( $rc_this_oldid != 0 ) {
739 $o = 'oldid='.$rc_this_oldid;
742 if( $rc_type == RC_LOG
) {
743 $link = '<tt>'.$rcObj->timestamp
.'</tt> ';
745 } else if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
746 $link = '<span class="history-deleted"><tt>'.$rcObj->timestamp
.'</tt></span> ';
748 $rcIdEq = ($rcObj->unpatrolled
&& $rc_type == RC_NEW
) ?
749 '&rcid='.$rcObj->mAttribs
['rc_id'] : '';
750 $link = '<tt>'.$this->skin
->makeKnownLinkObj( $rcObj->getTitle(),
751 $rcObj->timestamp
, $curIdEq.'&'.$o.$rcIdEq ).'</tt>';
752 if( $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) )
753 $link = '<span class="history-deleted">'.$link.'</span> ';
757 if ( !$rc_type == RC_LOG ||
$rc_type == RC_NEW
) {
759 $r .= $rcObj->curlink
;
760 $r .= $this->message
['semicolon-separator'];
761 $r .= $rcObj->lastlink
;
767 if( $wgRCShowChangedSize ) {
768 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : $rcObj->getCharacterDifference() . ' . . ' ) ;
771 $r .= $rcObj->userlink
;
772 $r .= $rcObj->usertalklink
;
774 parent
::insertAction( $r, $rcObj );
776 parent
::insertComment( $r, $rcObj );
777 # Mark revision as deleted
778 if( !$rc_log_type && $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) ) {
779 $r .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
782 $r .= "</td></tr>\n";
784 $r .= "</table></div>\n";
786 $this->rcCacheIndex++
;
791 * Generate HTML for an arrow or placeholder graphic
792 * @param string $dir one of '', 'd', 'l', 'r'
793 * @param string $alt text
794 * @param string $title text
795 * @return string HTML <img> tag
797 protected function arrow( $dir, $alt='', $title='' ) {
799 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
800 $encAlt = htmlspecialchars( $alt );
801 $encTitle = htmlspecialchars( $title );
802 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
806 * Generate HTML for a right- or left-facing arrow,
807 * depending on language direction.
808 * @return string HTML <img> tag
810 protected function sideArrow() {
812 $dir = $wgContLang->isRTL() ?
'l' : 'r';
813 return $this->arrow( $dir, '+', wfMsg('rc-enhanced-expand') );
817 * Generate HTML for a down-facing arrow
818 * depending on language direction.
819 * @return string HTML <img> tag
821 protected function downArrow() {
822 return $this->arrow( 'd', '-', wfMsg('rc-enhanced-hide') );
826 * Generate HTML for a spacer image
827 * @return string HTML <img> tag
829 protected function spacerArrow() {
830 return $this->arrow( '', codepointToUtf8( 0xa0 ) ); // non-breaking space
834 * Add a set of spaces
835 * @return string HTML <td> tag
837 protected function spacerIndent() {
838 return ' ';
842 * Enhanced RC ungrouped line.
843 * @return string a HTML formated line (generated using $r)
845 protected function recentChangesBlockLine( $rcObj ) {
846 global $wgContLang, $wgRCShowChangedSize;
847 # Get rc_xxxx variables
848 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
849 extract( $rcObj->mAttribs
);
850 $curIdEq = "curid={$rc_cur_id}";
852 $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>';
853 $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . ' ';
855 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
856 $r .= ' '; // 4 flags -> 4 spaces
858 $r .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
860 $r .= ' '.$rcObj->timestamp
.' </tt></td><td>';
861 # Article or log link
863 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
864 $logname = LogPage
::logName( $rc_log_type );
865 $r .= '(' . $this->skin
->makeKnownLinkObj($logtitle, $logname ) . ')';
867 $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled
, $rcObj->watched
);
869 # Diff and hist links
870 if ( $rc_type != RC_LOG
) {
871 $r .= ' ('. $rcObj->difflink
. $this->message
['semicolon-separator'];
872 $r .= $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')';
876 if( $wgRCShowChangedSize ) {
877 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : $rcObj->getCharacterDifference() . ' . . ' ) ;
880 $r .= ' '.$rcObj->userlink
. $rcObj->usertalklink
;
881 # Log action (if any)
883 if( $this->isDeleted($rcObj,LogPage
::DELETED_ACTION
) ) {
884 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
886 $r .= ' ' . LogPage
::actionText( $rc_log_type, $rc_log_action, $rcObj->getTitle(),
887 $this->skin
, LogPage
::extractParams($rc_params), true, true );
890 # Edit or log comment
891 if( $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
893 if ( $this->isDeleted($rcObj,LogPage
::DELETED_COMMENT
) ) {
894 $r .= ' <span class="history-deleted">' . wfMsg('rev-deleted-comment') . '</span>';
896 $r .= $this->skin
->commentBlock( $rc_comment, $rcObj->getTitle() );
899 # Show how many people are watching this if enabled
900 $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers
);
902 $r .= "</td></tr></table>\n";
907 * If enhanced RC is in use, this function takes the previously cached
908 * RC lines, arranges them, and outputs the HTML
910 protected function recentChangesBlock() {
911 if( count ( $this->rc_cache
) == 0 ) {
915 foreach( $this->rc_cache
as $block ) {
916 if( count( $block ) < 2 ) {
917 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
919 $blockOut .= $this->recentChangesBlockGroup( $block );
922 return '<div>'.$blockOut.'</div>';
926 * Returns text for the end of RC
927 * If enhanced RC is in use, returns pretty much all the text
929 public function endRecentChangesList() {
930 return $this->recentChangesBlock() . parent
::endRecentChangesList();