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
28 protected $watchlist = false;
31 * Changeslist contructor
34 public 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' ) ?
51 new EnhancedChangesList( $sk ) : new OldChangesList( $sk );
58 * Sets the list to use a <li class="watchlist-(namespace)-(page)"> tag
61 public function setWatchlistDivs( $value = true ) {
62 $this->watchlist
= $value;
66 * As we use the same small set of messages in various methods and that
67 * they are called often, we call them once and save them in $this->message
69 private function preCacheMessages() {
70 if( !isset( $this->message
) ) {
71 foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last '.
72 'blocklink history boteditletter semicolon-separator' ) as $msg ) {
73 $this->message
[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
80 * Returns the appropriate flags for new page, minor change and patrolling
83 * @param bool $patrolled
84 * @param string $nothing, string to use for empty space
88 protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = ' ', $bot = false ) {
90 '<span class="newpage">' . $this->message
['newpageletter'] . '</span>' : $nothing;
92 '<span class="minor">' . $this->message
['minoreditletter'] . '</span>' : $nothing;
93 $f .= $bot ?
'<span class="bot">' . $this->message
['boteditletter'] . '</span>' : $nothing;
94 $f .= $patrolled ?
'<span class="unpatrolled">!</span>' : $nothing;
99 * Returns text for the start of the tabular part of RC
102 public function beginRecentChangesList() {
103 $this->rc_cache
= array();
104 $this->rcMoveIndex
= 0;
105 $this->rcCacheIndex
= 0;
106 $this->lastdate
= '';
107 $this->rclistOpen
= false;
112 * Show formatted char difference
113 * @param int $old bytes
114 * @param int $new bytes
117 public static function showCharacterDifference( $old, $new ) {
118 global $wgRCChangedSizeThreshold, $wgLang, $wgMiserMode;
119 $szdiff = $new - $old;
121 $code = $wgLang->getCode();
122 static $fastCharDiff = array();
123 if ( !isset($fastCharDiff[$code]) ) {
124 $fastCharDiff[$code] = $wgMiserMode ||
wfMsgNoTrans( 'rc-change-size' ) === '$1';
127 $formatedSize = $wgLang->formatNum($szdiff);
129 if ( !$fastCharDiff[$code] ) {
130 $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape' ), $formatedSize );
133 if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
138 if( $szdiff === 0 ) {
139 return "<$tag class='mw-plusminus-null'>($formatedSize)</$tag>";
140 } elseif( $szdiff > 0 ) {
141 return "<$tag class='mw-plusminus-pos'>(+$formatedSize)</$tag>";
143 return "<$tag class='mw-plusminus-neg'>($formatedSize)</$tag>";
148 * Returns text for the end of RC
151 public function endRecentChangesList() {
152 if( $this->rclistOpen
) {
159 protected function insertMove( &$s, $rc ) {
161 $s .= '(' . $this->message
['diff'] . ') (';
163 $s .= $this->skin
->link(
164 $rc->getMovedToTitle(),
165 $this->message
['hist'],
167 array( 'action' => 'history' ),
168 array( 'known', 'noclasses' )
170 # "[[x]] moved to [[y]]"
171 $msg = ( $rc->mAttribs
['rc_type'] == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
178 array( 'redirect' => 'no' ),
179 array( 'known', 'noclasses' )
182 $rc->getMovedToTitle(),
186 array( 'known', 'noclasses' )
191 protected function insertDateHeader( &$s, $rc_timestamp ) {
193 # Make date header if necessary
194 $date = $wgLang->date( $rc_timestamp, true, true );
195 if( $date != $this->lastdate
) {
196 if( '' != $this->lastdate
) {
199 $s .= Xml
::element( 'h4', null, $date ) . "\n<ul class=\"special\">";
200 $this->lastdate
= $date;
201 $this->rclistOpen
= true;
205 protected function insertLog( &$s, $title, $logtype ) {
206 $logname = LogPage
::logName( $logtype );
207 $s .= '(' . $this->skin
->link(
212 array( 'known', 'noclasses' )
216 protected function insertDiffHist( &$s, &$rc, $unpatrolled ) {
218 if( $rc->mAttribs
['rc_type'] == RC_NEW ||
$rc->mAttribs
['rc_type'] == RC_LOG
) {
219 $diffLink = $this->message
['diff'];
220 } else if( !$this->userCan($rc,Revision
::DELETED_TEXT
) ) {
221 $diffLink = $this->message
['diff'];
224 'curid' => $rc->mAttribs
['rc_cur_id'],
225 'diff' => $rc->mAttribs
['rc_this_oldid'],
226 'oldid' => $rc->mAttribs
['rc_last_oldid']
230 $query['rcid'] = $rc->mAttribs
['rc_id'];
233 $diffLink = $this->skin
->link(
235 $this->message
['diff'],
236 array( 'tabindex' => $rc->counter
),
238 array( 'known', 'noclasses' )
241 $s .= '('.$diffLink.') (';
243 $s .= $this->skin
->link(
245 $this->message
['hist'],
248 'curid' => $rc->mAttribs
['rc_cur_id'],
249 'action' => 'history'
251 array( 'known', 'noclasses' )
256 protected function insertArticleLink( &$s, &$rc, $unpatrolled, $watched ) {
258 # If it's a new article, there is no diff link, but if it hasn't been
259 # patrolled yet, we need to give users a way to do so
262 if ( $unpatrolled && $rc->mAttribs
['rc_type'] == RC_NEW
) {
263 $params['rcid'] = $rc->mAttribs
['rc_id'];
266 if( $this->isDeleted($rc,Revision
::DELETED_TEXT
) ) {
267 $articlelink = $this->skin
->link(
272 array( 'known', 'noclasses' )
274 $articlelink = '<span class="history-deleted">' . $articlelink . '</span>';
276 $articlelink = ' '. $this->skin
->link(
281 array( 'known', 'noclasses' )
284 # Bolden pages watched by this user
286 $articlelink = "<strong class=\"mw-watched\">{$articlelink}</strong>";
289 $articlelink .= $wgContLang->getDirMark();
291 wfRunHooks( 'ChangesListInsertArticleLink',
292 array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched) );
294 $s .= " $articlelink";
297 protected function insertTimestamp( &$s, $rc ) {
299 $s .= $this->message
['semicolon-separator'] .
300 $wgLang->time( $rc->mAttribs
['rc_timestamp'], true, true ) . ' . . ';
303 /** Insert links to user page, user talk page and eventually a blocking link */
304 public function insertUserRelatedLinks( &$s, &$rc ) {
305 if( $this->isDeleted( $rc, Revision
::DELETED_USER
) ) {
306 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
308 $s .= $this->skin
->userLink( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
309 $s .= $this->skin
->userToolLinks( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
313 /** insert a formatted action */
314 protected function insertAction( &$s, &$rc ) {
315 if( $rc->mAttribs
['rc_type'] == RC_LOG
) {
316 if( $this->isDeleted( $rc, LogPage
::DELETED_ACTION
) ) {
317 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
319 $s .= ' '.LogPage
::actionText( $rc->mAttribs
['rc_log_type'], $rc->mAttribs
['rc_log_action'],
320 $rc->getTitle(), $this->skin
, LogPage
::extractParams( $rc->mAttribs
['rc_params'] ), true, true );
325 /** insert a formatted comment */
326 protected function insertComment( &$s, &$rc ) {
327 if( $rc->mAttribs
['rc_type'] != RC_MOVE
&& $rc->mAttribs
['rc_type'] != RC_MOVE_OVER_REDIRECT
) {
328 if( $this->isDeleted( $rc, Revision
::DELETED_COMMENT
) ) {
329 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span>';
331 $s .= $this->skin
->commentBlock( $rc->mAttribs
['rc_comment'], $rc->getTitle() );
337 * Check whether to enable recent changes patrol features
340 public static function usePatrol() {
342 return $wgUser->useRCPatrol();
346 * Returns the string which indicates the number of watching users
348 protected function numberofWatchingusers( $count ) {
350 static $cache = array();
352 if( !isset( $cache[$count] ) ) {
353 $cache[$count] = wfMsgExt( 'number_of_watching_users_RCview',
354 array('parsemag', 'escape' ), $wgLang->formatNum( $count ) );
356 return $cache[$count];
363 * Determine if said field of a revision is hidden
364 * @param RCCacheEntry $rc
365 * @param int $field one of DELETED_* bitfield constants
368 public static function isDeleted( $rc, $field ) {
369 return ( $rc->mAttribs
['rc_deleted'] & $field ) == $field;
373 * Determine if the current user is allowed to view a particular
374 * field of this revision, if it's marked as deleted.
375 * @param RCCacheEntry $rc
379 public static function userCan( $rc, $field ) {
380 if( ( $rc->mAttribs
['rc_deleted'] & $field ) == $field ) {
382 $permission = ( $rc->mAttribs
['rc_deleted'] & Revision
::DELETED_RESTRICTED
) == Revision
::DELETED_RESTRICTED
385 wfDebug( "Checking for $permission due to $field match on {$rc->mAttribs['rc_deleted']}\n" );
386 return $wgUser->isAllowed( $permission );
392 protected function maybeWatchedLink( $link, $watched = false ) {
394 return '<strong class="mw-watched">' . $link . '</strong>';
396 return '<span class="mw-rc-unwatched">' . $link . '</span>';
400 /** Inserts a rollback link */
401 protected function insertRollback( &$s, &$rc ) {
403 if( !$rc->mAttribs
['rc_new'] && $rc->mAttribs
['rc_this_oldid'] && $rc->mAttribs
['rc_cur_id'] ) {
404 $page = $rc->getTitle();
405 /** Check for rollback and edit permissions, disallow special pages, and only
406 * show a link on the top-most revision */
407 if ($wgUser->isAllowed('rollback') && $rc->mAttribs
['page_latest'] == $rc->mAttribs
['rc_this_oldid'] )
409 $rev = new Revision( array(
410 'id' => $rc->mAttribs
['rc_this_oldid'],
411 'user' => $rc->mAttribs
['rc_user'],
412 'user_text' => $rc->mAttribs
['rc_user_text'],
413 'deleted' => $rc->mAttribs
['rc_deleted']
415 $rev->setTitle( $page );
416 $s .= ' '.$this->skin
->generateRollback( $rev );
421 protected function insertTags( &$s, &$rc, &$classes ) {
422 if ( empty($rc->mAttribs
['ts_tags']) )
425 list($tagSummary, $newClasses) = ChangeTags
::formatSummaryRow( $rc->mAttribs
['ts_tags'], 'changeslist' );
426 $classes = array_merge( $classes, $newClasses );
427 $s .= ' ' . $tagSummary;
430 protected function insertExtra( &$s, &$rc, &$classes ) {
431 ## Empty, used for subclassers to add anything special.
437 * Generate a list of changes using the good old system (no javascript)
439 class OldChangesList
extends ChangesList
{
441 * Format a line using the old system (aka without any javascript).
443 public function recentChangesLine( &$rc, $watched = false, $linenumber = NULL ) {
444 global $wgLang, $wgRCShowChangedSize, $wgUser;
445 wfProfileIn( __METHOD__
);
446 # Should patrol-related stuff be shown?
447 $unpatrolled = $wgUser->useRCPatrol() && !$rc->mAttribs
['rc_patrolled'];
449 $dateheader = ''; // $s now contains only <li>...</li>, for hooks' convenience.
450 $this->insertDateHeader( $dateheader, $rc->mAttribs
['rc_timestamp'] );
454 // use mw-line-even/mw-line-odd class only if linenumber is given (feature from bug 14468)
456 if( $linenumber & 1 ) {
457 $classes[] = 'mw-line-odd';
460 $classes[] = 'mw-line-even';
465 if( $rc->mAttribs
['rc_type'] == RC_MOVE ||
$rc->mAttribs
['rc_type'] == RC_MOVE_OVER_REDIRECT
) {
466 $this->insertMove( $s, $rc );
468 } elseif( $rc->mAttribs
['rc_log_type'] ) {
469 $logtitle = Title
::newFromText( 'Log/'.$rc->mAttribs
['rc_log_type'], NS_SPECIAL
);
470 $this->insertLog( $s, $logtitle, $rc->mAttribs
['rc_log_type'] );
471 // Log entries (old format) or log targets, and special pages
472 } elseif( $rc->mAttribs
['rc_namespace'] == NS_SPECIAL
) {
473 list( $name, $subpage ) = SpecialPage
::resolveAliasWithSubpage( $rc->mAttribs
['rc_title'] );
474 if( $name == 'Log' ) {
475 $this->insertLog( $s, $rc->getTitle(), $subpage );
479 $this->insertDiffHist( $s, $rc, $unpatrolled );
480 # M, N, b and ! (minor, new, bot and unpatrolled)
481 $s .= $this->recentChangesFlags( $rc->mAttribs
['rc_new'], $rc->mAttribs
['rc_minor'],
482 $unpatrolled, '', $rc->mAttribs
['rc_bot'] );
483 $this->insertArticleLink( $s, $rc, $unpatrolled, $watched );
486 $this->insertTimestamp( $s, $rc );
487 # Bytes added or removed
488 if( $wgRCShowChangedSize ) {
489 $cd = $rc->getCharacterDifference();
495 $this->insertUserRelatedLinks( $s, $rc );
496 # Log action text (if any)
497 $this->insertAction( $s, $rc );
498 # Edit or log comment
499 $this->insertComment( $s, $rc );
501 $this->insertTags( $s, $rc, $classes );
503 $this->insertRollback( $s, $rc );
505 $this->insertExtra( $s, $rc, $classes );
507 # How many users watch this page
508 if( $rc->numberofWatchingusers
> 0 ) {
509 $s .= ' ' . wfMsgExt( 'number_of_watching_users_RCview',
510 array( 'parsemag', 'escape' ), $wgLang->formatNum( $rc->numberofWatchingusers
) );
513 if( $this->watchlist
) {
514 $classes[] = Sanitizer
::escapeClass( 'watchlist-'.$rc->mAttribs
['rc_namespace'].'-'.$rc->mAttribs
['rc_title'] );
517 wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) );
519 wfProfileOut( __METHOD__
);
520 return "$dateheader<li class=\"".implode( ' ', $classes )."\">".$s."</li>\n";
526 * Generate a list of changes using an Enhanced system (uses javascript).
528 class EnhancedChangesList
extends ChangesList
{
530 * Add the JavaScript file for enhanced changeslist
533 public function beginRecentChangesList() {
534 global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
535 $this->rc_cache
= array();
536 $this->rcMoveIndex
= 0;
537 $this->rcCacheIndex
= 0;
538 $this->lastdate
= '';
539 $this->rclistOpen
= false;
540 $script = Xml
::tags( 'script', array(
541 'type' => $wgJsMimeType,
542 'src' => $wgStylePath . "/common/enhancedchanges.js?$wgStyleVersion" ), '' );
546 * Format a line for enhanced recentchange (aka with javascript and block of lines).
548 public function recentChangesLine( &$baseRC, $watched = false ) {
549 global $wgLang, $wgUser;
551 wfProfileIn( __METHOD__
);
553 # Create a specialised object
554 $rc = RCCacheEntry
::newFromParent( $baseRC );
556 # Extract fields from DB into the function scope (rc_xxxx variables)
557 // FIXME: Would be good to replace this extract() call with something
558 // that explicitly initializes variables.
559 extract( $rc->mAttribs
);
560 $curIdEq = array( 'curid' => $rc_cur_id );
562 # If it's a new day, add the headline and flush the cache
563 $date = $wgLang->date( $rc_timestamp, true );
565 if( $date != $this->lastdate
) {
566 # Process current cache
567 $ret = $this->recentChangesBlock();
568 $this->rc_cache
= array();
569 $ret .= Xml
::element( 'h4', null, $date );
570 $this->lastdate
= $date;
573 # Should patrol-related stuff be shown?
574 if( $wgUser->useRCPatrol() ) {
575 $rc->unpatrolled
= !$rc_patrolled;
577 $rc->unpatrolled
= false;
580 $showdifflinks = true;
583 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
584 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
585 $clink = wfMsg( $msg, $this->skin
->linkKnown( $rc->getTitle(), null,
586 array(), array( 'redirect' => 'no' ) ),
587 $this->skin
->linkKnown( $rc->getMovedToTitle() ) );
588 // New unpatrolled pages
589 } else if( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
590 $clink = $this->skin
->linkKnown( $rc->getTitle(), null, array(),
591 array( 'rcid' => $rc_id ) );
593 } else if( $rc_type == RC_LOG
) {
595 $logtitle = SpecialPage
::getTitleFor( 'Log', $rc_log_type );
596 $clink = '(' . $this->skin
->linkKnown( $logtitle,
597 LogPage
::logName($rc_log_type) ) . ')';
599 $clink = $this->skin
->link( $rc->getTitle() );
602 // Log entries (old format) and special pages
603 } elseif( $rc_namespace == NS_SPECIAL
) {
604 list( $specialName, $logtype ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
605 if ( $specialName == 'Log' ) {
607 $logname = LogPage
::logName( $logtype );
608 $clink = '(' . $this->skin
->linkKnown( $rc->getTitle(), $logname ) . ')';
610 wfDebug( "Unexpected special page in recentchanges\n" );
615 $clink = $this->skin
->linkKnown( $rc->getTitle() );
618 # Don't show unusable diff links
619 if ( !ChangesList
::userCan($rc,Revision
::DELETED_TEXT
) ) {
620 $showdifflinks = false;
623 $time = $wgLang->time( $rc_timestamp, true, true );
624 $rc->watched
= $watched;
626 $rc->timestamp
= $time;
627 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
629 # Make "cur" and "diff" links. Do not use link(), it is too slow if
630 # called too many times (50% of CPU time on RecentChanges!).
631 if( $rc->unpatrolled
) {
632 $rcIdQuery = array( 'rcid' => $rc_id );
634 $rcIdQuery = array();
636 $querycur = $curIdEq +
array( 'diff' => '0', 'oldid' => $rc_this_oldid );
637 $querydiff = $curIdEq +
array( 'diff' => $rc_this_oldid, 'oldid' =>
638 $rc_last_oldid ) +
$rcIdQuery;
640 if( !$showdifflinks ) {
641 $curLink = $this->message
['cur'];
642 $diffLink = $this->message
['diff'];
643 } else if( in_array( $rc_type, array(RC_NEW
,RC_LOG
,RC_MOVE
,RC_MOVE_OVER_REDIRECT
) ) ) {
644 if ( $rc_type != RC_NEW
) {
645 $curLink = $this->message
['cur'];
647 $curUrl = htmlspecialchars( $rc->getTitle()->getLinkUrl( $querycur ) );
648 $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
650 $diffLink = $this->message
['diff'];
652 $diffUrl = htmlspecialchars( $rc->getTitle()->getLinkUrl( $querydiff ) );
653 $curUrl = htmlspecialchars( $rc->getTitle()->getLinkUrl( $querycur ) );
654 $diffLink = "<a href=\"$diffUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['diff']}</a>";
655 $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
659 if( !$showdifflinks ||
!$rc_last_oldid ) {
660 $lastLink = $this->message
['last'];
661 } else if( $rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
662 $lastLink = $this->message
['last'];
664 $lastLink = $this->skin
->linkKnown( $rc->getTitle(), $this->message
['last'],
665 array(), $curIdEq +
array('diff' => $rc_this_oldid, 'oldid' => $rc_last_oldid) +
$rcIdQuery );
669 if( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
670 $rc->userlink
= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
672 $rc->userlink
= $this->skin
->userLink( $rc_user, $rc_user_text );
673 $rc->usertalklink
= $this->skin
->userToolLinks( $rc_user, $rc_user_text );
676 $rc->lastlink
= $lastLink;
677 $rc->curlink
= $curLink;
678 $rc->difflink
= $diffLink;
680 # Put accumulated information into the cache, for later display
681 # Page moves go on their own line
682 $title = $rc->getTitle();
683 $secureName = $title->getPrefixedDBkey();
684 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
685 # Use an @ character to prevent collision with page names
686 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
688 # Logs are grouped by type
689 if( $rc_type == RC_LOG
){
690 $secureName = SpecialPage
::getTitleFor( 'Log', $rc_log_type )->getPrefixedDBkey();
692 if( !isset( $this->rc_cache
[$secureName] ) ) {
693 $this->rc_cache
[$secureName] = array();
696 array_push( $this->rc_cache
[$secureName], $rc );
699 wfProfileOut( __METHOD__
);
707 protected function recentChangesBlockGroup( $block ) {
708 global $wgLang, $wgContLang, $wgRCShowChangedSize;
710 wfProfileIn( __METHOD__
);
712 $r = '<table cellpadding="0" cellspacing="0" border="0" style="background: none"><tr>';
714 # Collate list of users
715 $userlinks = array();
717 $unpatrolled = false;
719 $curId = $currentRevision = 0;
720 # Some catalyst variables...
723 foreach( $block as $rcObj ) {
724 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
725 if( $rcObj->mAttribs
['rc_new'] ) {
728 // If all log actions to this page were hidden, then don't
729 // give the name of the affected page for this block!
730 if( !$this->isDeleted( $rcObj, LogPage
::DELETED_ACTION
) ) {
733 $u = $rcObj->userlink
;
734 if( !isset( $userlinks[$u] ) ) {
737 if( $rcObj->unpatrolled
) {
740 if( $rcObj->mAttribs
['rc_type'] != RC_LOG
) {
743 # Get the latest entry with a page_id and oldid
744 # since logs may not have these.
745 if( !$curId && $rcObj->mAttribs
['rc_cur_id'] ) {
746 $curId = $rcObj->mAttribs
['rc_cur_id'];
748 if( !$currentRevision && $rcObj->mAttribs
['rc_this_oldid'] ) {
749 $currentRevision = $rcObj->mAttribs
['rc_this_oldid'];
752 $bot = $rcObj->mAttribs
['rc_bot'];
756 # Sort the list and convert to text
757 krsort( $userlinks );
760 foreach( $userlinks as $userlink => $count) {
762 $text .= $wgContLang->getDirMark();
764 $text .= ' (' . $wgLang->formatNum( $count ) . '×)';
766 array_push( $users, $text );
769 $users = ' <span class="changedby">[' .
770 implode( $this->message
['semicolon-separator'], $users ) . ']</span>';
772 # ID for JS visibility toggle
773 $jsid = $this->rcCacheIndex
;
774 # onclick handler to toggle hidden/expanded
775 $toggleLink = "onclick='toggleVisibility($jsid); return false'";
777 $expandTitle = htmlspecialchars( wfMsg( 'rc-enhanced-expand' ) );
778 $closeTitle = htmlspecialchars( wfMsg( 'rc-enhanced-hide' ) );
780 $tl = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
781 $tl .= "<span id='mw-rc-closearrow-$jsid' class='mw-changeslist-hidden' style='display:none'><a href='#' $toggleLink title='$closeTitle'>" . $this->downArrow() . "</a></span>";
782 $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.' ';
785 $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot );
788 $r .= ' '.$block[0]->timestamp
.' </tt></td><td>';
792 $r .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
793 } else if( $allLogs ) {
794 $r .= $this->maybeWatchedLink( $block[0]->link
, $block[0]->watched
);
796 $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled
, $block[0]->watched
);
799 $r .= $wgContLang->getDirMark();
801 $queryParams['curid'] = $curId;
804 static $nchanges = array();
805 if ( !isset( $nchanges[$n] ) ) {
806 $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) );
812 if( !ChangesList
::userCan( $rcObj, Revision
::DELETED_TEXT
) ) {
814 } else if( $isnew ) {
817 $params = $queryParams;
818 $params['diff'] = $currentRevision;
819 $params['oldid'] = $oldid;
821 $r .= $this->skin
->link(
822 $block[0]->getTitle(),
826 array( 'known', 'noclasses' )
833 // don't show history link for logs
834 } else if( $namehidden ||
!$block[0]->getTitle()->exists() ) {
835 $r .= $this->message
['semicolon-separator'] . $this->message
['hist'] . ')';
837 $params = $queryParams;
838 $params['action'] = 'history';
840 $r .= $this->message
['semicolon-separator'] .
842 $block[0]->getTitle(),
843 $this->message
['hist'],
846 array( 'known', 'noclasses' )
851 # Character difference (does not apply if only log items)
852 if( $wgRCShowChangedSize && !$allLogs ) {
854 $first = count($block) - 1;
855 # Some events (like logs) have an "empty" size, so we need to skip those...
856 while( $last < $first && $block[$last]->mAttribs
['rc_new_len'] === NULL ) {
859 while( $first > $last && $block[$first]->mAttribs
['rc_old_len'] === NULL ) {
863 $chardiff = $rcObj->getCharacterDifference( $block[$first]->mAttribs
['rc_old_len'],
864 $block[$last]->mAttribs
['rc_new_len'] );
866 if( $chardiff == '' ) {
869 $r .= ' ' . $chardiff. ' . . ';
874 $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers
);
876 $r .= "</td></tr></table>\n";
879 $r .= '<div id="mw-rc-subentries-'.$jsid.'" class="mw-changeslist-hidden">';
880 $r .= '<table cellpadding="0" cellspacing="0" border="0" style="background: none">';
881 foreach( $block as $rcObj ) {
882 # Extract fields from DB into the function scope (rc_xxxx variables)
883 // FIXME: Would be good to replace this extract() call with something
884 // that explicitly initializes variables.
885 # Classes to apply -- TODO implement
887 extract( $rcObj->mAttribs
);
889 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
890 $r .= '<tr><td valign="top">';
891 $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
892 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
893 $r .= ' </tt></td><td valign="top">';
895 $params = $queryParams;
897 if( $rc_this_oldid != 0 ) {
898 $params['oldid'] = $rc_this_oldid;
902 if( $rc_type == RC_LOG
) {
903 $link = '<tt>'.$rcObj->timestamp
.'</tt> ';
905 } else if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
906 $link = '<span class="history-deleted"><tt>'.$rcObj->timestamp
.'</tt></span> ';
908 if ( $rcObj->unpatrolled
&& $rc_type == RC_NEW
) {
909 $params['rcid'] = $rcObj->mAttribs
['rc_id'];
918 array( 'known', 'noclasses' )
920 if( $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) )
921 $link = '<span class="history-deleted">'.$link.'</span> ';
925 if ( !$rc_type == RC_LOG ||
$rc_type == RC_NEW
) {
927 $r .= $rcObj->curlink
;
928 $r .= $this->message
['semicolon-separator'];
929 $r .= $rcObj->lastlink
;
935 if( $wgRCShowChangedSize ) {
936 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : $rcObj->getCharacterDifference() . ' . . ' ) ;
939 $r .= $rcObj->userlink
;
940 $r .= $rcObj->usertalklink
;
942 $this->insertAction( $r, $rcObj );
944 $this->insertComment( $r, $rcObj );
946 $this->insertRollback( $r, $rcObj );
948 $this->insertTags( $r, $rcObj, $classes );
950 $r .= "</td></tr>\n";
952 $r .= "</table></div>\n";
954 $this->rcCacheIndex++
;
956 wfProfileOut( __METHOD__
);
962 * Generate HTML for an arrow or placeholder graphic
963 * @param string $dir one of '', 'd', 'l', 'r'
964 * @param string $alt text
965 * @param string $title text
966 * @return string HTML <img> tag
968 protected function arrow( $dir, $alt='', $title='' ) {
970 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
971 $encAlt = htmlspecialchars( $alt );
972 $encTitle = htmlspecialchars( $title );
973 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
977 * Generate HTML for a right- or left-facing arrow,
978 * depending on language direction.
979 * @return string HTML <img> tag
981 protected function sideArrow() {
983 $dir = $wgContLang->isRTL() ?
'l' : 'r';
984 return $this->arrow( $dir, '+', wfMsg( 'rc-enhanced-expand' ) );
988 * Generate HTML for a down-facing arrow
989 * depending on language direction.
990 * @return string HTML <img> tag
992 protected function downArrow() {
993 return $this->arrow( 'd', '-', wfMsg( 'rc-enhanced-hide' ) );
997 * Generate HTML for a spacer image
998 * @return string HTML <img> tag
1000 protected function spacerArrow() {
1001 return $this->arrow( '', codepointToUtf8( 0xa0 ) ); // non-breaking space
1005 * Add a set of spaces
1006 * @return string HTML <td> tag
1008 protected function spacerIndent() {
1009 return ' ';
1013 * Enhanced RC ungrouped line.
1014 * @return string a HTML formated line (generated using $r)
1016 protected function recentChangesBlockLine( $rcObj ) {
1017 global $wgRCShowChangedSize;
1019 wfProfileIn( __METHOD__
);
1021 # Extract fields from DB into the function scope (rc_xxxx variables)
1022 // FIXME: Would be good to replace this extract() call with something
1023 // that explicitly initializes variables.
1024 $classes = array(); // TODO implement
1025 extract( $rcObj->mAttribs
);
1026 $query['curid'] = $rc_cur_id;
1028 $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>';
1029 $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . ' ';
1030 # Flag and Timestamp
1031 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
1032 $r .= ' '; // 4 flags -> 4 spaces
1034 $r .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
1036 $r .= ' '.$rcObj->timestamp
.' </tt></td><td>';
1037 # Article or log link
1038 if( $rc_log_type ) {
1039 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
1040 $logname = LogPage
::logName( $rc_log_type );
1041 $r .= '(' . $this->skin
->link(
1046 array( 'known', 'noclasses' )
1049 $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled
, $rcObj->watched
);
1051 # Diff and hist links
1052 if ( $rc_type != RC_LOG
) {
1053 $r .= ' ('. $rcObj->difflink
. $this->message
['semicolon-separator'];
1054 $query['action'] = 'history';
1055 $r .= $this->skin
->link(
1057 $this->message
['hist'],
1060 array( 'known', 'noclasses' )
1065 if( $wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference()) ) {
1069 $r .= ' '.$rcObj->userlink
. $rcObj->usertalklink
;
1070 # Log action (if any)
1071 if( $rc_log_type ) {
1072 if( $this->isDeleted($rcObj,LogPage
::DELETED_ACTION
) ) {
1073 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
1075 $r .= ' ' . LogPage
::actionText( $rc_log_type, $rc_log_action, $rcObj->getTitle(),
1076 $this->skin
, LogPage
::extractParams($rc_params), true, true );
1079 $this->insertComment( $r, $rcObj );
1080 $this->insertRollback( $r, $rcObj );
1082 $this->insertTags( $r, $rcObj, $classes );
1083 # Show how many people are watching this if enabled
1084 $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers
);
1086 $r .= "</td></tr></table>\n";
1088 wfProfileOut( __METHOD__
);
1094 * If enhanced RC is in use, this function takes the previously cached
1095 * RC lines, arranges them, and outputs the HTML
1097 protected function recentChangesBlock() {
1098 if( count ( $this->rc_cache
) == 0 ) {
1102 wfProfileIn( __METHOD__
);
1105 foreach( $this->rc_cache
as $block ) {
1106 if( count( $block ) < 2 ) {
1107 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
1109 $blockOut .= $this->recentChangesBlockGroup( $block );
1113 wfProfileOut( __METHOD__
);
1115 return '<div>'.$blockOut.'</div>';
1119 * Returns text for the end of RC
1120 * If enhanced RC is in use, returns pretty much all the text
1122 public function endRecentChangesList() {
1123 return $this->recentChangesBlock() . parent
::endRecentChangesList();