f453687e1d29378cecd6fb9ce729aeff10e444ee
6 class RCCacheEntry
extends RecentChange
8 var $secureName, $link;
9 var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ;
10 var $userlink, $timestamp, $watched;
12 static function newFromParent( $rc ) {
13 $rc2 = new RCCacheEntry
;
14 $rc2->mAttribs
= $rc->mAttribs
;
15 $rc2->mExtra
= $rc->mExtra
;
21 * Class to show various lists of changes:
27 # Called by history lists and recent changes
31 * Changeslist contructor
34 function __construct( &$skin ) {
36 $this->preCacheMessages();
40 * Fetch an appropriate changes list class for the specified user
41 * Some users might want to use an enhanced list format, for instance
43 * @param $user User to fetch the list class for
44 * @return ChangesList derivative
46 public static function newFromUser( &$user ) {
47 $sk = $user->getSkin();
49 if( wfRunHooks( 'FetchChangesList', array( &$user, &$sk, &$list ) ) ) {
50 return $user->getOption( 'usenewrc' ) ?
new EnhancedChangesList( $sk ) : new OldChangesList( $sk );
57 * As we use the same small set of messages in various methods and that
58 * they are called often, we call them once and save them in $this->message
60 private function preCacheMessages() {
61 // Precache various messages
62 if( !isset( $this->message
) ) {
63 foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last '.
64 'blocklink history boteditletter semicolon-separator' ) as $msg ) {
65 $this->message
[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
72 * Returns the appropriate flags for new page, minor change and patrolling
75 * @param bool $patrolled
76 * @param string $nothing, string to use for empty space
80 protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = ' ', $bot = false ) {
81 $f = $new ?
'<span class="newpage">' . $this->message
['newpageletter'] . '</span>'
83 $f .= $minor ?
'<span class="minor">' . $this->message
['minoreditletter'] . '</span>'
85 $f .= $bot ?
'<span class="bot">' . $this->message
['boteditletter'] . '</span>' : $nothing;
86 $f .= $patrolled ?
'<span class="unpatrolled">!</span>' : $nothing;
91 * Returns text for the start of the tabular part of RC
94 public function beginRecentChangesList() {
95 $this->rc_cache
= array();
96 $this->rcMoveIndex
= 0;
97 $this->rcCacheIndex
= 0;
99 $this->rclistOpen
= false;
104 * Returns text for the end of RC
107 public function endRecentChangesList() {
108 if( $this->rclistOpen
) {
115 protected function insertMove( &$s, $rc ) {
117 $s .= '(' . $this->message
['diff'] . ') (';
119 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $this->message
['hist'], 'action=history' ) .
122 # "[[x]] moved to [[y]]"
123 $msg = ( $rc->mAttribs
['rc_type'] == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
124 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
125 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
128 protected function insertDateHeader(&$s, $rc_timestamp) {
131 # Make date header if necessary
132 $date = $wgLang->date( $rc_timestamp, true, true );
133 if( $date != $this->lastdate
) {
134 if( '' != $this->lastdate
) {
137 $s .= '<h4>'.$date."</h4>\n<ul class=\"special\">";
138 $this->lastdate
= $date;
139 $this->rclistOpen
= true;
143 protected function insertLog(&$s, $title, $logtype) {
144 $logname = LogPage
::logName( $logtype );
145 $s .= '(' . $this->skin
->makeKnownLinkObj($title, $logname ) . ')';
148 protected function insertDiffHist(&$s, &$rc, $unpatrolled) {
150 if( !$this->userCan($rc,Revision
::DELETED_TEXT
) ) {
151 $diffLink = $this->message
['diff'];
152 } else if( $rc->mAttribs
['rc_type'] == RC_NEW ||
$rc->mAttribs
['rc_type'] == RC_LOG
) {
153 $diffLink = $this->message
['diff'];
155 $rcidparam = $unpatrolled
156 ?
array( 'rcid' => $rc->mAttribs
['rc_id'] )
158 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['diff'],
160 'curid' => $rc->mAttribs
['rc_cur_id'],
161 'diff' => $rc->mAttribs
['rc_this_oldid'],
162 'oldid' => $rc->mAttribs
['rc_last_oldid'] ),
164 '', '', ' tabindex="'.$rc->counter
.'"');
166 $s .= '('.$diffLink.') (';
169 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['hist'],
171 'curid' => $rc->mAttribs
['rc_cur_id'],
172 'action' => 'history' ) ) );
176 protected function insertArticleLink(&$s, &$rc, $unpatrolled, $watched) {
178 # If it's a new article, there is no diff link, but if it hasn't been
179 # patrolled yet, we need to give users a way to do so
180 $params = ( $unpatrolled && $rc->mAttribs
['rc_type'] == RC_NEW
)
181 ?
'rcid='.$rc->mAttribs
['rc_id']
183 if( $this->isDeleted($rc,Revision
::DELETED_TEXT
) ) {
184 $articlelink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', $params );
185 $articlelink = '<span class="history-deleted">'.$articlelink.'</span>';
187 $articlelink = ' '. $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', $params );
190 $articlelink = "<strong class=\"mw-watched\">{$articlelink}</strong>";
192 $articlelink .= $wgContLang->getDirMark();
194 wfRunHooks('ChangesListInsertArticleLink',
195 array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched));
197 $s .= ' '.$articlelink;
200 protected function insertTimestamp(&$s, $rc) {
203 $s .= $this->message
['semicolon-separator'] . $wgLang->time( $rc->mAttribs
['rc_timestamp'], true, true ) . ' . . ';
206 /** Insert links to user page, user talk page and eventually a blocking link */
207 public function insertUserRelatedLinks(&$s, &$rc) {
208 if ( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
209 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
211 $s .= $this->skin
->userLink( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
212 $s .= $this->skin
->userToolLinks( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
216 /** insert a formatted action */
217 protected function insertAction(&$s, &$rc) {
219 if( $rc->mAttribs
['rc_type'] == RC_LOG
) {
221 if ( $this->isDeleted($rc,LogPage
::DELETED_ACTION
) ) {
222 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
224 $s .= ' ' . LogPage
::actionText( $rc->mAttribs
['rc_log_type'], $rc->mAttribs
['rc_log_action'],
225 $rc->getTitle(), $this->skin
, LogPage
::extractParams($rc->mAttribs
['rc_params']), true, true );
230 /** insert a formatted comment */
231 protected function insertComment(&$s, &$rc) {
233 if( $rc->mAttribs
['rc_type'] != RC_MOVE
&& $rc->mAttribs
['rc_type'] != RC_MOVE_OVER_REDIRECT
) {
235 if ( $this->isDeleted($rc,Revision
::DELETED_COMMENT
) ) {
236 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
238 $s .= $this->skin
->commentBlock( $rc->mAttribs
['rc_comment'], $rc->getTitle() );
244 * Check whether to enable recent changes patrol features
247 public static function usePatrol() {
249 return $wgUser->useRCPatrol();
253 * Returns the string which indicates the number of watching users
255 protected function numberofWatchingusers( $count ) {
257 static $cache = array();
259 if ( !isset( $cache[$count] ) ) {
260 $cache[$count] = wfMsgExt('number_of_watching_users_RCview',
261 array('parsemag', 'escape'), $wgLang->formatNum($count));
263 return $cache[$count];
270 * Determine if said field of a revision is hidden
271 * @param RCCacheEntry $rc
272 * @param int $field one of DELETED_* bitfield constants
275 public static function isDeleted( $rc, $field ) {
276 return ($rc->mAttribs
['rc_deleted'] & $field) == $field;
280 * Determine if the current user is allowed to view a particular
281 * field of this revision, if it's marked as deleted.
282 * @param RCCacheEntry $rc
286 public static function userCan( $rc, $field ) {
287 if( ( $rc->mAttribs
['rc_deleted'] & $field ) == $field ) {
289 $permission = ( $rc->mAttribs
['rc_deleted'] & Revision
::DELETED_RESTRICTED
) == Revision
::DELETED_RESTRICTED
292 wfDebug( "Checking for $permission due to $field match on $rc->mAttribs['rc_deleted']\n" );
293 return $wgUser->isAllowed( $permission );
302 * Generate a list of changes using the good old system (no javascript)
304 class OldChangesList
extends ChangesList
{
306 * Format a line using the old system (aka without any javascript).
308 public function recentChangesLine( &$rc, $watched = false ) {
309 global $wgContLang, $wgRCShowChangedSize, $wgUser;
311 $fname = 'ChangesList::recentChangesLineOld';
312 wfProfileIn( $fname );
314 # Extract DB fields into local scope
315 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
316 extract( $rc->mAttribs
);
318 # Should patrol-related stuff be shown?
319 $unpatrolled = $wgUser->useRCPatrol() && $rc_patrolled == 0;
321 $dateheader = ""; // $s now contains only <li>...</li>, for hooks' convenience.
322 $this->insertDateHeader($dateheader,$rc_timestamp);
327 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
328 $this->insertMove( $s, $rc );
330 } elseif( $rc_log_type ) {
331 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
332 $this->insertLog( $s, $logtitle, $rc_log_type );
333 // Log entries (old format) or log targets, and special pages
334 } elseif( $rc_namespace == NS_SPECIAL
) {
335 list( $specialName, $specialSubpage ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
336 if ( $specialName == 'Log' ) {
337 $this->insertLog( $s, $rc->getTitle(), $specialSubpage );
339 wfDebug( "Unexpected special page in recentchanges\n" );
343 wfProfileIn($fname.'-page');
345 $this->insertDiffHist($s, $rc, $unpatrolled);
347 # M, N, b and ! (minor, new, bot and unpatrolled)
348 $s .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $unpatrolled, '', $rc_bot );
349 $this->insertArticleLink($s, $rc, $unpatrolled, $watched);
351 wfProfileOut($fname.'-page');
354 wfProfileIn( $fname.'-rest' );
356 $this->insertTimestamp($s,$rc);
358 if( $wgRCShowChangedSize ) {
359 $s .= ( $rc->getCharacterDifference() == '' ?
'' : $rc->getCharacterDifference() . ' . . ' );
362 $this->insertUserRelatedLinks($s,$rc);
363 # Log action text (if any)
364 $this->insertAction($s, $rc);
365 # Edit or log comment
366 $this->insertComment($s, $rc);
368 # Mark revision as deleted if so
369 if ( !$rc_log_type && $this->isDeleted($rc,Revision
::DELETED_TEXT
) )
370 $s .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
371 if($rc->numberofWatchingusers
> 0) {
372 $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers
));
375 wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) );
377 $s = "<li>$s</li>\n";
379 wfProfileOut( $fname.'-rest' );
381 wfProfileOut( $fname );
382 return $dateheader . $s;
388 * Generate a list of changes using an Enhanced system (use javascript).
390 class EnhancedChangesList
extends ChangesList
{
393 * Add the JavaScript file for enhanced changeslist
396 public function beginRecentChangesList() {
397 global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
398 $this->rc_cache
= array();
399 $this->rcMoveIndex
= 0;
400 $this->rcCacheIndex
= 0;
401 $this->lastdate
= '';
402 $this->rclistOpen
= false;
403 $script = Xml
::tags( 'script', array(
404 'type' => $wgJsMimeType,
405 'src' => $wgStylePath . "/common/enhancedchanges.js?$wgStyleVersion" ), '' );
409 * Format a line for enhanced recentchange (aka with javascript and block of lines).
411 public function recentChangesLine( &$baseRC, $watched = false ) {
412 global $wgLang, $wgContLang, $wgUser;
414 # Create a specialised object
415 $rc = RCCacheEntry
::newFromParent( $baseRC );
417 # Extract fields from DB into the function scope (rc_xxxx variables)
418 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
419 extract( $rc->mAttribs
);
420 $curIdEq = 'curid=' . $rc_cur_id;
422 # If it's a new day, add the headline and flush the cache
423 $date = $wgLang->date( $rc_timestamp, true);
425 if( $date != $this->lastdate
) {
426 # Process current cache
427 $ret = $this->recentChangesBlock();
428 $this->rc_cache
= array();
429 $ret .= "<h4>{$date}</h4>\n";
430 $this->lastdate
= $date;
433 # Should patrol-related stuff be shown?
434 if( $wgUser->useRCPatrol() ) {
435 $rc->unpatrolled
= !$rc_patrolled;
437 $rc->unpatrolled
= false;
440 $showdifflinks = true;
443 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
444 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
445 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
446 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
447 // Log entries (old format) and special pages
448 } elseif( $rc_namespace == NS_SPECIAL
) {
449 list( $specialName, $logtype ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
450 if ( $specialName == 'Log' ) {
452 $logname = LogPage
::logName( $logtype );
453 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
455 wfDebug( "Unexpected special page in recentchanges\n" );
458 // New unpatrolled pages
459 } else if( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
460 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
462 } else if( $rc_type == RC_LOG
) {
464 $logtitle = SpecialPage
::getTitleFor( 'Log', $rc_log_type );
465 $clink = '(' . $this->skin
->makeKnownLinkObj( $logtitle, LogPage
::logName($rc_log_type) ) . ')';
467 $clink = $this->skin
->makeLinkObj( $rc->getTitle(), '' );
472 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
475 # Don't show unusable diff links
476 if ( !ChangesList
::userCan($rc,Revision
::DELETED_TEXT
) ) {
477 $showdifflinks = false;
480 $time = $wgContLang->time( $rc_timestamp, true, true );
481 $rc->watched
= $watched;
483 $rc->timestamp
= $time;
484 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
486 # Make "cur" and "diff" links
487 if( $rc->unpatrolled
) {
488 $rcIdQuery = "&rcid={$rc_id}";
492 $querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid";
493 $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery";
494 $aprops = ' tabindex="'.$baseRC->counter
.'"';
495 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['cur'], $querycur, '' ,'', $aprops );
497 # Make "diff" an "cur" links
498 if( !$showdifflinks ) {
499 $curLink = $this->message
['cur'];
500 $diffLink = $this->message
['diff'];
501 } else if( $rc_type == RC_NEW ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
502 if( $rc_type != RC_NEW
) {
503 $curLink = $this->message
['cur'];
505 $diffLink = $this->message
['diff'];
507 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['diff'], $querydiff, '' ,'', $aprops );
511 if( !$showdifflinks ) {
512 $lastLink = $this->message
['last'];
513 } else if( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
514 $lastLink = $this->message
['last'];
516 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['last'],
517 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
521 if( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
522 $rc->userlink
= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
524 $rc->userlink
= $this->skin
->userLink( $rc_user, $rc_user_text );
525 $rc->usertalklink
= $this->skin
->userToolLinks( $rc_user, $rc_user_text );
528 $rc->lastlink
= $lastLink;
529 $rc->curlink
= $curLink;
530 $rc->difflink
= $diffLink;
532 # Put accumulated information into the cache, for later display
533 # Page moves go on their own line
534 $title = $rc->getTitle();
535 $secureName = $title->getPrefixedDBkey();
536 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
537 # Use an @ character to prevent collision with page names
538 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
540 # Logs are grouped by type
541 if( $rc_type == RC_LOG
){
542 $secureName = SpecialPage
::getTitleFor( 'Log', $rc_log_type )->getPrefixedDBkey();
544 if( !isset( $this->rc_cache
[$secureName] ) ) {
545 $this->rc_cache
[$secureName] = array();
547 array_push( $this->rc_cache
[$secureName], $rc );
555 protected function recentChangesBlockGroup( $block ) {
556 global $wgLang, $wgContLang, $wgRCShowChangedSize;
557 $r = '<table cellpadding="0" cellspacing="0" border="0" style="background: none"><tr>';
559 # Collate list of users
560 $userlinks = array();
562 $unpatrolled = false;
564 $curId = $currentRevision = 0;
565 # Some catalyst variables...
568 foreach( $block as $rcObj ) {
569 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
570 if( $rcObj->mAttribs
['rc_new'] ) {
573 // If all log actions to this page were hidden, then don't
574 // give the name of the affected page for this block!
575 if( !$this->isDeleted( $rcObj, LogPage
::DELETED_ACTION
) ) {
578 $u = $rcObj->userlink
;
579 if( !isset( $userlinks[$u] ) ) {
582 if( $rcObj->unpatrolled
) {
585 if( $rcObj->mAttribs
['rc_type'] != RC_LOG
) {
588 # Get the latest entry with a page_id and oldid
589 # since logs may not have these.
590 if( !$curId && $rcObj->mAttribs
['rc_cur_id'] ) {
591 $curId = $rcObj->mAttribs
['rc_cur_id'];
593 if( !$currentRevision && $rcObj->mAttribs
['rc_this_oldid'] ) {
594 $currentRevision = $rcObj->mAttribs
['rc_this_oldid'];
597 $bot = $rcObj->mAttribs
['rc_bot'];
601 # Sort the list and convert to text
602 krsort( $userlinks );
605 foreach( $userlinks as $userlink => $count) {
607 $text .= $wgContLang->getDirMark();
609 $text .= ' (' . $wgLang->formatNum( $count ) . '×)';
611 array_push( $users, $text );
614 $users = ' <span class="changedby">[' . implode( $this->message
['semicolon-separator'], $users ) . ']</span>';
616 # ID for JS visibility toggle
617 $jsid = $this->rcCacheIndex
;
618 # onclick handler to toggle hidden/expanded
619 $toggleLink = "onclick='toggleVisibility($jsid); return false'";
621 $expandTitle = htmlspecialchars( wfMsg('rc-enhanced-expand') );
622 $closeTitle = htmlspecialchars( wfMsg('rc-enhanced-hide') );
624 $tl = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
625 $tl .= "<span id='mw-rc-closearrow-$jsid' class='mw-changeslist-hidden' style='display:none'><a href='#' $toggleLink title='$closeTitle'>" . $this->downArrow() . "</a></span>";
626 $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.' ';
629 $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot );
632 $r .= ' '.$block[0]->timestamp
.' </tt></td><td>';
636 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
638 $r .= $this->maybeWatchedLink( $block[0]->link
, $block[0]->watched
);
641 $r .= $wgContLang->getDirMark();
643 $curIdEq = 'curid=' . $curId;
646 static $nchanges = array();
647 if ( !isset( $nchanges[$n] ) ) {
648 $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) );
654 if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
656 } else if( $isnew ) {
659 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
660 $nchanges[$n], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
665 # Character difference (does not apply if only log items)
666 if( $wgRCShowChangedSize && !$alllogs ) {
668 $first = count($block) - 1;
669 # Some events (like logs) have an "empty" size, so we need to skip those...
670 while( $last < $first && $block[$last]->mAttribs
['rc_new_len'] === NULL ) {
673 while( $first > $last && $block[$first]->mAttribs
['rc_old_len'] === NULL ) {
677 $chardiff = $rcObj->getCharacterDifference( $block[$first]->mAttribs
['rc_old_len'],
678 $block[$last]->mAttribs
['rc_new_len'] );
680 if( $chardiff == '' ) {
683 $r .= ' ' . $chardiff. ' . . ';
689 // don't show history link for logs
690 } else if( $namehidden ||
!$block[0]->getTitle()->exists() ) {
691 $r .= '(' . $this->message
['history'] . ')';
693 $r .= '(' . $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
694 $this->message
['history'], $curIdEq.'&action=history' ) . ')';
698 $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers
);
700 $r .= "</td></tr></table>\n";
703 $r .= '<div id="mw-rc-subentries-'.$jsid.'" class="mw-changeslist-hidden"><table cellpadding="0" cellspacing="0" border="0" style="background: none">';
704 foreach( $block as $rcObj ) {
705 # Get rc_xxxx variables
706 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
707 extract( $rcObj->mAttribs
);
709 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
710 $r .= '<tr><td valign="top">';
711 $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
712 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
713 $r .= ' </tt></td><td valign="top">';
716 if( $rc_this_oldid != 0 ) {
717 $o = 'oldid='.$rc_this_oldid;
720 if( $rc_type == RC_LOG
) {
721 $link = '<tt>'.$rcObj->timestamp
.'</tt> ';
723 } else if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
724 $link = '<span class="history-deleted"><tt>'.$rcObj->timestamp
.'</tt></span> ';
726 $rcIdEq = ($rcObj->unpatrolled
&& $rc_type == RC_NEW
) ?
'&rcid='.$rcObj->mAttribs
['rc_id'] : '';
728 $link = '<tt>'.$this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, $curIdEq.'&'.$o.$rcIdEq ).'</tt>';
729 if( $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) )
730 $link = '<span class="history-deleted">'.$link.'</span> ';
734 if ( !$rc_type == RC_LOG ||
$rc_type == RC_NEW
) {
736 $r .= $rcObj->curlink
;
737 $r .= $this->message
['semicolon-separator'];
738 $r .= $rcObj->lastlink
;
744 if( $wgRCShowChangedSize ) {
745 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : $rcObj->getCharacterDifference() . ' . . ' ) ;
748 $r .= $rcObj->userlink
;
749 $r .= $rcObj->usertalklink
;
751 parent
::insertAction( $r, $rcObj );
753 parent
::insertComment( $r, $rcObj );
754 # Mark revision as deleted
755 if( !$rc_log_type && $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) ) {
756 $r .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
759 $r .= "</td></tr>\n";
761 $r .= "</table></div>\n";
763 $this->rcCacheIndex++
;
767 protected function maybeWatchedLink( $link, $watched=false ) {
769 // FIXME: css style might be more appropriate
770 return '<strong class="mw-watched">' . $link . '</strong>';
777 * Generate HTML for an arrow or placeholder graphic
778 * @param string $dir one of '', 'd', 'l', 'r'
779 * @param string $alt text
780 * @param string $title text
781 * @return string HTML <img> tag
783 protected function arrow( $dir, $alt='', $title='' ) {
785 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
786 $encAlt = htmlspecialchars( $alt );
787 $encTitle = htmlspecialchars( $title );
788 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
792 * Generate HTML for a right- or left-facing arrow,
793 * depending on language direction.
794 * @return string HTML <img> tag
796 protected function sideArrow() {
798 $dir = $wgContLang->isRTL() ?
'l' : 'r';
799 return $this->arrow( $dir, '+', wfMsg('rc-enhanced-expand') );
803 * Generate HTML for a down-facing arrow
804 * depending on language direction.
805 * @return string HTML <img> tag
807 protected function downArrow() {
808 return $this->arrow( 'd', '-', wfMsg('rc-enhanced-hide') );
812 * Generate HTML for a spacer image
813 * @return string HTML <img> tag
815 protected function spacerArrow() {
816 return $this->arrow( '', codepointToUtf8( 0xa0 ) ); // non-breaking space
820 * Add a set of spaces
821 * @return string HTML <td> tag
823 protected function spacerIndent() {
824 return ' ';
828 * Enhanced RC ungrouped line.
829 * @return string a HTML formated line (generated using $r)
831 protected function recentChangesBlockLine( $rcObj ) {
832 global $wgContLang, $wgRCShowChangedSize;
834 # Get rc_xxxx variables
835 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
836 extract( $rcObj->mAttribs
);
837 $curIdEq = 'curid='.$rc_cur_id;
839 $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>';
841 $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . ' ';
844 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
845 $r .= ' '; // 4 flags -> 4 spaces
847 $r .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
849 $r .= ' '.$rcObj->timestamp
.' </tt></td><td>';
851 # Article or log link
853 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
854 $logname = LogPage
::logName( $rc_log_type );
855 $r .= '(' . $this->skin
->makeKnownLinkObj($logtitle, $logname ) . ')';
856 } else if( !$this->userCan($rcObj,Revision
::DELETED_TEXT
) ) {
857 $r .= '<span class="history-deleted">' . $rcObj->link
. '</span>';
859 $r .= $this->maybeWatchedLink( $rcObj->link
, $rcObj->watched
);
862 # Diff and hist links
863 if ( $rc_type != RC_LOG
) {
864 $r .= ' ('. $rcObj->difflink
. $this->message
['semicolon-separator'];
865 $r .= $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')';
870 if( $wgRCShowChangedSize ) {
871 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : ' ' . $rcObj->getCharacterDifference() . ' . . ' ) ;
875 $r .= ' '.$rcObj->userlink
. $rcObj->usertalklink
;
877 # Log action (if any)
879 if( $this->isDeleted($rcObj,LogPage
::DELETED_ACTION
) ) {
880 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
882 $r .= ' ' . LogPage
::actionText( $rc_log_type, $rc_log_action, $rcObj->getTitle(),
883 $this->skin
, LogPage
::extractParams($rc_params), true, true );
887 # Edit or log comment
888 if( $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
890 if ( $this->isDeleted($rcObj,LogPage
::DELETED_COMMENT
) ) {
891 $r .= ' <span class="history-deleted">' . wfMsg('rev-deleted-comment') . '</span>';
893 $r .= $this->skin
->commentBlock( $rc_comment, $rcObj->getTitle() );
897 # Show how many people are watching this if enabled
898 $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers
);
900 $r .= "</td></tr></table>\n";
905 * If enhanced RC is in use, this function takes the previously cached
906 * RC lines, arranges them, and outputs the HTML
908 protected function recentChangesBlock() {
909 if( count ( $this->rc_cache
) == 0 ) {
913 foreach( $this->rc_cache
as $block ) {
914 if( count( $block ) < 2 ) {
915 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
917 $blockOut .= $this->recentChangesBlockGroup( $block );
921 return '<div>'.$blockOut.'</div>';
925 * Returns text for the end of RC
926 * If enhanced RC is in use, returns pretty much all the text
928 public function endRecentChangesList() {
929 return $this->recentChangesBlock() . parent
::endRecentChangesList();