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 last blocklink history ' .
72 'semicolon-separator pipe-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 ) {
89 $f = $new ? self
::flag( 'newpage' ) : $nothing;
90 $f .= $minor ? self
::flag( 'minor' ) : $nothing;
91 $f .= $bot ? self
::flag( 'bot' ) : $nothing;
92 $f .= $patrolled ? self
::flag( 'unpatrolled' ) : $nothing;
97 * Provide the <abbr> element appropriate to a given abbreviated flag,
98 * namely the flag indicating a new page, a minor edit, a bot edit, or an
99 * unpatrolled edit. By default in English it will contain "N", "m", "b",
100 * "!" respectively, plus it will have an appropriate title and class.
102 * @param $key string 'newpage', 'unpatrolled', 'minor', or 'bot'
103 * @return string Raw HTML
105 public static function flag( $key ) {
106 static $messages = null;
107 if ( is_null( $messages ) ) {
108 foreach ( explode( ' ', 'minoreditletter boteditletter newpageletter ' .
109 'unpatrolledletter recentchanges-label-minor recentchanges-label-bot ' .
110 'recentchanges-label-newpage recentchanges-label-unpatrolled' ) as $msg ) {
111 $messages[$msg] = wfMsgExt( $msg, 'escapenoentities' );
114 # Inconsistent naming, bleh
115 if ( $key == 'newpage' ||
$key == 'unpatrolled' ) {
118 $key2 = $key . 'edit';
120 return "<abbr class=\"$key\" title=\""
121 . $messages["recentchanges-label-$key"] . "\">"
122 . $messages["${key2}letter"]
127 * Returns text for the start of the tabular part of RC
130 public function beginRecentChangesList() {
131 $this->rc_cache
= array();
132 $this->rcMoveIndex
= 0;
133 $this->rcCacheIndex
= 0;
134 $this->lastdate
= '';
135 $this->rclistOpen
= false;
140 * Show formatted char difference
141 * @param int $old bytes
142 * @param int $new bytes
145 public static function showCharacterDifference( $old, $new ) {
146 global $wgRCChangedSizeThreshold, $wgLang, $wgMiserMode;
147 $szdiff = $new - $old;
149 $code = $wgLang->getCode();
150 static $fastCharDiff = array();
151 if ( !isset($fastCharDiff[$code]) ) {
152 $fastCharDiff[$code] = $wgMiserMode ||
wfMsgNoTrans( 'rc-change-size' ) === '$1';
155 $formatedSize = $wgLang->formatNum($szdiff);
157 if ( !$fastCharDiff[$code] ) {
158 $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape' ), $formatedSize );
161 if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
166 if( $szdiff === 0 ) {
167 return "<$tag class='mw-plusminus-null'>($formatedSize)</$tag>";
168 } elseif( $szdiff > 0 ) {
169 return "<$tag class='mw-plusminus-pos'>(+$formatedSize)</$tag>";
171 return "<$tag class='mw-plusminus-neg'>($formatedSize)</$tag>";
176 * Returns text for the end of RC
179 public function endRecentChangesList() {
180 if( $this->rclistOpen
) {
187 protected function insertMove( &$s, $rc ) {
189 $s .= '(' . $this->message
['diff'] . ') (';
191 $s .= $this->skin
->link(
192 $rc->getMovedToTitle(),
193 $this->message
['hist'],
195 array( 'action' => 'history' ),
196 array( 'known', 'noclasses' )
198 # "[[x]] moved to [[y]]"
199 $msg = ( $rc->mAttribs
['rc_type'] == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
206 array( 'redirect' => 'no' ),
207 array( 'known', 'noclasses' )
210 $rc->getMovedToTitle(),
214 array( 'known', 'noclasses' )
219 protected function insertDateHeader( &$s, $rc_timestamp ) {
221 # Make date header if necessary
222 $date = $wgLang->date( $rc_timestamp, true, true );
223 if( $date != $this->lastdate
) {
224 if( '' != $this->lastdate
) {
227 $s .= Xml
::element( 'h4', null, $date ) . "\n<ul class=\"special\">";
228 $this->lastdate
= $date;
229 $this->rclistOpen
= true;
233 protected function insertLog( &$s, $title, $logtype ) {
234 $logname = LogPage
::logName( $logtype );
235 $s .= '(' . $this->skin
->link(
240 array( 'known', 'noclasses' )
244 protected function insertDiffHist( &$s, &$rc, $unpatrolled ) {
246 if( $rc->mAttribs
['rc_type'] == RC_NEW ||
$rc->mAttribs
['rc_type'] == RC_LOG
) {
247 $diffLink = $this->message
['diff'];
248 } else if( !$this->userCan($rc,Revision
::DELETED_TEXT
) ) {
249 $diffLink = $this->message
['diff'];
252 'curid' => $rc->mAttribs
['rc_cur_id'],
253 'diff' => $rc->mAttribs
['rc_this_oldid'],
254 'oldid' => $rc->mAttribs
['rc_last_oldid']
258 $query['rcid'] = $rc->mAttribs
['rc_id'];
261 $diffLink = $this->skin
->link(
263 $this->message
['diff'],
264 array( 'tabindex' => $rc->counter
),
266 array( 'known', 'noclasses' )
269 $s .= '('.$diffLink.') (';
271 $s .= $this->skin
->link(
273 $this->message
['hist'],
276 'curid' => $rc->mAttribs
['rc_cur_id'],
277 'action' => 'history'
279 array( 'known', 'noclasses' )
284 protected function insertArticleLink( &$s, &$rc, $unpatrolled, $watched ) {
286 # If it's a new article, there is no diff link, but if it hasn't been
287 # patrolled yet, we need to give users a way to do so
290 if ( $unpatrolled && $rc->mAttribs
['rc_type'] == RC_NEW
) {
291 $params['rcid'] = $rc->mAttribs
['rc_id'];
294 if( $this->isDeleted($rc,Revision
::DELETED_TEXT
) ) {
295 $articlelink = $this->skin
->link(
300 array( 'known', 'noclasses' )
302 $articlelink = '<span class="history-deleted">' . $articlelink . '</span>';
304 $articlelink = ' '. $this->skin
->link(
309 array( 'known', 'noclasses' )
312 # Bolden pages watched by this user
314 $articlelink = "<strong class=\"mw-watched\">{$articlelink}</strong>";
317 $articlelink .= $wgContLang->getDirMark();
319 wfRunHooks( 'ChangesListInsertArticleLink',
320 array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched) );
322 $s .= " $articlelink";
325 protected function insertTimestamp( &$s, $rc ) {
327 $s .= $this->message
['semicolon-separator'] .
328 $wgLang->time( $rc->mAttribs
['rc_timestamp'], true, true ) . ' . . ';
331 /** Insert links to user page, user talk page and eventually a blocking link */
332 public function insertUserRelatedLinks( &$s, &$rc ) {
333 if( $this->isDeleted( $rc, Revision
::DELETED_USER
) ) {
334 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
336 $s .= $this->skin
->userLink( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
337 $s .= $this->skin
->userToolLinks( $rc->mAttribs
['rc_user'], $rc->mAttribs
['rc_user_text'] );
341 /** insert a formatted action */
342 protected function insertAction( &$s, &$rc ) {
343 if( $rc->mAttribs
['rc_type'] == RC_LOG
) {
344 if( $this->isDeleted( $rc, LogPage
::DELETED_ACTION
) ) {
345 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
347 $s .= ' '.LogPage
::actionText( $rc->mAttribs
['rc_log_type'], $rc->mAttribs
['rc_log_action'],
348 $rc->getTitle(), $this->skin
, LogPage
::extractParams( $rc->mAttribs
['rc_params'] ), true, true );
353 /** insert a formatted comment */
354 protected function insertComment( &$s, &$rc ) {
355 if( $rc->mAttribs
['rc_type'] != RC_MOVE
&& $rc->mAttribs
['rc_type'] != RC_MOVE_OVER_REDIRECT
) {
356 if( $this->isDeleted( $rc, Revision
::DELETED_COMMENT
) ) {
357 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span>';
359 $s .= $this->skin
->commentBlock( $rc->mAttribs
['rc_comment'], $rc->getTitle() );
365 * Check whether to enable recent changes patrol features
368 public static function usePatrol() {
370 return $wgUser->useRCPatrol();
374 * Returns the string which indicates the number of watching users
376 protected function numberofWatchingusers( $count ) {
378 static $cache = array();
380 if( !isset( $cache[$count] ) ) {
381 $cache[$count] = wfMsgExt( 'number_of_watching_users_RCview',
382 array('parsemag', 'escape' ), $wgLang->formatNum( $count ) );
384 return $cache[$count];
391 * Determine if said field of a revision is hidden
392 * @param RCCacheEntry $rc
393 * @param int $field one of DELETED_* bitfield constants
396 public static function isDeleted( $rc, $field ) {
397 return ( $rc->mAttribs
['rc_deleted'] & $field ) == $field;
401 * Determine if the current user is allowed to view a particular
402 * field of this revision, if it's marked as deleted.
403 * @param RCCacheEntry $rc
407 public static function userCan( $rc, $field ) {
408 if( ( $rc->mAttribs
['rc_deleted'] & $field ) == $field ) {
410 $permission = ( $rc->mAttribs
['rc_deleted'] & Revision
::DELETED_RESTRICTED
) == Revision
::DELETED_RESTRICTED
413 wfDebug( "Checking for $permission due to $field match on {$rc->mAttribs['rc_deleted']}\n" );
414 return $wgUser->isAllowed( $permission );
420 protected function maybeWatchedLink( $link, $watched = false ) {
422 return '<strong class="mw-watched">' . $link . '</strong>';
424 return '<span class="mw-rc-unwatched">' . $link . '</span>';
428 /** Inserts a rollback link */
429 public function insertRollback( &$s, &$rc ) {
431 if( !$rc->mAttribs
['rc_new'] && $rc->mAttribs
['rc_this_oldid'] && $rc->mAttribs
['rc_cur_id'] ) {
432 $page = $rc->getTitle();
433 /** Check for rollback and edit permissions, disallow special pages, and only
434 * show a link on the top-most revision */
435 if ($wgUser->isAllowed('rollback') && $rc->mAttribs
['page_latest'] == $rc->mAttribs
['rc_this_oldid'] )
437 $rev = new Revision( array(
438 'id' => $rc->mAttribs
['rc_this_oldid'],
439 'user' => $rc->mAttribs
['rc_user'],
440 'user_text' => $rc->mAttribs
['rc_user_text'],
441 'deleted' => $rc->mAttribs
['rc_deleted']
443 $rev->setTitle( $page );
444 $s .= ' '.$this->skin
->generateRollback( $rev );
449 public function insertTags( &$s, &$rc, &$classes ) {
450 if ( empty($rc->mAttribs
['ts_tags']) )
453 list($tagSummary, $newClasses) = ChangeTags
::formatSummaryRow( $rc->mAttribs
['ts_tags'], 'changeslist' );
454 $classes = array_merge( $classes, $newClasses );
455 $s .= ' ' . $tagSummary;
458 public function insertExtra( &$s, &$rc, &$classes ) {
459 ## Empty, used for subclassers to add anything special.
465 * Generate a list of changes using the good old system (no javascript)
467 class OldChangesList
extends ChangesList
{
469 * Format a line using the old system (aka without any javascript).
471 public function recentChangesLine( &$rc, $watched = false, $linenumber = NULL ) {
472 global $wgLang, $wgRCShowChangedSize, $wgUser;
473 wfProfileIn( __METHOD__
);
474 # Should patrol-related stuff be shown?
475 $unpatrolled = $wgUser->useRCPatrol() && !$rc->mAttribs
['rc_patrolled'];
477 $dateheader = ''; // $s now contains only <li>...</li>, for hooks' convenience.
478 $this->insertDateHeader( $dateheader, $rc->mAttribs
['rc_timestamp'] );
482 // use mw-line-even/mw-line-odd class only if linenumber is given (feature from bug 14468)
484 if( $linenumber & 1 ) {
485 $classes[] = 'mw-line-odd';
488 $classes[] = 'mw-line-even';
493 if( $rc->mAttribs
['rc_type'] == RC_MOVE ||
$rc->mAttribs
['rc_type'] == RC_MOVE_OVER_REDIRECT
) {
494 $this->insertMove( $s, $rc );
496 } elseif( $rc->mAttribs
['rc_log_type'] ) {
497 $logtitle = Title
::newFromText( 'Log/'.$rc->mAttribs
['rc_log_type'], NS_SPECIAL
);
498 $this->insertLog( $s, $logtitle, $rc->mAttribs
['rc_log_type'] );
499 // Log entries (old format) or log targets, and special pages
500 } elseif( $rc->mAttribs
['rc_namespace'] == NS_SPECIAL
) {
501 list( $name, $subpage ) = SpecialPage
::resolveAliasWithSubpage( $rc->mAttribs
['rc_title'] );
502 if( $name == 'Log' ) {
503 $this->insertLog( $s, $rc->getTitle(), $subpage );
507 $this->insertDiffHist( $s, $rc, $unpatrolled );
508 # M, N, b and ! (minor, new, bot and unpatrolled)
509 $s .= $this->recentChangesFlags( $rc->mAttribs
['rc_new'], $rc->mAttribs
['rc_minor'],
510 $unpatrolled, '', $rc->mAttribs
['rc_bot'] );
511 $this->insertArticleLink( $s, $rc, $unpatrolled, $watched );
514 $this->insertTimestamp( $s, $rc );
515 # Bytes added or removed
516 if( $wgRCShowChangedSize ) {
517 $cd = $rc->getCharacterDifference();
523 $this->insertUserRelatedLinks( $s, $rc );
524 # Log action text (if any)
525 $this->insertAction( $s, $rc );
526 # Edit or log comment
527 $this->insertComment( $s, $rc );
529 $this->insertTags( $s, $rc, $classes );
531 $this->insertRollback( $s, $rc );
533 $this->insertExtra( $s, $rc, $classes );
535 # How many users watch this page
536 if( $rc->numberofWatchingusers
> 0 ) {
537 $s .= ' ' . wfMsgExt( 'number_of_watching_users_RCview',
538 array( 'parsemag', 'escape' ), $wgLang->formatNum( $rc->numberofWatchingusers
) );
541 if( $this->watchlist
) {
542 $classes[] = Sanitizer
::escapeClass( 'watchlist-'.$rc->mAttribs
['rc_namespace'].'-'.$rc->mAttribs
['rc_title'] );
545 wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) );
547 wfProfileOut( __METHOD__
);
548 return "$dateheader<li class=\"".implode( ' ', $classes )."\">".$s."</li>\n";
554 * Generate a list of changes using an Enhanced system (uses javascript).
556 class EnhancedChangesList
extends ChangesList
{
558 * Add the JavaScript file for enhanced changeslist
561 public function beginRecentChangesList() {
562 global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
563 $this->rc_cache
= array();
564 $this->rcMoveIndex
= 0;
565 $this->rcCacheIndex
= 0;
566 $this->lastdate
= '';
567 $this->rclistOpen
= false;
568 $script = Xml
::tags( 'script', array(
569 'type' => $wgJsMimeType,
570 'src' => $wgStylePath . "/common/enhancedchanges.js?$wgStyleVersion" ), '' );
574 * Format a line for enhanced recentchange (aka with javascript and block of lines).
576 public function recentChangesLine( &$baseRC, $watched = false ) {
577 global $wgLang, $wgUser;
579 wfProfileIn( __METHOD__
);
581 # Create a specialised object
582 $rc = RCCacheEntry
::newFromParent( $baseRC );
584 # Extract fields from DB into the function scope (rc_xxxx variables)
585 // FIXME: Would be good to replace this extract() call with something
586 // that explicitly initializes variables.
587 extract( $rc->mAttribs
);
588 $curIdEq = array( 'curid' => $rc_cur_id );
590 # If it's a new day, add the headline and flush the cache
591 $date = $wgLang->date( $rc_timestamp, true );
593 if( $date != $this->lastdate
) {
594 # Process current cache
595 $ret = $this->recentChangesBlock();
596 $this->rc_cache
= array();
597 $ret .= Xml
::element( 'h4', null, $date );
598 $this->lastdate
= $date;
601 # Should patrol-related stuff be shown?
602 if( $wgUser->useRCPatrol() ) {
603 $rc->unpatrolled
= !$rc_patrolled;
605 $rc->unpatrolled
= false;
608 $showdifflinks = true;
611 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
612 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
613 $clink = wfMsg( $msg, $this->skin
->linkKnown( $rc->getTitle(), null,
614 array(), array( 'redirect' => 'no' ) ),
615 $this->skin
->linkKnown( $rc->getMovedToTitle() ) );
616 // New unpatrolled pages
617 } else if( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
618 $clink = $this->skin
->linkKnown( $rc->getTitle(), null, array(),
619 array( 'rcid' => $rc_id ) );
621 } else if( $rc_type == RC_LOG
) {
623 $logtitle = SpecialPage
::getTitleFor( 'Log', $rc_log_type );
624 $clink = '(' . $this->skin
->linkKnown( $logtitle,
625 LogPage
::logName($rc_log_type) ) . ')';
627 $clink = $this->skin
->link( $rc->getTitle() );
630 // Log entries (old format) and special pages
631 } elseif( $rc_namespace == NS_SPECIAL
) {
632 list( $specialName, $logtype ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
633 if ( $specialName == 'Log' ) {
635 $logname = LogPage
::logName( $logtype );
636 $clink = '(' . $this->skin
->linkKnown( $rc->getTitle(), $logname ) . ')';
638 wfDebug( "Unexpected special page in recentchanges\n" );
643 $clink = $this->skin
->linkKnown( $rc->getTitle() );
646 # Don't show unusable diff links
647 if ( !ChangesList
::userCan($rc,Revision
::DELETED_TEXT
) ) {
648 $showdifflinks = false;
651 $time = $wgLang->time( $rc_timestamp, true, true );
652 $rc->watched
= $watched;
654 $rc->timestamp
= $time;
655 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
657 # Make "cur" and "diff" links. Do not use link(), it is too slow if
658 # called too many times (50% of CPU time on RecentChanges!).
659 if( $rc->unpatrolled
) {
660 $rcIdQuery = array( 'rcid' => $rc_id );
662 $rcIdQuery = array();
664 $querycur = $curIdEq +
array( 'diff' => '0', 'oldid' => $rc_this_oldid );
665 $querydiff = $curIdEq +
array( 'diff' => $rc_this_oldid, 'oldid' =>
666 $rc_last_oldid ) +
$rcIdQuery;
668 if( !$showdifflinks ) {
669 $curLink = $this->message
['cur'];
670 $diffLink = $this->message
['diff'];
671 } else if( in_array( $rc_type, array(RC_NEW
,RC_LOG
,RC_MOVE
,RC_MOVE_OVER_REDIRECT
) ) ) {
672 if ( $rc_type != RC_NEW
) {
673 $curLink = $this->message
['cur'];
675 $curUrl = htmlspecialchars( $rc->getTitle()->getLinkUrl( $querycur ) );
676 $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
678 $diffLink = $this->message
['diff'];
680 $diffUrl = htmlspecialchars( $rc->getTitle()->getLinkUrl( $querydiff ) );
681 $curUrl = htmlspecialchars( $rc->getTitle()->getLinkUrl( $querycur ) );
682 $diffLink = "<a href=\"$diffUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['diff']}</a>";
683 $curLink = "<a href=\"$curUrl\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
687 if( !$showdifflinks ||
!$rc_last_oldid ) {
688 $lastLink = $this->message
['last'];
689 } else if( $rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
690 $lastLink = $this->message
['last'];
692 $lastLink = $this->skin
->linkKnown( $rc->getTitle(), $this->message
['last'],
693 array(), $curIdEq +
array('diff' => $rc_this_oldid, 'oldid' => $rc_last_oldid) +
$rcIdQuery );
697 if( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
698 $rc->userlink
= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
700 $rc->userlink
= $this->skin
->userLink( $rc_user, $rc_user_text );
701 $rc->usertalklink
= $this->skin
->userToolLinks( $rc_user, $rc_user_text );
704 $rc->lastlink
= $lastLink;
705 $rc->curlink
= $curLink;
706 $rc->difflink
= $diffLink;
708 # Put accumulated information into the cache, for later display
709 # Page moves go on their own line
710 $title = $rc->getTitle();
711 $secureName = $title->getPrefixedDBkey();
712 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
713 # Use an @ character to prevent collision with page names
714 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
716 # Logs are grouped by type
717 if( $rc_type == RC_LOG
){
718 $secureName = SpecialPage
::getTitleFor( 'Log', $rc_log_type )->getPrefixedDBkey();
720 if( !isset( $this->rc_cache
[$secureName] ) ) {
721 $this->rc_cache
[$secureName] = array();
724 array_push( $this->rc_cache
[$secureName], $rc );
727 wfProfileOut( __METHOD__
);
735 protected function recentChangesBlockGroup( $block ) {
736 global $wgLang, $wgContLang, $wgRCShowChangedSize;
738 wfProfileIn( __METHOD__
);
740 $r = '<table cellpadding="0" cellspacing="0" border="0" style="background: none"><tr>';
742 # Collate list of users
743 $userlinks = array();
745 $unpatrolled = false;
747 $curId = $currentRevision = 0;
748 # Some catalyst variables...
751 foreach( $block as $rcObj ) {
752 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
753 if( $rcObj->mAttribs
['rc_new'] ) {
756 // If all log actions to this page were hidden, then don't
757 // give the name of the affected page for this block!
758 if( !$this->isDeleted( $rcObj, LogPage
::DELETED_ACTION
) ) {
761 $u = $rcObj->userlink
;
762 if( !isset( $userlinks[$u] ) ) {
765 if( $rcObj->unpatrolled
) {
768 if( $rcObj->mAttribs
['rc_type'] != RC_LOG
) {
771 # Get the latest entry with a page_id and oldid
772 # since logs may not have these.
773 if( !$curId && $rcObj->mAttribs
['rc_cur_id'] ) {
774 $curId = $rcObj->mAttribs
['rc_cur_id'];
776 if( !$currentRevision && $rcObj->mAttribs
['rc_this_oldid'] ) {
777 $currentRevision = $rcObj->mAttribs
['rc_this_oldid'];
780 $bot = $rcObj->mAttribs
['rc_bot'];
784 # Sort the list and convert to text
785 krsort( $userlinks );
788 foreach( $userlinks as $userlink => $count) {
790 $text .= $wgContLang->getDirMark();
792 $text .= ' (' . $wgLang->formatNum( $count ) . '×)';
794 array_push( $users, $text );
797 $users = ' <span class="changedby">[' .
798 implode( $this->message
['semicolon-separator'], $users ) . ']</span>';
800 # ID for JS visibility toggle
801 $jsid = $this->rcCacheIndex
;
802 # onclick handler to toggle hidden/expanded
803 $toggleLink = "onclick='toggleVisibility($jsid); return false'";
805 $expandTitle = htmlspecialchars( wfMsg( 'rc-enhanced-expand' ) );
806 $closeTitle = htmlspecialchars( wfMsg( 'rc-enhanced-hide' ) );
808 $tl = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
809 $tl .= "<span id='mw-rc-closearrow-$jsid' class='mw-changeslist-hidden' style='display:none'><a href='#' $toggleLink title='$closeTitle'>" . $this->downArrow() . "</a></span>";
810 $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.' ';
813 $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot );
816 $r .= ' '.$block[0]->timestamp
.' </tt></td><td>';
820 $r .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
821 } else if( $allLogs ) {
822 $r .= $this->maybeWatchedLink( $block[0]->link
, $block[0]->watched
);
824 $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled
, $block[0]->watched
);
827 $r .= $wgContLang->getDirMark();
829 $queryParams['curid'] = $curId;
832 static $nchanges = array();
833 if ( !isset( $nchanges[$n] ) ) {
834 $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) );
840 if( !ChangesList
::userCan( $rcObj, Revision
::DELETED_TEXT
) ) {
842 } else if( $isnew ) {
845 $params = $queryParams;
846 $params['diff'] = $currentRevision;
847 $params['oldid'] = $oldid;
849 $r .= $this->skin
->link(
850 $block[0]->getTitle(),
854 array( 'known', 'noclasses' )
861 // don't show history link for logs
862 } else if( $namehidden ||
!$block[0]->getTitle()->exists() ) {
863 $r .= $this->message
['pipe-separator'] . $this->message
['hist'] . ')';
865 $params = $queryParams;
866 $params['action'] = 'history';
868 $r .= $this->message
['pipe-separator'] .
870 $block[0]->getTitle(),
871 $this->message
['hist'],
874 array( 'known', 'noclasses' )
879 # Character difference (does not apply if only log items)
880 if( $wgRCShowChangedSize && !$allLogs ) {
882 $first = count($block) - 1;
883 # Some events (like logs) have an "empty" size, so we need to skip those...
884 while( $last < $first && $block[$last]->mAttribs
['rc_new_len'] === NULL ) {
887 while( $first > $last && $block[$first]->mAttribs
['rc_old_len'] === NULL ) {
891 $chardiff = $rcObj->getCharacterDifference( $block[$first]->mAttribs
['rc_old_len'],
892 $block[$last]->mAttribs
['rc_new_len'] );
894 if( $chardiff == '' ) {
897 $r .= ' ' . $chardiff. ' . . ';
902 $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers
);
904 $r .= "</td></tr></table>\n";
907 $r .= '<div id="mw-rc-subentries-'.$jsid.'" class="mw-changeslist-hidden">';
908 $r .= '<table cellpadding="0" cellspacing="0" border="0" style="background: none">';
909 foreach( $block as $rcObj ) {
910 # Extract fields from DB into the function scope (rc_xxxx variables)
911 // FIXME: Would be good to replace this extract() call with something
912 // that explicitly initializes variables.
913 # Classes to apply -- TODO implement
915 extract( $rcObj->mAttribs
);
917 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
918 $r .= '<tr><td valign="top">';
919 $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
920 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
921 $r .= ' </tt></td><td valign="top">';
923 $params = $queryParams;
925 if( $rc_this_oldid != 0 ) {
926 $params['oldid'] = $rc_this_oldid;
930 if( $rc_type == RC_LOG
) {
931 $link = '<tt>'.$rcObj->timestamp
.'</tt> ';
933 } else if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
934 $link = '<span class="history-deleted"><tt>'.$rcObj->timestamp
.'</tt></span> ';
936 if ( $rcObj->unpatrolled
&& $rc_type == RC_NEW
) {
937 $params['rcid'] = $rcObj->mAttribs
['rc_id'];
946 array( 'known', 'noclasses' )
948 if( $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) )
949 $link = '<span class="history-deleted">'.$link.'</span> ';
953 if ( !$rc_type == RC_LOG ||
$rc_type == RC_NEW
) {
955 $r .= $rcObj->curlink
;
956 $r .= $this->message
['pipe-separator'];
957 $r .= $rcObj->lastlink
;
963 if( $wgRCShowChangedSize ) {
964 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : $rcObj->getCharacterDifference() . ' . . ' ) ;
967 $r .= $rcObj->userlink
;
968 $r .= $rcObj->usertalklink
;
970 $this->insertAction( $r, $rcObj );
972 $this->insertComment( $r, $rcObj );
974 $this->insertRollback( $r, $rcObj );
976 $this->insertTags( $r, $rcObj, $classes );
978 $r .= "</td></tr>\n";
980 $r .= "</table></div>\n";
982 $this->rcCacheIndex++
;
984 wfProfileOut( __METHOD__
);
990 * Generate HTML for an arrow or placeholder graphic
991 * @param string $dir one of '', 'd', 'l', 'r'
992 * @param string $alt text
993 * @param string $title text
994 * @return string HTML <img> tag
996 protected function arrow( $dir, $alt='', $title='' ) {
998 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
999 $encAlt = htmlspecialchars( $alt );
1000 $encTitle = htmlspecialchars( $title );
1001 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
1005 * Generate HTML for a right- or left-facing arrow,
1006 * depending on language direction.
1007 * @return string HTML <img> tag
1009 protected function sideArrow() {
1011 $dir = $wgContLang->isRTL() ?
'l' : 'r';
1012 return $this->arrow( $dir, '+', wfMsg( 'rc-enhanced-expand' ) );
1016 * Generate HTML for a down-facing arrow
1017 * depending on language direction.
1018 * @return string HTML <img> tag
1020 protected function downArrow() {
1021 return $this->arrow( 'd', '-', wfMsg( 'rc-enhanced-hide' ) );
1025 * Generate HTML for a spacer image
1026 * @return string HTML <img> tag
1028 protected function spacerArrow() {
1029 return $this->arrow( '', codepointToUtf8( 0xa0 ) ); // non-breaking space
1033 * Add a set of spaces
1034 * @return string HTML <td> tag
1036 protected function spacerIndent() {
1037 return ' ';
1041 * Enhanced RC ungrouped line.
1042 * @return string a HTML formated line (generated using $r)
1044 protected function recentChangesBlockLine( $rcObj ) {
1045 global $wgRCShowChangedSize;
1047 wfProfileIn( __METHOD__
);
1049 # Extract fields from DB into the function scope (rc_xxxx variables)
1050 // FIXME: Would be good to replace this extract() call with something
1051 // that explicitly initializes variables.
1052 $classes = array(); // TODO implement
1053 extract( $rcObj->mAttribs
);
1054 $query['curid'] = $rc_cur_id;
1056 $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>';
1057 $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . ' ';
1058 # Flag and Timestamp
1059 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
1060 $r .= ' '; // 4 flags -> 4 spaces
1062 $r .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
1064 $r .= ' '.$rcObj->timestamp
.' </tt></td><td>';
1065 # Article or log link
1066 if( $rc_log_type ) {
1067 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
1068 $logname = LogPage
::logName( $rc_log_type );
1069 $r .= '(' . $this->skin
->link(
1074 array( 'known', 'noclasses' )
1077 $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled
, $rcObj->watched
);
1079 # Diff and hist links
1080 if ( $rc_type != RC_LOG
) {
1081 $r .= ' ('. $rcObj->difflink
. $this->message
['pipe-separator'];
1082 $query['action'] = 'history';
1083 $r .= $this->skin
->link(
1085 $this->message
['hist'],
1088 array( 'known', 'noclasses' )
1093 if( $wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference()) ) {
1097 $r .= ' '.$rcObj->userlink
. $rcObj->usertalklink
;
1098 # Log action (if any)
1099 if( $rc_log_type ) {
1100 if( $this->isDeleted($rcObj,LogPage
::DELETED_ACTION
) ) {
1101 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
1103 $r .= ' ' . LogPage
::actionText( $rc_log_type, $rc_log_action, $rcObj->getTitle(),
1104 $this->skin
, LogPage
::extractParams($rc_params), true, true );
1107 $this->insertComment( $r, $rcObj );
1108 $this->insertRollback( $r, $rcObj );
1110 $this->insertTags( $r, $rcObj, $classes );
1111 # Show how many people are watching this if enabled
1112 $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers
);
1114 $r .= "</td></tr></table>\n";
1116 wfProfileOut( __METHOD__
);
1122 * If enhanced RC is in use, this function takes the previously cached
1123 * RC lines, arranges them, and outputs the HTML
1125 protected function recentChangesBlock() {
1126 if( count ( $this->rc_cache
) == 0 ) {
1130 wfProfileIn( __METHOD__
);
1133 foreach( $this->rc_cache
as $block ) {
1134 if( count( $block ) < 2 ) {
1135 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
1137 $blockOut .= $this->recentChangesBlockGroup( $block );
1141 wfProfileOut( __METHOD__
);
1143 return '<div>'.$blockOut.'</div>';
1147 * Returns text for the end of RC
1148 * If enhanced RC is in use, returns pretty much all the text
1150 public function endRecentChangesList() {
1151 return $this->recentChangesBlock() . parent
::endRecentChangesList();