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, $wgMiserMode;
110 $szdiff = $new - $old;
112 $formatedSize = ( $wgMiserMode?
113 $wgLang->formatNum($szdiff) : // avoid expensive calculations
114 wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape' ), $wgLang->formatNum( $szdiff ) )
117 if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
122 if( $szdiff === 0 ) {
123 return "<$tag class='mw-plusminus-null'>($formatedSize)</$tag>";
124 } elseif( $szdiff > 0 ) {
125 return "<$tag class='mw-plusminus-pos'>(+$formatedSize)</$tag>";
127 return "<$tag class='mw-plusminus-neg'>($formatedSize)</$tag>";
132 * Returns text for the end of RC
135 public function endRecentChangesList() {
136 if( $this->rclistOpen
) {
143 protected function insertMove( &$s, $rc ) {
145 $s .= '(' . $this->message
['diff'] . ') (';
147 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $this->message
['hist'],
148 'action=history' ) . ') . . ';
149 # "[[x]] moved to [[y]]"
150 $msg = ( $rc->mAttribs
['rc_type'] == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
151 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
152 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
155 protected function insertDateHeader( &$s, $rc_timestamp ) {
157 # Make date header if necessary
158 $date = $wgLang->date( $rc_timestamp, true, true );
159 if( $date != $this->lastdate
) {
160 if( '' != $this->lastdate
) {
163 $s .= '<h4>'.$date."</h4>\n<ul class=\"special\">";
164 $this->lastdate
= $date;
165 $this->rclistOpen
= true;
169 protected function insertLog( &$s, $title, $logtype ) {
170 $logname = LogPage
::logName( $logtype );
171 $s .= '(' . $this->skin
->makeKnownLinkObj($title, $logname ) . ')';
174 protected function insertDiffHist( &$s, &$rc, $unpatrolled ) {
176 if( $rc->mAttribs
['rc_type'] == RC_NEW ||
$rc->mAttribs
['rc_type'] == RC_LOG
) {
177 $diffLink = $this->message
['diff'];
178 } else if( !$this->userCan($rc,Revision
::DELETED_TEXT
) ) {
179 $diffLink = $this->message
['diff'];
181 $rcidparam = $unpatrolled ?
array( 'rcid' => $rc->mAttribs
['rc_id'] ) : array();
182 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['diff'],
184 'curid' => $rc->mAttribs
['rc_cur_id'],
185 'diff' => $rc->mAttribs
['rc_this_oldid'],
186 'oldid' => $rc->mAttribs
['rc_last_oldid'] ),
188 '', '', ' tabindex="'.$rc->counter
.'"');
190 $s .= '('.$diffLink.') (';
192 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['hist'],
194 'curid' => $rc->mAttribs
['rc_cur_id'],
195 'action' => 'history' ) ) );
199 protected function insertArticleLink( &$s, &$rc, $unpatrolled, $watched ) {
201 # If it's a new article, there is no diff link, but if it hasn't been
202 # patrolled yet, we need to give users a way to do so
203 $params = ( $unpatrolled && $rc->mAttribs
['rc_type'] == RC_NEW
) ?
204 'rcid='.$rc->mAttribs
['rc_id'] : '';
205 if( $this->isDeleted($rc,Revision
::DELETED_TEXT
) ) {
206 $articlelink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', $params );
207 $articlelink = '<span class="history-deleted">'.$articlelink.'</span>';
209 $articlelink = ' '. $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', $params );
211 # Bolden pages watched by this user
213 $articlelink = "<strong class=\"mw-watched\">{$articlelink}</strong>";
216 $articlelink .= $wgContLang->getDirMark();
218 wfRunHooks( 'ChangesListInsertArticleLink',
219 array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched) );
221 $s .= " $articlelink";
224 protected function insertTimestamp( &$s, $rc ) {
226 $s .= $this->message
['semicolon-separator'] .
227 $wgLang->time( $rc->mAttribs
['rc_timestamp'], true, true ) . ' . . ';
230 /** Insert links to user page, user talk page and eventually a blocking link */
231 public function insertUserRelatedLinks( &$s, &$rc ) {
232 if( $this->isDeleted( $rc, Revision
::DELETED_USER
) ) {
233 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
235 $s .= $this->skin
->userLink( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
236 $s .= $this->skin
->userToolLinks( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
240 /** insert a formatted action */
241 protected function insertAction( &$s, &$rc ) {
242 if( $rc->mAttribs
['rc_type'] == RC_LOG
) {
243 if( $this->isDeleted( $rc, LogPage
::DELETED_ACTION
) ) {
244 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
246 $s .= ' '.LogPage
::actionText( $rc->mAttribs
['rc_log_type'], $rc->mAttribs
['rc_log_action'],
247 $rc->getTitle(), $this->skin
, LogPage
::extractParams( $rc->mAttribs
['rc_params'] ), true, true );
252 /** insert a formatted comment */
253 protected function insertComment( &$s, &$rc ) {
254 if( $rc->mAttribs
['rc_type'] != RC_MOVE
&& $rc->mAttribs
['rc_type'] != RC_MOVE_OVER_REDIRECT
) {
255 if( $this->isDeleted( $rc, Revision
::DELETED_COMMENT
) ) {
256 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span>';
258 $s .= $this->skin
->commentBlock( $rc->mAttribs
['rc_comment'], $rc->getTitle() );
264 * Check whether to enable recent changes patrol features
267 public static function usePatrol() {
269 return $wgUser->useRCPatrol();
273 * Returns the string which indicates the number of watching users
275 protected function numberofWatchingusers( $count ) {
277 static $cache = array();
279 if( !isset( $cache[$count] ) ) {
280 $cache[$count] = wfMsgExt( 'number_of_watching_users_RCview',
281 array('parsemag', 'escape' ), $wgLang->formatNum( $count ) );
283 return $cache[$count];
290 * Determine if said field of a revision is hidden
291 * @param RCCacheEntry $rc
292 * @param int $field one of DELETED_* bitfield constants
295 public static function isDeleted( $rc, $field ) {
296 return ( $rc->mAttribs
['rc_deleted'] & $field ) == $field;
300 * Determine if the current user is allowed to view a particular
301 * field of this revision, if it's marked as deleted.
302 * @param RCCacheEntry $rc
306 public static function userCan( $rc, $field ) {
307 if( ( $rc->mAttribs
['rc_deleted'] & $field ) == $field ) {
309 $permission = ( $rc->mAttribs
['rc_deleted'] & Revision
::DELETED_RESTRICTED
) == Revision
::DELETED_RESTRICTED
312 wfDebug( "Checking for $permission due to $field match on {$rc->mAttribs['rc_deleted']}\n" );
313 return $wgUser->isAllowed( $permission );
319 protected function maybeWatchedLink( $link, $watched=false ) {
321 return '<strong class="mw-watched">' . $link . '</strong>';
323 return '<span class="mw-rc-unwatched">' . $link . '</span>';
327 /** Inserts a rollback link */
328 protected function insertRollback( &$s, &$rc ) {
330 if( !$rc->mAttribs
['rc_new'] && $rc->mAttribs
['rc_this_oldid'] && $rc->mAttribs
['rc_cur_id'] ) {
331 $page = $rc->getTitle();
332 /** Check for rollback and edit permissions, disallow special pages, and only
333 * show a link on the top-most revision */
334 if ($wgUser->isAllowed('rollback') && $rc->mAttribs
['page_latest'] == $rc->mAttribs
['rc_this_oldid'] )
336 $rev = new Revision( array(
337 'id' => $rc->mAttribs
['rc_this_oldid'],
338 'user' => $rc->mAttribs
['rc_user'],
339 'user_text' => $rc->mAttribs
['rc_user_text'],
340 'deleted' => $rc->mAttribs
['rc_deleted']
342 $rev->setTitle( $page );
343 $s .= ' '.$this->skin
->generateRollback( $rev );
348 protected function insertTags( &$s, &$rc, &$classes ) {
349 if ( empty($rc->mAttribs
['ts_tags']) )
352 list($tagSummary, $newClasses) = ChangeTags
::formatSummaryRow( $rc->mAttribs
['ts_tags'], 'changeslist' );
353 $classes = array_merge( $classes, $newClasses );
354 $s .= ' ' . $tagSummary;
357 protected function insertExtra( &$s, &$rc, &$classes ) {
358 ## Empty, used for subclassers to add anything special.
364 * Generate a list of changes using the good old system (no javascript)
366 class OldChangesList
extends ChangesList
{
368 * Format a line using the old system (aka without any javascript).
370 public function recentChangesLine( &$rc, $watched = false, $linenumber = NULL ) {
371 global $wgContLang, $wgLang, $wgRCShowChangedSize, $wgUser;
372 wfProfileIn( __METHOD__
);
373 # Should patrol-related stuff be shown?
374 $unpatrolled = $wgUser->useRCPatrol() && !$rc->mAttribs
['rc_patrolled'];
376 $dateheader = ''; // $s now contains only <li>...</li>, for hooks' convenience.
377 $this->insertDateHeader( $dateheader, $rc->mAttribs
['rc_timestamp'] );
381 // use mw-line-even/mw-line-odd class only if linenumber is given (feature from bug 14468)
383 if( $linenumber & 1 ) {
384 $classes[] = 'mw-line-odd';
387 $classes[] = 'mw-line-even';
392 if( $rc->mAttribs
['rc_type'] == RC_MOVE ||
$rc->mAttribs
['rc_type'] == RC_MOVE_OVER_REDIRECT
) {
393 $this->insertMove( $s, $rc );
395 } elseif( $rc->mAttribs
['rc_log_type'] ) {
396 $logtitle = Title
::newFromText( 'Log/'.$rc->mAttribs
['rc_log_type'], NS_SPECIAL
);
397 $this->insertLog( $s, $logtitle, $rc->mAttribs
['rc_log_type'] );
398 // Log entries (old format) or log targets, and special pages
399 } elseif( $rc->mAttribs
['rc_namespace'] == NS_SPECIAL
) {
400 list( $name, $subpage ) = SpecialPage
::resolveAliasWithSubpage( $rc->mAttribs
['rc_title'] );
401 if( $name == 'Log' ) {
402 $this->insertLog( $s, $rc->getTitle(), $subpage );
406 $this->insertDiffHist( $s, $rc, $unpatrolled );
407 # M, N, b and ! (minor, new, bot and unpatrolled)
408 $s .= $this->recentChangesFlags( $rc->mAttribs
['rc_new'], $rc->mAttribs
['rc_minor'],
409 $unpatrolled, '', $rc->mAttribs
['rc_bot'] );
410 $this->insertArticleLink( $s, $rc, $unpatrolled, $watched );
413 $this->insertTimestamp( $s, $rc );
414 # Bytes added or removed
415 if( $wgRCShowChangedSize ) {
416 $cd = $rc->getCharacterDifference();
422 $this->insertUserRelatedLinks( $s, $rc );
423 # Log action text (if any)
424 $this->insertAction( $s, $rc );
425 # Edit or log comment
426 $this->insertComment( $s, $rc );
428 $this->insertTags( $s, $rc, $classes );
430 $this->insertRollback( $s, $rc );
432 $this->insertExtra( $s, $rc, $classes );
434 # Mark revision as deleted if so
435 if( !$rc->mAttribs
['rc_log_type'] && $this->isDeleted($rc,Revision
::DELETED_TEXT
) ) {
436 $s .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
438 # How many users watch this page
439 if( $rc->numberofWatchingusers
> 0 ) {
440 $s .= ' ' . wfMsgExt( 'number_of_watching_users_RCview',
441 array( 'parsemag', 'escape' ), $wgLang->formatNum( $rc->numberofWatchingusers
) );
444 wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) );
446 wfProfileOut( __METHOD__
);
447 return "$dateheader<li class=\"".implode( ' ', $classes )."\">$s</li>\n";
453 * Generate a list of changes using an Enhanced system (uses javascript).
455 class EnhancedChangesList
extends ChangesList
{
457 * Add the JavaScript file for enhanced changeslist
460 public function beginRecentChangesList() {
461 global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
462 $this->rc_cache
= array();
463 $this->rcMoveIndex
= 0;
464 $this->rcCacheIndex
= 0;
465 $this->lastdate
= '';
466 $this->rclistOpen
= false;
467 $script = Xml
::tags( 'script', array(
468 'type' => $wgJsMimeType,
469 'src' => $wgStylePath . "/common/enhancedchanges.js?$wgStyleVersion" ), '' );
473 * Format a line for enhanced recentchange (aka with javascript and block of lines).
475 public function recentChangesLine( &$baseRC, $watched = false ) {
476 global $wgLang, $wgContLang, $wgUser;
478 wfProfileIn( __METHOD__
);
480 # Create a specialised object
481 $rc = RCCacheEntry
::newFromParent( $baseRC );
483 # Extract fields from DB into the function scope (rc_xxxx variables)
484 // FIXME: Would be good to replace this extract() call with something
485 // that explicitly initializes variables.
486 extract( $rc->mAttribs
);
487 $curIdEq = array( 'curid' => $rc_cur_id );
489 # If it's a new day, add the headline and flush the cache
490 $date = $wgLang->date( $rc_timestamp, true );
492 if( $date != $this->lastdate
) {
493 # Process current cache
494 $ret = $this->recentChangesBlock();
495 $this->rc_cache
= array();
496 $ret .= "<h4>{$date}</h4>\n";
497 $this->lastdate
= $date;
500 # Should patrol-related stuff be shown?
501 if( $wgUser->useRCPatrol() ) {
502 $rc->unpatrolled
= !$rc_patrolled;
504 $rc->unpatrolled
= false;
507 $showdifflinks = true;
510 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
511 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
512 $clink = wfMsg( $msg, $this->skin
->linkKnown( $rc->getTitle(), null,
513 array(), array( 'redirect' => 'no' ) ),
514 $this->skin
->linkKnown( $rc->getMovedToTitle() ) );
515 // New unpatrolled pages
516 } else if( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
517 $clink = $this->skin
->linkKnown( $rc->getTitle(), null, array(),
518 array( 'rcid' => $rc_id ) );
520 } else if( $rc_type == RC_LOG
) {
522 $logtitle = SpecialPage
::getTitleFor( 'Log', $rc_log_type );
523 $clink = '(' . $this->skin
->linkKnown( $logtitle,
524 LogPage
::logName($rc_log_type) ) . ')';
526 $clink = $this->skin
->link( $rc->getTitle() );
529 // Log entries (old format) and special pages
530 } elseif( $rc_namespace == NS_SPECIAL
) {
531 list( $specialName, $logtype ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
532 if ( $specialName == 'Log' ) {
534 $logname = LogPage
::logName( $logtype );
535 $clink = '(' . $this->skin
->linkKnown( $rc->getTitle(), $logname ) . ')';
537 wfDebug( "Unexpected special page in recentchanges\n" );
542 $clink = $this->skin
->linkKnown( $rc->getTitle() );
545 # Don't show unusable diff links
546 if ( !ChangesList
::userCan($rc,Revision
::DELETED_TEXT
) ) {
547 $showdifflinks = false;
550 $time = $wgContLang->time( $rc_timestamp, true, true );
551 $rc->watched
= $watched;
553 $rc->timestamp
= $time;
554 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
556 # Make "cur" and "diff" links. Don't use link(), it's too slow if
557 # called too many times (50% of CPU time on RecentChanges!).
558 if( $rc->unpatrolled
) {
559 $rcIdQuery = array( 'rcid' => $rc_id );
561 $rcIdQuery = array();
563 $querycur = $curIdEq +
array( 'diff' => '0', 'oldid' => $rc_this_oldid );
564 $querydiff = $curIdEq +
array( 'diff' => $rc_this_oldid, 'oldid' =>
565 $rc_last_oldid ) +
$rcIdQuery;
566 $attribs = array( 'tabindex' => $baseRC->counter
);
568 if( !$showdifflinks ) {
569 $curLink = $this->message
['cur'];
570 $diffLink = $this->message
['diff'];
571 } else if( in_array( $rc_type, array(RC_NEW
,RC_LOG
,RC_MOVE
,RC_MOVE_OVER_REDIRECT
) ) ) {
572 if ( $rc_type != RC_NEW
) {
573 $curLink = $this->message
['cur'];
575 $curUrl = wfUrlencode( $rc->getTitle()->getLinkUrl( $querycur ) );
576 $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
578 $diffLink = $this->message
['diff'];
580 $diffUrl = wfUrlencode( $rc->getTitle()->getLinkUrl( $querydiff ) );
581 $curUrl = wfUrlencode( $rc->getTitle()->getLinkUrl( $querycur ) );
582 $diffLink = "<a href=\"$diffUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['diff']}</a>";
583 $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
587 if( !$showdifflinks ||
!$rc_last_oldid ) {
588 $lastLink = $this->message
['last'];
589 } else if( $rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
590 $lastLink = $this->message
['last'];
592 $lastLink = $this->skin
->linkKnown( $rc->getTitle(), $this->message
['last'],
593 array(), $curIdEq +
array('diff' => $rc_this_oldid, 'oldid' => $rc_last_oldid) +
$rcIdQuery );
597 if( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
598 $rc->userlink
= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
600 $rc->userlink
= $this->skin
->userLink( $rc_user, $rc_user_text );
601 $rc->usertalklink
= $this->skin
->userToolLinks( $rc_user, $rc_user_text );
604 $rc->lastlink
= $lastLink;
605 $rc->curlink
= $curLink;
606 $rc->difflink
= $diffLink;
608 # Put accumulated information into the cache, for later display
609 # Page moves go on their own line
610 $title = $rc->getTitle();
611 $secureName = $title->getPrefixedDBkey();
612 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
613 # Use an @ character to prevent collision with page names
614 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
616 # Logs are grouped by type
617 if( $rc_type == RC_LOG
){
618 $secureName = SpecialPage
::getTitleFor( 'Log', $rc_log_type )->getPrefixedDBkey();
620 if( !isset( $this->rc_cache
[$secureName] ) ) {
621 $this->rc_cache
[$secureName] = array();
624 array_push( $this->rc_cache
[$secureName], $rc );
627 wfProfileOut( __METHOD__
);
635 protected function recentChangesBlockGroup( $block ) {
636 global $wgLang, $wgContLang, $wgRCShowChangedSize;
638 wfProfileIn( __METHOD__
);
640 $r = '<table cellpadding="0" cellspacing="0" border="0" style="background: none"><tr>';
642 # Collate list of users
643 $userlinks = array();
645 $unpatrolled = false;
647 $curId = $currentRevision = 0;
648 # Some catalyst variables...
651 foreach( $block as $rcObj ) {
652 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
653 if( $rcObj->mAttribs
['rc_new'] ) {
656 // If all log actions to this page were hidden, then don't
657 // give the name of the affected page for this block!
658 if( !$this->isDeleted( $rcObj, LogPage
::DELETED_ACTION
) ) {
661 $u = $rcObj->userlink
;
662 if( !isset( $userlinks[$u] ) ) {
665 if( $rcObj->unpatrolled
) {
668 if( $rcObj->mAttribs
['rc_type'] != RC_LOG
) {
671 # Get the latest entry with a page_id and oldid
672 # since logs may not have these.
673 if( !$curId && $rcObj->mAttribs
['rc_cur_id'] ) {
674 $curId = $rcObj->mAttribs
['rc_cur_id'];
676 if( !$currentRevision && $rcObj->mAttribs
['rc_this_oldid'] ) {
677 $currentRevision = $rcObj->mAttribs
['rc_this_oldid'];
680 $bot = $rcObj->mAttribs
['rc_bot'];
684 # Sort the list and convert to text
685 krsort( $userlinks );
688 foreach( $userlinks as $userlink => $count) {
690 $text .= $wgContLang->getDirMark();
692 $text .= ' (' . $wgLang->formatNum( $count ) . '×)';
694 array_push( $users, $text );
697 $users = ' <span class="changedby">[' .
698 implode( $this->message
['semicolon-separator'], $users ) . ']</span>';
700 # ID for JS visibility toggle
701 $jsid = $this->rcCacheIndex
;
702 # onclick handler to toggle hidden/expanded
703 $toggleLink = "onclick='toggleVisibility($jsid); return false'";
705 $expandTitle = htmlspecialchars( wfMsg( 'rc-enhanced-expand' ) );
706 $closeTitle = htmlspecialchars( wfMsg( 'rc-enhanced-hide' ) );
708 $tl = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
709 $tl .= "<span id='mw-rc-closearrow-$jsid' class='mw-changeslist-hidden' style='display:none'><a href='#' $toggleLink title='$closeTitle'>" . $this->downArrow() . "</a></span>";
710 $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.' ';
713 $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot );
716 $r .= ' '.$block[0]->timestamp
.' </tt></td><td>';
720 $r .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
721 } else if( $allLogs ) {
722 $r .= $this->maybeWatchedLink( $block[0]->link
, $block[0]->watched
);
724 $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled
, $block[0]->watched
);
727 $r .= $wgContLang->getDirMark();
729 $curIdEq = 'curid=' . $curId;
732 static $nchanges = array();
733 if ( !isset( $nchanges[$n] ) ) {
734 $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) );
740 if( !ChangesList
::userCan( $rcObj, Revision
::DELETED_TEXT
) ) {
742 } else if( $isnew ) {
745 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
746 $nchanges[$n], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
752 // don't show history link for logs
753 } else if( $namehidden ||
!$block[0]->getTitle()->exists() ) {
754 $r .= $this->message
['semicolon-separator'] . $this->message
['hist'] . ')';
756 $r .= $this->message
['semicolon-separator'] . $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
757 $this->message
['hist'], $curIdEq . '&action=history' ) . ')';
761 # Character difference (does not apply if only log items)
762 if( $wgRCShowChangedSize && !$allLogs ) {
764 $first = count($block) - 1;
765 # Some events (like logs) have an "empty" size, so we need to skip those...
766 while( $last < $first && $block[$last]->mAttribs
['rc_new_len'] === NULL ) {
769 while( $first > $last && $block[$first]->mAttribs
['rc_old_len'] === NULL ) {
773 $chardiff = $rcObj->getCharacterDifference( $block[$first]->mAttribs
['rc_old_len'],
774 $block[$last]->mAttribs
['rc_new_len'] );
776 if( $chardiff == '' ) {
779 $r .= ' ' . $chardiff. ' . . ';
784 $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers
);
786 $r .= "</td></tr></table>\n";
789 $r .= '<div id="mw-rc-subentries-'.$jsid.'" class="mw-changeslist-hidden">';
790 $r .= '<table cellpadding="0" cellspacing="0" border="0" style="background: none">';
791 foreach( $block as $rcObj ) {
792 # Extract fields from DB into the function scope (rc_xxxx variables)
793 // FIXME: Would be good to replace this extract() call with something
794 // that explicitly initializes variables.
795 # Classes to apply -- TODO implement
797 extract( $rcObj->mAttribs
);
799 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
800 $r .= '<tr><td valign="top">';
801 $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
802 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
803 $r .= ' </tt></td><td valign="top">';
806 if( $rc_this_oldid != 0 ) {
807 $o = 'oldid='.$rc_this_oldid;
810 if( $rc_type == RC_LOG
) {
811 $link = '<tt>'.$rcObj->timestamp
.'</tt> ';
813 } else if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
814 $link = '<span class="history-deleted"><tt>'.$rcObj->timestamp
.'</tt></span> ';
816 $rcIdEq = ($rcObj->unpatrolled
&& $rc_type == RC_NEW
) ?
817 '&rcid='.$rcObj->mAttribs
['rc_id'] : '';
818 $link = '<tt>'.$this->skin
->makeKnownLinkObj( $rcObj->getTitle(),
819 $rcObj->timestamp
, $curIdEq.'&'.$o.$rcIdEq ).'</tt>';
820 if( $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) )
821 $link = '<span class="history-deleted">'.$link.'</span> ';
825 if ( !$rc_type == RC_LOG ||
$rc_type == RC_NEW
) {
827 $r .= $rcObj->curlink
;
828 $r .= $this->message
['semicolon-separator'];
829 $r .= $rcObj->lastlink
;
835 if( $wgRCShowChangedSize ) {
836 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : $rcObj->getCharacterDifference() . ' . . ' ) ;
839 $r .= $rcObj->userlink
;
840 $r .= $rcObj->usertalklink
;
842 $this->insertAction( $r, $rcObj );
844 $this->insertComment( $r, $rcObj );
846 $this->insertRollback( $r, $rcObj );
848 $this->insertTags( $r, $rcObj, $classes );
850 # Mark revision as deleted
851 if( !$rc_log_type && $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) ) {
852 $r .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
855 $r .= "</td></tr>\n";
857 $r .= "</table></div>\n";
859 $this->rcCacheIndex++
;
861 wfProfileOut( __METHOD__
);
867 * Generate HTML for an arrow or placeholder graphic
868 * @param string $dir one of '', 'd', 'l', 'r'
869 * @param string $alt text
870 * @param string $title text
871 * @return string HTML <img> tag
873 protected function arrow( $dir, $alt='', $title='' ) {
875 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
876 $encAlt = htmlspecialchars( $alt );
877 $encTitle = htmlspecialchars( $title );
878 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
882 * Generate HTML for a right- or left-facing arrow,
883 * depending on language direction.
884 * @return string HTML <img> tag
886 protected function sideArrow() {
888 $dir = $wgContLang->isRTL() ?
'l' : 'r';
889 return $this->arrow( $dir, '+', wfMsg( 'rc-enhanced-expand' ) );
893 * Generate HTML for a down-facing arrow
894 * depending on language direction.
895 * @return string HTML <img> tag
897 protected function downArrow() {
898 return $this->arrow( 'd', '-', wfMsg( 'rc-enhanced-hide' ) );
902 * Generate HTML for a spacer image
903 * @return string HTML <img> tag
905 protected function spacerArrow() {
906 return $this->arrow( '', codepointToUtf8( 0xa0 ) ); // non-breaking space
910 * Add a set of spaces
911 * @return string HTML <td> tag
913 protected function spacerIndent() {
914 return ' ';
918 * Enhanced RC ungrouped line.
919 * @return string a HTML formated line (generated using $r)
921 protected function recentChangesBlockLine( $rcObj ) {
922 global $wgContLang, $wgRCShowChangedSize;
924 wfProfileIn( __METHOD__
);
926 # Extract fields from DB into the function scope (rc_xxxx variables)
927 // FIXME: Would be good to replace this extract() call with something
928 // that explicitly initializes variables.
929 $classes = array(); // TODO implement
930 extract( $rcObj->mAttribs
);
931 $curIdEq = "curid={$rc_cur_id}";
933 $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>';
934 $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . ' ';
936 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
937 $r .= ' '; // 4 flags -> 4 spaces
939 $r .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
941 $r .= ' '.$rcObj->timestamp
.' </tt></td><td>';
942 # Article or log link
944 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
945 $logname = LogPage
::logName( $rc_log_type );
946 $r .= '(' . $this->skin
->makeKnownLinkObj($logtitle, $logname ) . ')';
948 $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled
, $rcObj->watched
);
950 # Diff and hist links
951 if ( $rc_type != RC_LOG
) {
952 $r .= ' ('. $rcObj->difflink
. $this->message
['semicolon-separator'];
953 $r .= $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $this->message
['hist'],
954 $curIdEq.'&action=history' ) . ')';
958 if( $wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference()) ) {
962 $r .= ' '.$rcObj->userlink
. $rcObj->usertalklink
;
963 # Log action (if any)
965 if( $this->isDeleted($rcObj,LogPage
::DELETED_ACTION
) ) {
966 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
968 $r .= ' ' . LogPage
::actionText( $rc_log_type, $rc_log_action, $rcObj->getTitle(),
969 $this->skin
, LogPage
::extractParams($rc_params), true, true );
972 $this->insertComment( $r, $rcObj );
973 $this->insertRollback( $r, $rcObj );
975 $this->insertTags( $r, $rcObj, $classes );
976 # Show how many people are watching this if enabled
977 $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers
);
979 $r .= "</td></tr></table>\n";
981 wfProfileOut( __METHOD__
);
987 * If enhanced RC is in use, this function takes the previously cached
988 * RC lines, arranges them, and outputs the HTML
990 protected function recentChangesBlock() {
991 if( count ( $this->rc_cache
) == 0 ) {
995 wfProfileIn( __METHOD__
);
998 foreach( $this->rc_cache
as $block ) {
999 if( count( $block ) < 2 ) {
1000 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
1002 $blockOut .= $this->recentChangesBlockGroup( $block );
1006 wfProfileOut( __METHOD__
);
1008 return '<div>'.$blockOut.'</div>';
1012 * Returns text for the end of RC
1013 * If enhanced RC is in use, returns pretty much all the text
1015 public function endRecentChangesList() {
1016 return $this->recentChangesBlock() . parent
::endRecentChangesList();