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 $code = $wgLang->getCode();
113 static $fastCharDiff = array();
114 if ( !isset($fastCharDiff[$code]) ) {
115 $fastCharDiff[$code] = $wgMiserMode ||
wfMsgNoTrans( 'rc-change-size' ) === '$1';
118 $formatedSize = $wgLang->formatNum($szdiff);
120 if ( !$fastCharDiff[$code] ) {
121 $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape' ), $formatedSize );
124 if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
129 if( $szdiff === 0 ) {
130 return "<$tag class='mw-plusminus-null'>($formatedSize)</$tag>";
131 } elseif( $szdiff > 0 ) {
132 return "<$tag class='mw-plusminus-pos'>(+$formatedSize)</$tag>";
134 return "<$tag class='mw-plusminus-neg'>($formatedSize)</$tag>";
139 * Returns text for the end of RC
142 public function endRecentChangesList() {
143 if( $this->rclistOpen
) {
150 protected function insertMove( &$s, $rc ) {
152 $s .= '(' . $this->message
['diff'] . ') (';
154 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $this->message
['hist'],
155 'action=history' ) . ') . . ';
156 # "[[x]] moved to [[y]]"
157 $msg = ( $rc->mAttribs
['rc_type'] == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
158 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
159 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
162 protected function insertDateHeader( &$s, $rc_timestamp ) {
164 # Make date header if necessary
165 $date = $wgLang->date( $rc_timestamp, true, true );
166 if( $date != $this->lastdate
) {
167 if( '' != $this->lastdate
) {
170 $s .= '<h4>'.$date."</h4>\n<ul class=\"special\">";
171 $this->lastdate
= $date;
172 $this->rclistOpen
= true;
176 protected function insertLog( &$s, $title, $logtype ) {
177 $logname = LogPage
::logName( $logtype );
178 $s .= '(' . $this->skin
->makeKnownLinkObj($title, $logname ) . ')';
181 protected function insertDiffHist( &$s, &$rc, $unpatrolled ) {
183 if( $rc->mAttribs
['rc_type'] == RC_NEW ||
$rc->mAttribs
['rc_type'] == RC_LOG
) {
184 $diffLink = $this->message
['diff'];
185 } else if( !$this->userCan($rc,Revision
::DELETED_TEXT
) ) {
186 $diffLink = $this->message
['diff'];
188 $rcidparam = $unpatrolled ?
array( 'rcid' => $rc->mAttribs
['rc_id'] ) : array();
189 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['diff'],
191 'curid' => $rc->mAttribs
['rc_cur_id'],
192 'diff' => $rc->mAttribs
['rc_this_oldid'],
193 'oldid' => $rc->mAttribs
['rc_last_oldid'] ),
195 '', '', ' tabindex="'.$rc->counter
.'"');
197 $s .= '('.$diffLink.') (';
199 $s .= $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['hist'],
201 'curid' => $rc->mAttribs
['rc_cur_id'],
202 'action' => 'history' ) ) );
206 protected function insertArticleLink( &$s, &$rc, $unpatrolled, $watched ) {
208 # If it's a new article, there is no diff link, but if it hasn't been
209 # patrolled yet, we need to give users a way to do so
210 $params = ( $unpatrolled && $rc->mAttribs
['rc_type'] == RC_NEW
) ?
211 'rcid='.$rc->mAttribs
['rc_id'] : '';
212 if( $this->isDeleted($rc,Revision
::DELETED_TEXT
) ) {
213 $articlelink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', $params );
214 $articlelink = '<span class="history-deleted">'.$articlelink.'</span>';
216 $articlelink = ' '. $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', $params );
218 # Bolden pages watched by this user
220 $articlelink = "<strong class=\"mw-watched\">{$articlelink}</strong>";
223 $articlelink .= $wgContLang->getDirMark();
225 wfRunHooks( 'ChangesListInsertArticleLink',
226 array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched) );
228 $s .= " $articlelink";
231 protected function insertTimestamp( &$s, $rc ) {
233 $s .= $this->message
['semicolon-separator'] .
234 $wgLang->time( $rc->mAttribs
['rc_timestamp'], true, true ) . ' . . ';
237 /** Insert links to user page, user talk page and eventually a blocking link */
238 public function insertUserRelatedLinks( &$s, &$rc ) {
239 if( $this->isDeleted( $rc, Revision
::DELETED_USER
) ) {
240 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
242 $s .= $this->skin
->userLink( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
243 $s .= $this->skin
->userToolLinks( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
247 /** insert a formatted action */
248 protected function insertAction( &$s, &$rc ) {
249 if( $rc->mAttribs
['rc_type'] == RC_LOG
) {
250 if( $this->isDeleted( $rc, LogPage
::DELETED_ACTION
) ) {
251 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
253 $s .= ' '.LogPage
::actionText( $rc->mAttribs
['rc_log_type'], $rc->mAttribs
['rc_log_action'],
254 $rc->getTitle(), $this->skin
, LogPage
::extractParams( $rc->mAttribs
['rc_params'] ), true, true );
259 /** insert a formatted comment */
260 protected function insertComment( &$s, &$rc ) {
261 if( $rc->mAttribs
['rc_type'] != RC_MOVE
&& $rc->mAttribs
['rc_type'] != RC_MOVE_OVER_REDIRECT
) {
262 if( $this->isDeleted( $rc, Revision
::DELETED_COMMENT
) ) {
263 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span>';
265 $s .= $this->skin
->commentBlock( $rc->mAttribs
['rc_comment'], $rc->getTitle() );
271 * Check whether to enable recent changes patrol features
274 public static function usePatrol() {
276 return $wgUser->useRCPatrol();
280 * Returns the string which indicates the number of watching users
282 protected function numberofWatchingusers( $count ) {
284 static $cache = array();
286 if( !isset( $cache[$count] ) ) {
287 $cache[$count] = wfMsgExt( 'number_of_watching_users_RCview',
288 array('parsemag', 'escape' ), $wgLang->formatNum( $count ) );
290 return $cache[$count];
297 * Determine if said field of a revision is hidden
298 * @param RCCacheEntry $rc
299 * @param int $field one of DELETED_* bitfield constants
302 public static function isDeleted( $rc, $field ) {
303 return ( $rc->mAttribs
['rc_deleted'] & $field ) == $field;
307 * Determine if the current user is allowed to view a particular
308 * field of this revision, if it's marked as deleted.
309 * @param RCCacheEntry $rc
313 public static function userCan( $rc, $field ) {
314 if( ( $rc->mAttribs
['rc_deleted'] & $field ) == $field ) {
316 $permission = ( $rc->mAttribs
['rc_deleted'] & Revision
::DELETED_RESTRICTED
) == Revision
::DELETED_RESTRICTED
319 wfDebug( "Checking for $permission due to $field match on {$rc->mAttribs['rc_deleted']}\n" );
320 return $wgUser->isAllowed( $permission );
326 protected function maybeWatchedLink( $link, $watched=false ) {
328 return '<strong class="mw-watched">' . $link . '</strong>';
330 return '<span class="mw-rc-unwatched">' . $link . '</span>';
334 /** Inserts a rollback link */
335 protected function insertRollback( &$s, &$rc ) {
337 if( !$rc->mAttribs
['rc_new'] && $rc->mAttribs
['rc_this_oldid'] && $rc->mAttribs
['rc_cur_id'] ) {
338 $page = $rc->getTitle();
339 /** Check for rollback and edit permissions, disallow special pages, and only
340 * show a link on the top-most revision */
341 if ($wgUser->isAllowed('rollback') && $rc->mAttribs
['page_latest'] == $rc->mAttribs
['rc_this_oldid'] )
343 $rev = new Revision( array(
344 'id' => $rc->mAttribs
['rc_this_oldid'],
345 'user' => $rc->mAttribs
['rc_user'],
346 'user_text' => $rc->mAttribs
['rc_user_text'],
347 'deleted' => $rc->mAttribs
['rc_deleted']
349 $rev->setTitle( $page );
350 $s .= ' '.$this->skin
->generateRollback( $rev );
355 protected function insertTags( &$s, &$rc, &$classes ) {
356 if ( empty($rc->mAttribs
['ts_tags']) )
359 list($tagSummary, $newClasses) = ChangeTags
::formatSummaryRow( $rc->mAttribs
['ts_tags'], 'changeslist' );
360 $classes = array_merge( $classes, $newClasses );
361 $s .= ' ' . $tagSummary;
364 protected function insertExtra( &$s, &$rc, &$classes ) {
365 ## Empty, used for subclassers to add anything special.
371 * Generate a list of changes using the good old system (no javascript)
373 class OldChangesList
extends ChangesList
{
375 * Format a line using the old system (aka without any javascript).
377 public function recentChangesLine( &$rc, $watched = false, $linenumber = NULL ) {
378 global $wgLang, $wgRCShowChangedSize, $wgUser;
379 wfProfileIn( __METHOD__
);
380 # Should patrol-related stuff be shown?
381 $unpatrolled = $wgUser->useRCPatrol() && !$rc->mAttribs
['rc_patrolled'];
383 $dateheader = ''; // $s now contains only <li>...</li>, for hooks' convenience.
384 $this->insertDateHeader( $dateheader, $rc->mAttribs
['rc_timestamp'] );
388 // use mw-line-even/mw-line-odd class only if linenumber is given (feature from bug 14468)
390 if( $linenumber & 1 ) {
391 $classes[] = 'mw-line-odd';
394 $classes[] = 'mw-line-even';
399 if( $rc->mAttribs
['rc_type'] == RC_MOVE ||
$rc->mAttribs
['rc_type'] == RC_MOVE_OVER_REDIRECT
) {
400 $this->insertMove( $s, $rc );
402 } elseif( $rc->mAttribs
['rc_log_type'] ) {
403 $logtitle = Title
::newFromText( 'Log/'.$rc->mAttribs
['rc_log_type'], NS_SPECIAL
);
404 $this->insertLog( $s, $logtitle, $rc->mAttribs
['rc_log_type'] );
405 // Log entries (old format) or log targets, and special pages
406 } elseif( $rc->mAttribs
['rc_namespace'] == NS_SPECIAL
) {
407 list( $name, $subpage ) = SpecialPage
::resolveAliasWithSubpage( $rc->mAttribs
['rc_title'] );
408 if( $name == 'Log' ) {
409 $this->insertLog( $s, $rc->getTitle(), $subpage );
413 $this->insertDiffHist( $s, $rc, $unpatrolled );
414 # M, N, b and ! (minor, new, bot and unpatrolled)
415 $s .= $this->recentChangesFlags( $rc->mAttribs
['rc_new'], $rc->mAttribs
['rc_minor'],
416 $unpatrolled, '', $rc->mAttribs
['rc_bot'] );
417 $this->insertArticleLink( $s, $rc, $unpatrolled, $watched );
420 $this->insertTimestamp( $s, $rc );
421 # Bytes added or removed
422 if( $wgRCShowChangedSize ) {
423 $cd = $rc->getCharacterDifference();
429 $this->insertUserRelatedLinks( $s, $rc );
430 # Log action text (if any)
431 $this->insertAction( $s, $rc );
432 # Edit or log comment
433 $this->insertComment( $s, $rc );
435 $this->insertTags( $s, $rc, $classes );
437 $this->insertRollback( $s, $rc );
439 $this->insertExtra( $s, $rc, $classes );
441 # Mark revision as deleted if so
442 if( !$rc->mAttribs
['rc_log_type'] && $this->isDeleted($rc,Revision
::DELETED_TEXT
) ) {
443 $s .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
445 # How many users watch this page
446 if( $rc->numberofWatchingusers
> 0 ) {
447 $s .= ' ' . wfMsgExt( 'number_of_watching_users_RCview',
448 array( 'parsemag', 'escape' ), $wgLang->formatNum( $rc->numberofWatchingusers
) );
451 wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) );
453 wfProfileOut( __METHOD__
);
454 return "$dateheader<li class=\"".implode( ' ', $classes )."\">$s</li>\n";
460 * Generate a list of changes using an Enhanced system (uses javascript).
462 class EnhancedChangesList
extends ChangesList
{
464 * Add the JavaScript file for enhanced changeslist
467 public function beginRecentChangesList() {
468 global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
469 $this->rc_cache
= array();
470 $this->rcMoveIndex
= 0;
471 $this->rcCacheIndex
= 0;
472 $this->lastdate
= '';
473 $this->rclistOpen
= false;
474 $script = Xml
::tags( 'script', array(
475 'type' => $wgJsMimeType,
476 'src' => $wgStylePath . "/common/enhancedchanges.js?$wgStyleVersion" ), '' );
480 * Format a line for enhanced recentchange (aka with javascript and block of lines).
482 public function recentChangesLine( &$baseRC, $watched = false ) {
483 global $wgLang, $wgUser;
485 wfProfileIn( __METHOD__
);
487 # Create a specialised object
488 $rc = RCCacheEntry
::newFromParent( $baseRC );
490 # Extract fields from DB into the function scope (rc_xxxx variables)
491 // FIXME: Would be good to replace this extract() call with something
492 // that explicitly initializes variables.
493 extract( $rc->mAttribs
);
494 $curIdEq = array( 'curid' => $rc_cur_id );
496 # If it's a new day, add the headline and flush the cache
497 $date = $wgLang->date( $rc_timestamp, true );
499 if( $date != $this->lastdate
) {
500 # Process current cache
501 $ret = $this->recentChangesBlock();
502 $this->rc_cache
= array();
503 $ret .= "<h4>{$date}</h4>\n";
504 $this->lastdate
= $date;
507 # Should patrol-related stuff be shown?
508 if( $wgUser->useRCPatrol() ) {
509 $rc->unpatrolled
= !$rc_patrolled;
511 $rc->unpatrolled
= false;
514 $showdifflinks = true;
517 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
518 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
519 $clink = wfMsg( $msg, $this->skin
->linkKnown( $rc->getTitle(), null,
520 array(), array( 'redirect' => 'no' ) ),
521 $this->skin
->linkKnown( $rc->getMovedToTitle() ) );
522 // New unpatrolled pages
523 } else if( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
524 $clink = $this->skin
->linkKnown( $rc->getTitle(), null, array(),
525 array( 'rcid' => $rc_id ) );
527 } else if( $rc_type == RC_LOG
) {
529 $logtitle = SpecialPage
::getTitleFor( 'Log', $rc_log_type );
530 $clink = '(' . $this->skin
->linkKnown( $logtitle,
531 LogPage
::logName($rc_log_type) ) . ')';
533 $clink = $this->skin
->link( $rc->getTitle() );
536 // Log entries (old format) and special pages
537 } elseif( $rc_namespace == NS_SPECIAL
) {
538 list( $specialName, $logtype ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
539 if ( $specialName == 'Log' ) {
541 $logname = LogPage
::logName( $logtype );
542 $clink = '(' . $this->skin
->linkKnown( $rc->getTitle(), $logname ) . ')';
544 wfDebug( "Unexpected special page in recentchanges\n" );
549 $clink = $this->skin
->linkKnown( $rc->getTitle() );
552 # Don't show unusable diff links
553 if ( !ChangesList
::userCan($rc,Revision
::DELETED_TEXT
) ) {
554 $showdifflinks = false;
557 $time = $wgLang->time( $rc_timestamp, true, true );
558 $rc->watched
= $watched;
560 $rc->timestamp
= $time;
561 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
563 # Make "cur" and "diff" links. Don't use link(), it's too slow if
564 # called too many times (50% of CPU time on RecentChanges!).
565 if( $rc->unpatrolled
) {
566 $rcIdQuery = array( 'rcid' => $rc_id );
568 $rcIdQuery = array();
570 $querycur = $curIdEq +
array( 'diff' => '0', 'oldid' => $rc_this_oldid );
571 $querydiff = $curIdEq +
array( 'diff' => $rc_this_oldid, 'oldid' =>
572 $rc_last_oldid ) +
$rcIdQuery;
574 if( !$showdifflinks ) {
575 $curLink = $this->message
['cur'];
576 $diffLink = $this->message
['diff'];
577 } else if( in_array( $rc_type, array(RC_NEW
,RC_LOG
,RC_MOVE
,RC_MOVE_OVER_REDIRECT
) ) ) {
578 if ( $rc_type != RC_NEW
) {
579 $curLink = $this->message
['cur'];
581 $curUrl = wfUrlencode( $rc->getTitle()->getLinkUrl( $querycur ) );
582 $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
584 $diffLink = $this->message
['diff'];
586 $diffUrl = wfUrlencode( $rc->getTitle()->getLinkUrl( $querydiff ) );
587 $curUrl = wfUrlencode( $rc->getTitle()->getLinkUrl( $querycur ) );
588 $diffLink = "<a href=\"$diffUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['diff']}</a>";
589 $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
593 if( !$showdifflinks ||
!$rc_last_oldid ) {
594 $lastLink = $this->message
['last'];
595 } else if( $rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
596 $lastLink = $this->message
['last'];
598 $lastLink = $this->skin
->linkKnown( $rc->getTitle(), $this->message
['last'],
599 array(), $curIdEq +
array('diff' => $rc_this_oldid, 'oldid' => $rc_last_oldid) +
$rcIdQuery );
603 if( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
604 $rc->userlink
= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
606 $rc->userlink
= $this->skin
->userLink( $rc_user, $rc_user_text );
607 $rc->usertalklink
= $this->skin
->userToolLinks( $rc_user, $rc_user_text );
610 $rc->lastlink
= $lastLink;
611 $rc->curlink
= $curLink;
612 $rc->difflink
= $diffLink;
614 # Put accumulated information into the cache, for later display
615 # Page moves go on their own line
616 $title = $rc->getTitle();
617 $secureName = $title->getPrefixedDBkey();
618 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
619 # Use an @ character to prevent collision with page names
620 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
622 # Logs are grouped by type
623 if( $rc_type == RC_LOG
){
624 $secureName = SpecialPage
::getTitleFor( 'Log', $rc_log_type )->getPrefixedDBkey();
626 if( !isset( $this->rc_cache
[$secureName] ) ) {
627 $this->rc_cache
[$secureName] = array();
630 array_push( $this->rc_cache
[$secureName], $rc );
633 wfProfileOut( __METHOD__
);
641 protected function recentChangesBlockGroup( $block ) {
642 global $wgLang, $wgContLang, $wgRCShowChangedSize;
644 wfProfileIn( __METHOD__
);
646 $r = '<table cellpadding="0" cellspacing="0" border="0" style="background: none"><tr>';
648 # Collate list of users
649 $userlinks = array();
651 $unpatrolled = false;
653 $curId = $currentRevision = 0;
654 # Some catalyst variables...
657 foreach( $block as $rcObj ) {
658 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
659 if( $rcObj->mAttribs
['rc_new'] ) {
662 // If all log actions to this page were hidden, then don't
663 // give the name of the affected page for this block!
664 if( !$this->isDeleted( $rcObj, LogPage
::DELETED_ACTION
) ) {
667 $u = $rcObj->userlink
;
668 if( !isset( $userlinks[$u] ) ) {
671 if( $rcObj->unpatrolled
) {
674 if( $rcObj->mAttribs
['rc_type'] != RC_LOG
) {
677 # Get the latest entry with a page_id and oldid
678 # since logs may not have these.
679 if( !$curId && $rcObj->mAttribs
['rc_cur_id'] ) {
680 $curId = $rcObj->mAttribs
['rc_cur_id'];
682 if( !$currentRevision && $rcObj->mAttribs
['rc_this_oldid'] ) {
683 $currentRevision = $rcObj->mAttribs
['rc_this_oldid'];
686 $bot = $rcObj->mAttribs
['rc_bot'];
690 # Sort the list and convert to text
691 krsort( $userlinks );
694 foreach( $userlinks as $userlink => $count) {
696 $text .= $wgContLang->getDirMark();
698 $text .= ' (' . $wgLang->formatNum( $count ) . '×)';
700 array_push( $users, $text );
703 $users = ' <span class="changedby">[' .
704 implode( $this->message
['semicolon-separator'], $users ) . ']</span>';
706 # ID for JS visibility toggle
707 $jsid = $this->rcCacheIndex
;
708 # onclick handler to toggle hidden/expanded
709 $toggleLink = "onclick='toggleVisibility($jsid); return false'";
711 $expandTitle = htmlspecialchars( wfMsg( 'rc-enhanced-expand' ) );
712 $closeTitle = htmlspecialchars( wfMsg( 'rc-enhanced-hide' ) );
714 $tl = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
715 $tl .= "<span id='mw-rc-closearrow-$jsid' class='mw-changeslist-hidden' style='display:none'><a href='#' $toggleLink title='$closeTitle'>" . $this->downArrow() . "</a></span>";
716 $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.' ';
719 $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot );
722 $r .= ' '.$block[0]->timestamp
.' </tt></td><td>';
726 $r .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
727 } else if( $allLogs ) {
728 $r .= $this->maybeWatchedLink( $block[0]->link
, $block[0]->watched
);
730 $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled
, $block[0]->watched
);
733 $r .= $wgContLang->getDirMark();
735 $curIdEq = 'curid=' . $curId;
738 static $nchanges = array();
739 if ( !isset( $nchanges[$n] ) ) {
740 $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) );
746 if( !ChangesList
::userCan( $rcObj, Revision
::DELETED_TEXT
) ) {
748 } else if( $isnew ) {
751 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
752 $nchanges[$n], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
758 // don't show history link for logs
759 } else if( $namehidden ||
!$block[0]->getTitle()->exists() ) {
760 $r .= $this->message
['semicolon-separator'] . $this->message
['hist'] . ')';
762 $r .= $this->message
['semicolon-separator'] . $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
763 $this->message
['hist'], $curIdEq . '&action=history' ) . ')';
767 # Character difference (does not apply if only log items)
768 if( $wgRCShowChangedSize && !$allLogs ) {
770 $first = count($block) - 1;
771 # Some events (like logs) have an "empty" size, so we need to skip those...
772 while( $last < $first && $block[$last]->mAttribs
['rc_new_len'] === NULL ) {
775 while( $first > $last && $block[$first]->mAttribs
['rc_old_len'] === NULL ) {
779 $chardiff = $rcObj->getCharacterDifference( $block[$first]->mAttribs
['rc_old_len'],
780 $block[$last]->mAttribs
['rc_new_len'] );
782 if( $chardiff == '' ) {
785 $r .= ' ' . $chardiff. ' . . ';
790 $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers
);
792 $r .= "</td></tr></table>\n";
795 $r .= '<div id="mw-rc-subentries-'.$jsid.'" class="mw-changeslist-hidden">';
796 $r .= '<table cellpadding="0" cellspacing="0" border="0" style="background: none">';
797 foreach( $block as $rcObj ) {
798 # Extract fields from DB into the function scope (rc_xxxx variables)
799 // FIXME: Would be good to replace this extract() call with something
800 // that explicitly initializes variables.
801 # Classes to apply -- TODO implement
803 extract( $rcObj->mAttribs
);
805 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
806 $r .= '<tr><td valign="top">';
807 $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
808 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
809 $r .= ' </tt></td><td valign="top">';
812 if( $rc_this_oldid != 0 ) {
813 $o = 'oldid='.$rc_this_oldid;
816 if( $rc_type == RC_LOG
) {
817 $link = '<tt>'.$rcObj->timestamp
.'</tt> ';
819 } else if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
820 $link = '<span class="history-deleted"><tt>'.$rcObj->timestamp
.'</tt></span> ';
822 $rcIdEq = ($rcObj->unpatrolled
&& $rc_type == RC_NEW
) ?
823 '&rcid='.$rcObj->mAttribs
['rc_id'] : '';
824 $link = '<tt>'.$this->skin
->makeKnownLinkObj( $rcObj->getTitle(),
825 $rcObj->timestamp
, $curIdEq.'&'.$o.$rcIdEq ).'</tt>';
826 if( $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) )
827 $link = '<span class="history-deleted">'.$link.'</span> ';
831 if ( !$rc_type == RC_LOG ||
$rc_type == RC_NEW
) {
833 $r .= $rcObj->curlink
;
834 $r .= $this->message
['semicolon-separator'];
835 $r .= $rcObj->lastlink
;
841 if( $wgRCShowChangedSize ) {
842 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : $rcObj->getCharacterDifference() . ' . . ' ) ;
845 $r .= $rcObj->userlink
;
846 $r .= $rcObj->usertalklink
;
848 $this->insertAction( $r, $rcObj );
850 $this->insertComment( $r, $rcObj );
852 $this->insertRollback( $r, $rcObj );
854 $this->insertTags( $r, $rcObj, $classes );
856 # Mark revision as deleted
857 if( !$rc_log_type && $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) ) {
858 $r .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
861 $r .= "</td></tr>\n";
863 $r .= "</table></div>\n";
865 $this->rcCacheIndex++
;
867 wfProfileOut( __METHOD__
);
873 * Generate HTML for an arrow or placeholder graphic
874 * @param string $dir one of '', 'd', 'l', 'r'
875 * @param string $alt text
876 * @param string $title text
877 * @return string HTML <img> tag
879 protected function arrow( $dir, $alt='', $title='' ) {
881 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
882 $encAlt = htmlspecialchars( $alt );
883 $encTitle = htmlspecialchars( $title );
884 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
888 * Generate HTML for a right- or left-facing arrow,
889 * depending on language direction.
890 * @return string HTML <img> tag
892 protected function sideArrow() {
894 $dir = $wgContLang->isRTL() ?
'l' : 'r';
895 return $this->arrow( $dir, '+', wfMsg( 'rc-enhanced-expand' ) );
899 * Generate HTML for a down-facing arrow
900 * depending on language direction.
901 * @return string HTML <img> tag
903 protected function downArrow() {
904 return $this->arrow( 'd', '-', wfMsg( 'rc-enhanced-hide' ) );
908 * Generate HTML for a spacer image
909 * @return string HTML <img> tag
911 protected function spacerArrow() {
912 return $this->arrow( '', codepointToUtf8( 0xa0 ) ); // non-breaking space
916 * Add a set of spaces
917 * @return string HTML <td> tag
919 protected function spacerIndent() {
920 return ' ';
924 * Enhanced RC ungrouped line.
925 * @return string a HTML formated line (generated using $r)
927 protected function recentChangesBlockLine( $rcObj ) {
928 global $wgRCShowChangedSize;
930 wfProfileIn( __METHOD__
);
932 # Extract fields from DB into the function scope (rc_xxxx variables)
933 // FIXME: Would be good to replace this extract() call with something
934 // that explicitly initializes variables.
935 $classes = array(); // TODO implement
936 extract( $rcObj->mAttribs
);
937 $curIdEq = "curid={$rc_cur_id}";
939 $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>';
940 $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . ' ';
942 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
943 $r .= ' '; // 4 flags -> 4 spaces
945 $r .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
947 $r .= ' '.$rcObj->timestamp
.' </tt></td><td>';
948 # Article or log link
950 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
951 $logname = LogPage
::logName( $rc_log_type );
952 $r .= '(' . $this->skin
->makeKnownLinkObj($logtitle, $logname ) . ')';
954 $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled
, $rcObj->watched
);
956 # Diff and hist links
957 if ( $rc_type != RC_LOG
) {
958 $r .= ' ('. $rcObj->difflink
. $this->message
['semicolon-separator'];
959 $r .= $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $this->message
['hist'],
960 $curIdEq.'&action=history' ) . ')';
964 if( $wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference()) ) {
968 $r .= ' '.$rcObj->userlink
. $rcObj->usertalklink
;
969 # Log action (if any)
971 if( $this->isDeleted($rcObj,LogPage
::DELETED_ACTION
) ) {
972 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
974 $r .= ' ' . LogPage
::actionText( $rc_log_type, $rc_log_action, $rcObj->getTitle(),
975 $this->skin
, LogPage
::extractParams($rc_params), true, true );
978 $this->insertComment( $r, $rcObj );
979 $this->insertRollback( $r, $rcObj );
981 $this->insertTags( $r, $rcObj, $classes );
982 # Show how many people are watching this if enabled
983 $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers
);
985 $r .= "</td></tr></table>\n";
987 wfProfileOut( __METHOD__
);
993 * If enhanced RC is in use, this function takes the previously cached
994 * RC lines, arranges them, and outputs the HTML
996 protected function recentChangesBlock() {
997 if( count ( $this->rc_cache
) == 0 ) {
1001 wfProfileIn( __METHOD__
);
1004 foreach( $this->rc_cache
as $block ) {
1005 if( count( $block ) < 2 ) {
1006 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
1008 $blockOut .= $this->recentChangesBlockGroup( $block );
1012 wfProfileOut( __METHOD__
);
1014 return '<div>'.$blockOut.'</div>';
1018 * Returns text for the end of RC
1019 * If enhanced RC is in use, returns pretty much all the text
1021 public function endRecentChangesList() {
1022 return $this->recentChangesBlock() . parent
::endRecentChangesList();