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 );
189 $articlelink = EnhancedChangesList
::maybeWatchedLink( $articlelink, $watched );
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 .= '<span class="mw-rc-user">' .
212 $this->skin
->userLink( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] ) .
213 '</span><span class="mw-rc-usertoollinks">' .
214 $this->skin
->userToolLinks( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] ) .
219 /** insert a formatted action */
220 protected function insertAction(&$s, &$rc) {
222 if( $rc->mAttribs
['rc_type'] == RC_LOG
) {
224 if ( $this->isDeleted($rc,LogPage
::DELETED_ACTION
) ) {
225 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
227 $s .= ' ' . LogPage
::actionText( $rc->mAttribs
['rc_log_type'], $rc->mAttribs
['rc_log_action'],
228 $rc->getTitle(), $this->skin
, LogPage
::extractParams($rc->mAttribs
['rc_params']), true, true );
233 /** insert a formatted comment */
234 protected function insertComment(&$s, &$rc) {
236 if( $rc->mAttribs
['rc_type'] != RC_MOVE
&& $rc->mAttribs
['rc_type'] != RC_MOVE_OVER_REDIRECT
) {
238 if ( $this->isDeleted($rc,Revision
::DELETED_COMMENT
) ) {
239 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
241 $s .= $this->skin
->commentBlock( $rc->mAttribs
['rc_comment'], $rc->getTitle() );
247 * Check whether to enable recent changes patrol features
250 public static function usePatrol() {
252 return $wgUser->useRCPatrol();
256 * Returns the string which indicates the number of watching users
258 protected function numberofWatchingusers( $count ) {
260 static $cache = array();
262 if ( !isset( $cache[$count] ) ) {
263 $cache[$count] = wfMsgExt('number_of_watching_users_RCview',
264 array('parsemag', 'escape'), $wgLang->formatNum($count));
266 return $cache[$count];
273 * Determine if said field of a revision is hidden
274 * @param RCCacheEntry $rc
275 * @param int $field one of DELETED_* bitfield constants
278 public static function isDeleted( $rc, $field ) {
279 return ($rc->mAttribs
['rc_deleted'] & $field) == $field;
283 * Determine if the current user is allowed to view a particular
284 * field of this revision, if it's marked as deleted.
285 * @param RCCacheEntry $rc
289 public static function userCan( $rc, $field ) {
290 if( ( $rc->mAttribs
['rc_deleted'] & $field ) == $field ) {
292 $permission = ( $rc->mAttribs
['rc_deleted'] & Revision
::DELETED_RESTRICTED
) == Revision
::DELETED_RESTRICTED
295 wfDebug( "Checking for $permission due to $field match on $rc->mAttribs['rc_deleted']\n" );
296 return $wgUser->isAllowed( $permission );
305 * Generate a list of changes using the good old system (no javascript)
307 class OldChangesList
extends ChangesList
{
309 * Format a line using the old system (aka without any javascript).
311 public function recentChangesLine( &$rc, $watched = false ) {
312 global $wgContLang, $wgRCShowChangedSize, $wgUser;
314 $fname = 'ChangesList::recentChangesLineOld';
315 wfProfileIn( $fname );
317 # Extract DB fields into local scope
318 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
319 extract( $rc->mAttribs
);
321 # Should patrol-related stuff be shown?
322 $unpatrolled = $wgUser->useRCPatrol() && $rc_patrolled == 0;
324 $dateheader = ""; // $s now contains only <li>...</li>, for hooks' convenience.
325 $this->insertDateHeader($dateheader,$rc_timestamp);
330 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
331 $this->insertMove( $s, $rc );
333 } elseif( $rc_log_type ) {
334 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
335 $this->insertLog( $s, $logtitle, $rc_log_type );
336 // Log entries (old format) or log targets, and special pages
337 } elseif( $rc_namespace == NS_SPECIAL
) {
338 list( $specialName, $specialSubpage ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
339 if ( $specialName == 'Log' ) {
340 $this->insertLog( $s, $rc->getTitle(), $specialSubpage );
342 wfDebug( "Unexpected special page in recentchanges\n" );
346 wfProfileIn($fname.'-page');
348 $this->insertDiffHist($s, $rc, $unpatrolled);
350 # M, N, b and ! (minor, new, bot and unpatrolled)
351 $s .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $unpatrolled, '', $rc_bot );
352 $this->insertArticleLink($s, $rc, $unpatrolled, $watched);
354 wfProfileOut($fname.'-page');
357 wfProfileIn( $fname.'-rest' );
359 $this->insertTimestamp($s,$rc);
361 if( $wgRCShowChangedSize ) {
362 $s .= ( $rc->getCharacterDifference() == '' ?
'' : $rc->getCharacterDifference() . ' . . ' );
365 $this->insertUserRelatedLinks($s,$rc);
366 # Log action text (if any)
367 $this->insertAction($s, $rc);
368 # Edit or log comment
369 $this->insertComment($s, $rc);
371 # Mark revision as deleted if so
372 if ( !$rc_log_type && $this->isDeleted($rc,Revision
::DELETED_TEXT
) )
373 $s .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
374 if($rc->numberofWatchingusers
> 0) {
375 $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers
));
378 wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) );
380 $s = "<li>$s</li>\n";
382 wfProfileOut( $fname.'-rest' );
384 wfProfileOut( $fname );
385 return $dateheader . $s;
391 * Generate a list of changes using an Enhanced system (use javascript).
393 class EnhancedChangesList
extends ChangesList
{
396 * Add the JavaScript file for enhanced changeslist
399 public function beginRecentChangesList() {
400 global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
401 $this->rc_cache
= array();
402 $this->rcMoveIndex
= 0;
403 $this->rcCacheIndex
= 0;
404 $this->lastdate
= '';
405 $this->rclistOpen
= false;
406 $script = Xml
::tags( 'script', array(
407 'type' => $wgJsMimeType,
408 'src' => $wgStylePath . "/common/enhancedchanges.js?$wgStyleVersion" ), '' );
412 * Format a line for enhanced recentchange (aka with javascript and block of lines).
414 public function recentChangesLine( &$baseRC, $watched = false ) {
415 global $wgLang, $wgContLang, $wgUser;
417 # Create a specialised object
418 $rc = RCCacheEntry
::newFromParent( $baseRC );
420 # Extract fields from DB into the function scope (rc_xxxx variables)
421 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
422 extract( $rc->mAttribs
);
423 $curIdEq = 'curid=' . $rc_cur_id;
425 # If it's a new day, add the headline and flush the cache
426 $date = $wgLang->date( $rc_timestamp, true);
428 if( $date != $this->lastdate
) {
429 # Process current cache
430 $ret = $this->recentChangesBlock();
431 $this->rc_cache
= array();
432 $ret .= "<h4>{$date}</h4>\n";
433 $this->lastdate
= $date;
436 # Should patrol-related stuff be shown?
437 if( $wgUser->useRCPatrol() ) {
438 $rc->unpatrolled
= !$rc_patrolled;
440 $rc->unpatrolled
= false;
443 $showdifflinks = true;
446 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
447 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
448 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
449 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
450 // Log entries (old format) and special pages
451 } elseif( $rc_namespace == NS_SPECIAL
) {
452 list( $specialName, $logtype ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
453 if ( $specialName == 'Log' ) {
455 $logname = LogPage
::logName( $logtype );
456 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
458 wfDebug( "Unexpected special page in recentchanges\n" );
461 // New unpatrolled pages
462 } else if( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
463 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
465 } else if( $rc_type == RC_LOG
) {
467 $logtitle = SpecialPage
::getTitleFor( 'Log', $rc_log_type );
468 $clink = '(' . $this->skin
->makeKnownLinkObj( $logtitle, LogPage
::logName($rc_log_type) ) . ')';
470 $clink = $this->skin
->makeLinkObj( $rc->getTitle(), '' );
475 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
478 # Don't show unusable diff links
479 if ( !ChangesList
::userCan($rc,Revision
::DELETED_TEXT
) ) {
480 $showdifflinks = false;
483 $time = $wgContLang->time( $rc_timestamp, true, true );
484 $rc->watched
= $watched;
486 $rc->timestamp
= $time;
487 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
489 # Make "cur" and "diff" links
490 if( $rc->unpatrolled
) {
491 $rcIdQuery = "&rcid={$rc_id}";
495 $querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid";
496 $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery";
497 $aprops = ' tabindex="'.$baseRC->counter
.'"';
498 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['cur'], $querycur, '' ,'', $aprops );
500 # Make "diff" an "cur" links
501 if( !$showdifflinks ) {
502 $curLink = $this->message
['cur'];
503 $diffLink = $this->message
['diff'];
504 } else if( $rc_type == RC_NEW ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
505 if( $rc_type != RC_NEW
) {
506 $curLink = $this->message
['cur'];
508 $diffLink = $this->message
['diff'];
510 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['diff'], $querydiff, '' ,'', $aprops );
514 if( !$showdifflinks ) {
515 $lastLink = $this->message
['last'];
516 } else if( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
517 $lastLink = $this->message
['last'];
519 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['last'],
520 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
524 if( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
525 $rc->userlink
= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
527 $rc->userlink
= $this->skin
->userLink( $rc_user, $rc_user_text );
528 $rc->usertalklink
= $this->skin
->userToolLinks( $rc_user, $rc_user_text );
531 $rc->lastlink
= $lastLink;
532 $rc->curlink
= $curLink;
533 $rc->difflink
= $diffLink;
535 # Put accumulated information into the cache, for later display
536 # Page moves go on their own line
537 $title = $rc->getTitle();
538 $secureName = $title->getPrefixedDBkey();
539 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
540 # Use an @ character to prevent collision with page names
541 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
543 # Logs are grouped by type
544 if( $rc_type == RC_LOG
){
545 $secureName = SpecialPage
::getTitleFor( 'Log', $rc_log_type )->getPrefixedDBkey();
547 if( !isset( $this->rc_cache
[$secureName] ) ) {
548 $this->rc_cache
[$secureName] = array();
550 array_push( $this->rc_cache
[$secureName], $rc );
558 protected function recentChangesBlockGroup( $block ) {
559 global $wgLang, $wgContLang, $wgRCShowChangedSize;
560 $r = '<table cellpadding="0" cellspacing="0" border="0" style="background: none"><tr>';
562 # Collate list of users
563 $userlinks = array();
565 $unpatrolled = false;
567 $curId = $currentRevision = 0;
568 # Some catalyst variables...
571 foreach( $block as $rcObj ) {
572 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
573 if( $rcObj->mAttribs
['rc_new'] ) {
576 // If all log actions to this page were hidden, then don't
577 // give the name of the affected page for this block!
578 if( !$this->isDeleted( $rcObj, LogPage
::DELETED_ACTION
) ) {
581 $u = $rcObj->userlink
;
582 if( !isset( $userlinks[$u] ) ) {
585 if( $rcObj->unpatrolled
) {
588 if( $rcObj->mAttribs
['rc_type'] != RC_LOG
) {
591 # Get the latest entry with a page_id and oldid
592 # since logs may not have these.
593 if( !$curId && $rcObj->mAttribs
['rc_cur_id'] ) {
594 $curId = $rcObj->mAttribs
['rc_cur_id'];
596 if( !$currentRevision && $rcObj->mAttribs
['rc_this_oldid'] ) {
597 $currentRevision = $rcObj->mAttribs
['rc_this_oldid'];
600 $bot = $rcObj->mAttribs
['rc_bot'];
604 # Sort the list and convert to text
605 krsort( $userlinks );
608 foreach( $userlinks as $userlink => $count) {
610 $text .= $wgContLang->getDirMark();
612 $text .= ' (' . $wgLang->formatNum( $count ) . '×)';
614 array_push( $users, $text );
617 $users = ' <span class="changedby">[' . implode( $this->message
['semicolon-separator'], $users ) . ']</span>';
619 # ID for JS visibility toggle
620 $jsid = $this->rcCacheIndex
;
621 # onclick handler to toggle hidden/expanded
622 $toggleLink = "onclick='toggleVisibility($jsid); return false'";
624 $expandTitle = htmlspecialchars( wfMsg('rc-enhanced-expand') );
625 $closeTitle = htmlspecialchars( wfMsg('rc-enhanced-hide') );
627 $tl = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
628 $tl .= "<span id='mw-rc-closearrow-$jsid' class='mw-changeslist-hidden' style='display:none'><a href='#' $toggleLink title='$closeTitle'>" . $this->downArrow() . "</a></span>";
629 $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.' ';
632 $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot );
635 $r .= ' '.$block[0]->timestamp
.' </tt></td><td>';
639 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
641 $r .= $this->maybeWatchedLink( $block[0]->link
, $block[0]->watched
);
644 $r .= $wgContLang->getDirMark();
646 $curIdEq = 'curid=' . $curId;
649 static $nchanges = array();
650 if ( !isset( $nchanges[$n] ) ) {
651 $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) );
657 if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
659 } else if( $isnew ) {
662 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
663 $nchanges[$n], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
668 # Character difference (does not apply if only log items)
669 if( $wgRCShowChangedSize && !$alllogs ) {
671 $first = count($block) - 1;
672 # Some events (like logs) have an "empty" size, so we need to skip those...
673 while( $last < $first && $block[$last]->mAttribs
['rc_new_len'] === NULL ) {
676 while( $first > $last && $block[$first]->mAttribs
['rc_old_len'] === NULL ) {
680 $chardiff = $rcObj->getCharacterDifference( $block[$first]->mAttribs
['rc_old_len'],
681 $block[$last]->mAttribs
['rc_new_len'] );
683 if( $chardiff == '' ) {
686 $r .= ' ' . $chardiff. ' . . ';
692 // don't show history link for logs
693 } else if( $namehidden ||
!$block[0]->getTitle()->exists() ) {
694 $r .= '(' . $this->message
['history'] . ')';
696 $r .= '(' . $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
697 $this->message
['history'], $curIdEq.'&action=history' ) . ')';
701 $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers
);
703 $r .= "</td></tr></table>\n";
706 $r .= '<div id="mw-rc-subentries-'.$jsid.'" class="mw-changeslist-hidden"><table cellpadding="0" cellspacing="0" border="0" style="background: none">';
707 foreach( $block as $rcObj ) {
708 # Get rc_xxxx variables
709 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
710 extract( $rcObj->mAttribs
);
712 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
713 $r .= '<tr><td valign="top">';
714 $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
715 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
716 $r .= ' </tt></td><td valign="top">';
719 if( $rc_this_oldid != 0 ) {
720 $o = 'oldid='.$rc_this_oldid;
723 if( $rc_type == RC_LOG
) {
724 $link = '<tt>'.$rcObj->timestamp
.'</tt> ';
726 } else if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
727 $link = '<span class="history-deleted"><tt>'.$rcObj->timestamp
.'</tt></span> ';
729 $rcIdEq = ($rcObj->unpatrolled
&& $rc_type == RC_NEW
) ?
'&rcid='.$rcObj->mAttribs
['rc_id'] : '';
731 $link = '<tt>'.$this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, $curIdEq.'&'.$o.$rcIdEq ).'</tt>';
732 if( $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) )
733 $link = '<span class="history-deleted">'.$link.'</span> ';
737 if ( !$rc_type == RC_LOG ||
$rc_type == RC_NEW
) {
739 $r .= $rcObj->curlink
;
740 $r .= $this->message
['semicolon-separator'];
741 $r .= $rcObj->lastlink
;
747 if( $wgRCShowChangedSize ) {
748 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : $rcObj->getCharacterDifference() . ' . . ' ) ;
751 $r .= $rcObj->userlink
;
752 $r .= $rcObj->usertalklink
;
754 parent
::insertAction( $r, $rcObj );
756 parent
::insertComment( $r, $rcObj );
757 # Mark revision as deleted
758 if( !$rc_log_type && $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) ) {
759 $r .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
762 $r .= "</td></tr>\n";
764 $r .= "</table></div>\n";
766 $this->rcCacheIndex++
;
770 protected function maybeWatchedLink( $link, $watched=false ) {
772 // FIXME: css style might be more appropriate
773 return '<strong class="mw-watched">' . $link . '</strong>';
775 return '<span class="mw-rc-unwatched">' . $link . '</span>';
780 * Generate HTML for an arrow or placeholder graphic
781 * @param string $dir one of '', 'd', 'l', 'r'
782 * @param string $alt text
783 * @param string $title text
784 * @return string HTML <img> tag
786 protected function arrow( $dir, $alt='', $title='' ) {
788 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
789 $encAlt = htmlspecialchars( $alt );
790 $encTitle = htmlspecialchars( $title );
791 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
795 * Generate HTML for a right- or left-facing arrow,
796 * depending on language direction.
797 * @return string HTML <img> tag
799 protected function sideArrow() {
801 $dir = $wgContLang->isRTL() ?
'l' : 'r';
802 return $this->arrow( $dir, '+', wfMsg('rc-enhanced-expand') );
806 * Generate HTML for a down-facing arrow
807 * depending on language direction.
808 * @return string HTML <img> tag
810 protected function downArrow() {
811 return $this->arrow( 'd', '-', wfMsg('rc-enhanced-hide') );
815 * Generate HTML for a spacer image
816 * @return string HTML <img> tag
818 protected function spacerArrow() {
819 return $this->arrow( '', codepointToUtf8( 0xa0 ) ); // non-breaking space
823 * Add a set of spaces
824 * @return string HTML <td> tag
826 protected function spacerIndent() {
827 return ' ';
831 * Enhanced RC ungrouped line.
832 * @return string a HTML formated line (generated using $r)
834 protected function recentChangesBlockLine( $rcObj ) {
835 global $wgContLang, $wgRCShowChangedSize;
837 # Get rc_xxxx variables
838 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
839 extract( $rcObj->mAttribs
);
840 $curIdEq = 'curid='.$rc_cur_id;
842 $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>';
844 $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . ' ';
847 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
848 $r .= ' '; // 4 flags -> 4 spaces
850 $r .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
852 $r .= ' '.$rcObj->timestamp
.' </tt></td><td>';
854 # Article or log link
856 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
857 $logname = LogPage
::logName( $rc_log_type );
858 $r .= '(' . $this->skin
->makeKnownLinkObj($logtitle, $logname ) . ')';
859 } else if( !$this->userCan($rcObj,Revision
::DELETED_TEXT
) ) {
860 $r .= '<span class="history-deleted">' . $rcObj->link
. '</span>';
862 $r .= $this->maybeWatchedLink( $rcObj->link
, $rcObj->watched
);
865 # Diff and hist links
866 if ( $rc_type != RC_LOG
) {
867 $r .= ' ('. $rcObj->difflink
. $this->message
['semicolon-separator'];
868 $r .= $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')';
873 if( $wgRCShowChangedSize ) {
874 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : ' ' . $rcObj->getCharacterDifference() . ' . . ' ) ;
878 $r .= ' '.$rcObj->userlink
. $rcObj->usertalklink
;
880 # Log action (if any)
882 if( $this->isDeleted($rcObj,LogPage
::DELETED_ACTION
) ) {
883 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
885 $r .= ' ' . LogPage
::actionText( $rc_log_type, $rc_log_action, $rcObj->getTitle(),
886 $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() );
900 # Show how many people are watching this if enabled
901 $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers
);
903 $r .= "</td></tr></table>\n";
908 * If enhanced RC is in use, this function takes the previously cached
909 * RC lines, arranges them, and outputs the HTML
911 protected function recentChangesBlock() {
912 if( count ( $this->rc_cache
) == 0 ) {
916 foreach( $this->rc_cache
as $block ) {
917 if( count( $block ) < 2 ) {
918 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
920 $blockOut .= $this->recentChangesBlockGroup( $block );
924 return '<div>'.$blockOut.'</div>';
928 * Returns text for the end of RC
929 * If enhanced RC is in use, returns pretty much all the text
931 public function endRecentChangesList() {
932 return $this->recentChangesBlock() . parent
::endRecentChangesList();