8b8fd50f0c3e65526c729adb369cec0ddd4d9dc8
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
81 protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = ' ', $bot = false, $newbie = false ) {
82 $f = $new ?
'<span class="newpage">' . $this->message
['newpageletter'] . '</span>'
84 $f .= $minor ?
'<span class="minor">' . $this->message
['minoreditletter'] . '</span>'
86 $f .= $bot ?
'<span class="bot">' . $this->message
['boteditletter'] . '</span>' : $nothing;
87 $f .= $patrolled ?
'<span class="unpatrolled">!</span>' : $nothing;
88 $f .= $newbie ?
'<span class="newuser">*</span>' : $nothing;
92 protected static function userIsNew( $attribs ) {
93 global $wgAutoConfirmCount, $wgAutoConfirmAge;
94 if( !array_key_exists('user_editcount',$attribs) ||
!array_key_exists('user_registration',$attribs) ) {
95 return false; // missing input!
99 $edits = $attribs['user_editcount'];
100 $age = $attribs['user_registration'];
101 if( $wgAutoConfirmCount && !$edits ||
$wgAutoConfirmAge && !$age ) {
103 } else if( $wgAutoConfirmCount && $edits < $wgAutoConfirmCount ) {
105 } else if( $wgAutoConfirmAge && ($time - wfTimestampOrNull(TS_UNIX
,$age)) < $wgAutoConfirmAge ) {
112 * Returns text for the start of the tabular part of RC
115 public function beginRecentChangesList() {
116 $this->rc_cache
= array();
117 $this->rcMoveIndex
= 0;
118 $this->rcCacheIndex
= 0;
119 $this->lastdate
= '';
120 $this->rclistOpen
= false;
125 * Returns text for the end of RC
128 public function endRecentChangesList() {
129 if( $this->rclistOpen
) {
136 protected function insertMove( &$s, $rc ) {
138 $s .= '(' . $this->message
['diff'] . ') (';
140 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $this->message
['hist'], 'action=history' ) .
143 # "[[x]] moved to [[y]]"
144 $msg = ( $rc->mAttribs
['rc_type'] == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
145 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
146 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
149 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'] )
179 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['diff'],
181 'curid' => $rc->mAttribs
['rc_cur_id'],
182 'diff' => $rc->mAttribs
['rc_this_oldid'],
183 'oldid' => $rc->mAttribs
['rc_last_oldid'] ),
185 '', '', ' tabindex="'.$rc->counter
.'"');
187 $s .= '('.$diffLink.') (';
190 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['hist'],
192 'curid' => $rc->mAttribs
['rc_cur_id'],
193 'action' => 'history' ) ) );
197 protected function insertArticleLink(&$s, &$rc, $unpatrolled, $watched) {
199 # If it's a new article, there is no diff link, but if it hasn't been
200 # patrolled yet, we need to give users a way to do so
201 $params = ( $unpatrolled && $rc->mAttribs
['rc_type'] == RC_NEW
)
202 ?
'rcid='.$rc->mAttribs
['rc_id']
204 if( $this->isDeleted($rc,Revision
::DELETED_TEXT
) ) {
205 $articlelink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', $params );
206 $articlelink = '<span class="history-deleted">'.$articlelink.'</span>';
208 $articlelink = ' '. $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', $params );
211 $articlelink = "<strong class=\"mw-watched\">{$articlelink}</strong>";
213 $articlelink .= $wgContLang->getDirMark();
215 wfRunHooks('ChangesListInsertArticleLink',
216 array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched));
218 $s .= ' '.$articlelink;
221 protected function insertTimestamp(&$s, $rc) {
224 $s .= $this->message
['semicolon-separator'] . $wgLang->time( $rc->mAttribs
['rc_timestamp'], true, true ) . ' . . ';
227 /** Insert links to user page, user talk page and eventually a blocking link */
228 public function insertUserRelatedLinks(&$s, &$rc) {
229 if ( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
230 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
232 $s .= $this->skin
->userLink( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
233 $s .= $this->skin
->userToolLinks( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
237 /** insert a formatted action */
238 protected function insertAction(&$s, &$rc) {
240 if( $rc->mAttribs
['rc_type'] == RC_LOG
) {
242 if ( $this->isDeleted($rc,LogPage
::DELETED_ACTION
) ) {
243 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
245 $s .= ' ' . LogPage
::actionText( $rc->mAttribs
['rc_log_type'], $rc->mAttribs
['rc_log_action'],
246 $rc->getTitle(), $this->skin
, LogPage
::extractParams($rc->mAttribs
['rc_params']), true, true );
251 /** insert a formatted comment */
252 protected function insertComment(&$s, &$rc) {
254 if( $rc->mAttribs
['rc_type'] != RC_MOVE
&& $rc->mAttribs
['rc_type'] != RC_MOVE_OVER_REDIRECT
) {
256 if ( $this->isDeleted($rc,Revision
::DELETED_COMMENT
) ) {
257 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
259 $s .= $this->skin
->commentBlock( $rc->mAttribs
['rc_comment'], $rc->getTitle() );
265 * Check whether to enable recent changes patrol features
268 public static function usePatrol() {
270 return $wgUser->useRCPatrol();
274 * Returns the string which indicates the number of watching users
276 protected function numberofWatchingusers( $count ) {
278 static $cache = array();
280 if ( !isset( $cache[$count] ) ) {
281 $cache[$count] = wfMsgExt('number_of_watching_users_RCview',
282 array('parsemag', 'escape'), $wgLang->formatNum($count));
284 return $cache[$count];
291 * Determine if said field of a revision is hidden
292 * @param RCCacheEntry $rc
293 * @param int $field one of DELETED_* bitfield constants
296 public static function isDeleted( $rc, $field ) {
297 return ($rc->mAttribs
['rc_deleted'] & $field) == $field;
301 * Determine if the current user is allowed to view a particular
302 * field of this revision, if it's marked as deleted.
303 * @param RCCacheEntry $rc
307 public static function userCan( $rc, $field ) {
308 if( ( $rc->mAttribs
['rc_deleted'] & $field ) == $field ) {
310 $permission = ( $rc->mAttribs
['rc_deleted'] & Revision
::DELETED_RESTRICTED
) == Revision
::DELETED_RESTRICTED
313 wfDebug( "Checking for $permission due to $field match on $rc->mAttribs['rc_deleted']\n" );
314 return $wgUser->isAllowed( $permission );
323 * Generate a list of changes using the good old system (no javascript)
325 class OldChangesList
extends ChangesList
{
327 * Format a line using the old system (aka without any javascript).
329 public function recentChangesLine( &$rc, $watched = false ) {
330 global $wgContLang, $wgRCShowChangedSize, $wgUser;
332 $fname = 'ChangesList::recentChangesLineOld';
333 wfProfileIn( $fname );
335 # Extract DB fields into local scope
336 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
337 extract( $rc->mAttribs
);
339 # Should patrol-related stuff be shown?
340 $unpatrolled = $wgUser->useRCPatrol() && $rc_patrolled == 0;
342 $dateheader = ""; // $s now contains only <li>...</li>, for hooks' convenience.
343 $this->insertDateHeader($dateheader,$rc_timestamp);
348 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
349 $this->insertMove( $s, $rc );
351 } elseif( $rc_log_type ) {
352 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
353 $this->insertLog( $s, $logtitle, $rc_log_type );
354 // Log entries (old format) or log targets, and special pages
355 } elseif( $rc_namespace == NS_SPECIAL
) {
356 list( $specialName, $specialSubpage ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
357 if ( $specialName == 'Log' ) {
358 $this->insertLog( $s, $rc->getTitle(), $specialSubpage );
360 wfDebug( "Unexpected special page in recentchanges\n" );
364 wfProfileIn($fname.'-page');
366 $this->insertDiffHist($s, $rc, $unpatrolled);
367 # M, N, b and ! (minor, new, bot and unpatrolled)
368 $newbie = self
::userIsNew( $rc->mAttribs
);
369 $s .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $unpatrolled, '',
371 $this->insertArticleLink($s, $rc, $unpatrolled, $watched);
373 wfProfileOut($fname.'-page');
376 wfProfileIn( $fname.'-rest' );
378 $this->insertTimestamp($s,$rc);
380 if( $wgRCShowChangedSize ) {
381 $s .= ( $rc->getCharacterDifference() == '' ?
'' : $rc->getCharacterDifference() . ' . . ' );
384 $this->insertUserRelatedLinks($s,$rc);
385 # Log action text (if any)
386 $this->insertAction($s, $rc);
387 # Edit or log comment
388 $this->insertComment($s, $rc);
390 # Mark revision as deleted if so
391 if ( !$rc_log_type && $this->isDeleted($rc,Revision
::DELETED_TEXT
) )
392 $s .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
393 if($rc->numberofWatchingusers
> 0) {
394 $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers
));
399 wfRunHooks('OldChangesListRecentChangesLine', array(&$this, &$s, &$rc));
401 wfProfileOut( $fname.'-rest' );
403 wfProfileOut( $fname );
404 return $dateheader . $s;
410 * Generate a list of changes using an Enhanced system (use javascript).
412 class EnhancedChangesList
extends ChangesList
{
414 * Format a line for enhanced recentchange (aka with javascript and block of lines).
416 public function recentChangesLine( &$baseRC, $watched = false ) {
417 global $wgLang, $wgContLang, $wgUser;
419 # Create a specialised object
420 $rc = RCCacheEntry
::newFromParent( $baseRC );
422 # Extract fields from DB into the function scope (rc_xxxx variables)
423 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
424 extract( $rc->mAttribs
);
425 $curIdEq = 'curid=' . $rc_cur_id;
427 # If it's a new day, add the headline and flush the cache
428 $date = $wgLang->date( $rc_timestamp, true);
430 if( $date != $this->lastdate
) {
431 # Process current cache
432 $ret = $this->recentChangesBlock();
433 $this->rc_cache
= array();
434 $ret .= "<h4>{$date}</h4>\n";
435 $this->lastdate
= $date;
438 # Should patrol-related stuff be shown?
439 if( $wgUser->useRCPatrol() ) {
440 $rc->unpatrolled
= !$rc_patrolled;
442 $rc->unpatrolled
= false;
445 $showdifflinks = true;
448 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
449 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
450 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
451 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
452 // Log entries (old format) and special pages
453 } elseif( $rc_namespace == NS_SPECIAL
) {
454 list( $specialName, $logtype ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
455 if ( $specialName == 'Log' ) {
457 $logname = LogPage
::logName( $logtype );
458 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
460 wfDebug( "Unexpected special page in recentchanges\n" );
463 // New unpatrolled pages
464 } else if( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
465 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
467 } else if( $rc_type == RC_LOG
) {
469 $logtitle = SpecialPage
::getTitleFor( 'Log', $rc_log_type );
470 $clink = '(' . $this->skin
->makeKnownLinkObj( $logtitle, LogPage
::logName($rc_log_type) ) . ')';
472 $clink = $this->skin
->makeLinkObj( $rc->getTitle(), '' );
477 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
480 # Don't show unusable diff links
481 if ( !ChangesList
::userCan($rc,Revision
::DELETED_TEXT
) ) {
482 $showdifflinks = false;
485 $time = $wgContLang->time( $rc_timestamp, true, true );
486 $rc->watched
= $watched;
488 $rc->timestamp
= $time;
489 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
491 # Make "cur" and "diff" links
492 if( $rc->unpatrolled
) {
493 $rcIdQuery = "&rcid={$rc_id}";
497 $querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid";
498 $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery";
499 $aprops = ' tabindex="'.$baseRC->counter
.'"';
500 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['cur'], $querycur, '' ,'', $aprops );
502 # Make "diff" an "cur" links
503 if( !$showdifflinks ) {
504 $curLink = $this->message
['cur'];
505 $diffLink = $this->message
['diff'];
506 } else if( $rc_type == RC_NEW ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
507 if( $rc_type != RC_NEW
) {
508 $curLink = $this->message
['cur'];
510 $diffLink = $this->message
['diff'];
512 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['diff'], $querydiff, '' ,'', $aprops );
516 if( !$showdifflinks ) {
517 $lastLink = $this->message
['last'];
518 } else if( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
519 $lastLink = $this->message
['last'];
521 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['last'],
522 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
526 if( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
527 $rc->userlink
= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
529 $rc->userlink
= $this->skin
->userLink( $rc_user, $rc_user_text );
530 $rc->usertalklink
= $this->skin
->userToolLinks( $rc_user, $rc_user_text );
533 $rc->lastlink
= $lastLink;
534 $rc->curlink
= $curLink;
535 $rc->difflink
= $diffLink;
537 # Put accumulated information into the cache, for later display
538 # Page moves go on their own line
539 $title = $rc->getTitle();
540 $secureName = $title->getPrefixedDBkey();
541 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
542 # Use an @ character to prevent collision with page names
543 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
545 # Logs are grouped by type
546 if( $rc_type == RC_LOG
){
547 $secureName = SpecialPage
::getTitleFor( 'Log', $rc_log_type )->getPrefixedDBkey();
549 if( !isset( $this->rc_cache
[$secureName] ) ) {
550 $this->rc_cache
[$secureName] = array();
552 array_push( $this->rc_cache
[$secureName], $rc );
560 protected function recentChangesBlockGroup( $block ) {
561 global $wgLang, $wgContLang, $wgRCShowChangedSize;
562 $r = '<table cellpadding="0" cellspacing="0" border="0" style="background: none"><tr>';
564 # Collate list of users
565 $userlinks = array();
567 $unpatrolled = $isnew = $newbie = false;
568 $curId = $currentRevision = 0;
569 # Some catalyst variables...
572 foreach( $block as $rcObj ) {
573 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
574 if( $rcObj->mAttribs
['rc_type'] == RC_NEW
) {
577 // If all log actions to this page were hidden, then don't
578 // give the name of the affected page for this block!
579 if( !$this->isDeleted( $rcObj, LogPage
::DELETED_ACTION
) ) {
582 $u = $rcObj->userlink
;
583 if( !isset( $userlinks[$u] ) ) {
586 if( $rcObj->unpatrolled
) {
589 if( $rcObj->mAttribs
['rc_type'] != RC_LOG
) {
592 if( self
::userIsNew( $rcObj->mAttribs
) ) {
595 # Get the latest entry with a page_id and oldid
596 # since logs may not have these.
597 if( !$curId && $rcObj->mAttribs
['rc_cur_id'] ) {
598 $curId = $rcObj->mAttribs
['rc_cur_id'];
600 if( !$currentRevision && $rcObj->mAttribs
['rc_this_oldid'] ) {
601 $currentRevision = $rcObj->mAttribs
['rc_this_oldid'];
604 $bot = $rcObj->mAttribs
['rc_bot'];
608 # Sort the list and convert to text
609 krsort( $userlinks );
612 foreach( $userlinks as $userlink => $count) {
614 $text .= $wgContLang->getDirMark();
616 $text .= ' (' . $wgLang->formatNum( $count ) . '×)';
618 array_push( $users, $text );
621 $users = ' <span class="changedby">[' . implode( $this->message
['semicolon-separator'], $users ) . ']</span>';
624 $rci = 'RCI'.$this->rcCacheIndex
;
625 $rcl = 'RCL'.$this->rcCacheIndex
;
626 $rcm = 'RCM'.$this->rcCacheIndex
;
627 $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')";
628 $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'">' . $this->sideArrow() . '</a></span>';
629 $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'">' . $this->downArrow() . '</a></span>';
630 $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.' ';
633 $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot, $newbie );
636 $r .= ' '.$block[0]->timestamp
.' </tt></td><td>';
640 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
642 $r .= $this->maybeWatchedLink( $block[0]->link
, $block[0]->watched
);
645 $r .= $wgContLang->getDirMark();
647 $curIdEq = 'curid=' . $curId;
650 static $nchanges = array();
651 if ( !isset( $nchanges[$n] ) ) {
652 $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) );
658 if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
660 } else if( $isnew ) {
663 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
664 $nchanges[$n], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
669 # Character difference (does not apply if only log items)
670 if( $wgRCShowChangedSize && !$alllogs ) {
672 $first = count($block) - 1;
673 # Some events (like logs) have an "empty" size, so we need to skip those...
674 while( $last < $first && $block[$last]->mAttribs
['rc_new_len'] === NULL ) {
677 while( $first > $last && $block[$first]->mAttribs
['rc_old_len'] === NULL ) {
681 $chardiff = $rcObj->getCharacterDifference( $block[$first]->mAttribs
['rc_old_len'],
682 $block[$last]->mAttribs
['rc_new_len'] );
684 if( $chardiff == '' ) {
687 $r .= ' ' . $chardiff. ' . . ';
693 // don't show history link for logs
694 } else if( $namehidden ||
!$block[0]->getTitle()->exists() ) {
695 $r .= '(' . $this->message
['history'] . ')';
697 $r .= '(' . $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
698 $this->message
['history'], $curIdEq.'&action=history' ) . ')';
702 $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers
);
704 $r .= "</td></tr></table>\n";
707 $r .= '<div id="'.$rci.'" style="display:none;"><table cellpadding="0" cellspacing="0" border="0" style="background: none">';
708 foreach( $block as $rcObj ) {
709 # Get rc_xxxx variables
710 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
711 extract( $rcObj->mAttribs
);
713 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
714 $r .= '<tr><td valign="top">';
715 $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
716 $newbie = self
::userIsNew( $rcObj->mAttribs
);
717 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot, $newbie );
718 $r .= ' </tt></td><td valign="top">';
721 if( $rc_this_oldid != 0 ) {
722 $o = 'oldid='.$rc_this_oldid;
725 if( $rc_type == RC_LOG
) {
726 $link = '<tt>'.$rcObj->timestamp
.'</tt> ';
728 } else if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
729 $link = '<span class="history-deleted"><tt>'.$rcObj->timestamp
.'</tt></span> ';
731 $rcIdEq = ($rcObj->unpatrolled
&& $rc_type == RC_NEW
) ?
'&rcid='.$rcObj->mAttribs
['rc_id'] : '';
733 $link = '<tt>'.$this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, $curIdEq.'&'.$o.$rcIdEq ).'</tt>';
734 if( $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) )
735 $link = '<span class="history-deleted">'.$link.'</span> ';
739 if ( !$rc_type == RC_LOG ||
$rc_type == RC_NEW
) {
741 $r .= $rcObj->curlink
;
742 $r .= $this->message
['semicolon-separator'];
743 $r .= $rcObj->lastlink
;
749 if( $wgRCShowChangedSize ) {
750 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : $rcObj->getCharacterDifference() . ' . . ' ) ;
753 $r .= $rcObj->userlink
;
754 $r .= $rcObj->usertalklink
;
756 parent
::insertAction( $r, $rcObj );
758 parent
::insertComment( $r, $rcObj );
759 # Mark revision as deleted
760 if( !$rc_log_type && $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) ) {
761 $r .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
764 $r .= "</td></tr>\n";
766 $r .= "</table></div>\n";
768 $this->rcCacheIndex++
;
772 protected function maybeWatchedLink( $link, $watched=false ) {
774 // FIXME: css style might be more appropriate
775 return '<strong class="mw-watched">' . $link . '</strong>';
782 * Generate HTML for an arrow or placeholder graphic
783 * @param string $dir one of '', 'd', 'l', 'r'
784 * @param string $alt text
785 * @return string HTML <img> tag
787 protected function arrow( $dir, $alt='' ) {
789 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
790 $encAlt = htmlspecialchars( $alt );
791 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" />";
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, '+' );
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', '-' );
815 * Generate HTML for a spacer image
816 * @return string HTML <img> tag
818 protected function spacerArrow() {
819 return $this->arrow( '', ' ' );
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>';
843 $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . ' ';
846 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
847 $r .= ' '; // 4 flags -> 4 spaces
849 $newbie = self
::userIsNew( $rcObj->mAttribs
);
850 $r .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $rcObj->unpatrolled
,
851 ' ', $rc_bot, $newbie );
853 $r .= ' '.$rcObj->timestamp
.' </tt></td><td>';
855 # Article or log link
857 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
858 $logname = LogPage
::logName( $rc_log_type );
859 $r .= '(' . $this->skin
->makeKnownLinkObj($logtitle, $logname ) . ')';
860 } else if( !$this->userCan($rcObj,Revision
::DELETED_TEXT
) ) {
861 $r .= '<span class="history-deleted">' . $rcObj->link
. '</span>';
863 $r .= $this->maybeWatchedLink( $rcObj->link
, $rcObj->watched
);
866 # Diff and hist links
867 if( $rc_type != RC_LOG
) {
868 $r .= ' ('. $rcObj->difflink
. $this->message
['semicolon-separator'];
869 $r .= $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')';
874 if( $wgRCShowChangedSize ) {
875 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : ' ' . $rcObj->getCharacterDifference() . ' . . ' ) ;
879 $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 );
891 # Edit or log comment
892 if( $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
894 if ( $this->isDeleted($rcObj,LogPage
::DELETED_COMMENT
) ) {
895 $r .= ' <span class="history-deleted">' . wfMsg('rev-deleted-comment') . '</span>';
897 $r .= $this->skin
->commentBlock( $rc_comment, $rcObj->getTitle() );
901 # Show how many people are watching this if enabled
902 $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers
);
904 $r .= "</td></tr></table>\n";
909 * If enhanced RC is in use, this function takes the previously cached
910 * RC lines, arranges them, and outputs the HTML
912 protected function recentChangesBlock() {
913 if( count ( $this->rc_cache
) == 0 ) {
917 foreach( $this->rc_cache
as $block ) {
918 if( count( $block ) < 2 ) {
919 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
921 $blockOut .= $this->recentChangesBlockGroup( $block );
925 return '<div>'.$blockOut.'</div>';
929 * Returns text for the end of RC
930 * If enhanced RC is in use, returns pretty much all the text
932 public function endRecentChangesList() {
933 return $this->recentChangesBlock() . parent
::endRecentChangesList();