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;
110 $szdiff = $new - $old;
111 $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape' ), $wgLang->formatNum( $szdiff ) );
112 if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
117 if( $szdiff === 0 ) {
118 return "<$tag class='mw-plusminus-null'>($formatedSize)</$tag>";
119 } elseif( $szdiff > 0 ) {
120 return "<$tag class='mw-plusminus-pos'>(+$formatedSize)</$tag>";
122 return "<$tag class='mw-plusminus-neg'>($formatedSize)</$tag>";
127 * Returns text for the end of RC
130 public function endRecentChangesList() {
131 if( $this->rclistOpen ) {
138 protected function insertMove( &$s, $rc ) {
140 $s .= '(' . $this->message['diff'] . ') (';
142 $s .= $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), $this->message['hist'],
143 'action=history' ) . ') . . ';
144 # "[[x]] moved to [[y]]"
145 $msg = ( $rc->mAttribs['rc_type'] == RC_MOVE ) ? '1movedto2' : '1movedto2_redir';
146 $s .= wfMsg( $msg, $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
147 $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
150 protected function insertDateHeader( &$s, $rc_timestamp ) {
152 # Make date header if necessary
153 $date = $wgLang->date( $rc_timestamp, true, true );
154 if( $date != $this->lastdate ) {
155 if( '' != $this->lastdate ) {
158 $s .= '<h4>'.$date."</h4>\n<ul class=\"special\">";
159 $this->lastdate = $date;
160 $this->rclistOpen = true;
164 protected function insertLog( &$s, $title, $logtype ) {
165 $logname = LogPage::logName( $logtype );
166 $s .= '(' . $this->skin->makeKnownLinkObj($title, $logname ) . ')';
169 protected function insertDiffHist( &$s, &$rc, $unpatrolled ) {
171 if( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) {
172 $diffLink = $this->message['diff'];
173 } else if( !$this->userCan($rc,Revision::DELETED_TEXT) ) {
174 $diffLink = $this->message['diff'];
176 $rcidparam = $unpatrolled ? array( 'rcid' => $rc->mAttribs['rc_id'] ) : array();
177 $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'],
179 'curid' => $rc->mAttribs['rc_cur_id'],
180 'diff' => $rc->mAttribs['rc_this_oldid'],
181 'oldid' => $rc->mAttribs['rc_last_oldid'] ),
183 '', '', ' tabindex="'.$rc->counter.'"');
185 $s .= '('.$diffLink.') (';
187 $s .= $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['hist'],
189 'curid' => $rc->mAttribs['rc_cur_id'],
190 'action' => 'history' ) ) );
194 protected function insertArticleLink( &$s, &$rc, $unpatrolled, $watched ) {
196 # If it's a new article, there is no diff link, but if it hasn't been
197 # patrolled yet, we need to give users a way to do so
198 $params = ( $unpatrolled && $rc->mAttribs['rc_type'] == RC_NEW ) ?
199 'rcid='.$rc->mAttribs['rc_id'] : '';
200 if( $this->isDeleted($rc,Revision::DELETED_TEXT) ) {
201 $articlelink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '', $params );
202 $articlelink = '<span class="history-deleted">'.$articlelink.'</span>';
204 $articlelink = ' '. $this->skin->makeKnownLinkObj( $rc->getTitle(), '', $params );
206 # Bolden pages watched by this user
208 $articlelink = "<strong class=\"mw-watched\">{$articlelink}</strong>";
211 $articlelink .= $wgContLang->getDirMark();
213 wfRunHooks( 'ChangesListInsertArticleLink',
214 array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched) );
216 $s .= " $articlelink";
219 protected function insertTimestamp( &$s, $rc ) {
221 $s .= $this->message['semicolon-separator'] .
222 $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . ';
225 /** Insert links to user page, user talk page and eventually a blocking link */
226 public function insertUserRelatedLinks( &$s, &$rc ) {
227 if( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
228 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
230 $s .= $this->skin->userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
231 $s .= $this->skin->userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
235 /** insert a formatted action */
236 protected function insertAction( &$s, &$rc ) {
237 if( $rc->mAttribs['rc_type'] == RC_LOG ) {
238 if( $this->isDeleted( $rc, LogPage::DELETED_ACTION ) ) {
239 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
241 $s .= ' '.LogPage::actionText( $rc->mAttribs['rc_log_type'], $rc->mAttribs['rc_log_action'],
242 $rc->getTitle(), $this->skin, LogPage::extractParams( $rc->mAttribs['rc_params'] ), true, true );
247 /** insert a formatted comment */
248 protected function insertComment( &$s, &$rc ) {
249 if( $rc->mAttribs['rc_type'] != RC_MOVE && $rc->mAttribs['rc_type'] != RC_MOVE_OVER_REDIRECT ) {
250 if( $this->isDeleted( $rc, Revision::DELETED_COMMENT ) ) {
251 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span>';
253 $s .= $this->skin->commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
259 * Check whether to enable recent changes patrol features
262 public static function usePatrol() {
264 return $wgUser->useRCPatrol();
268 * Returns the string which indicates the number of watching users
270 protected function numberofWatchingusers( $count ) {
272 static $cache = array();
274 if( !isset( $cache[$count] ) ) {
275 $cache[$count] = wfMsgExt( 'number_of_watching_users_RCview',
276 array('parsemag', 'escape' ), $wgLang->formatNum( $count ) );
278 return $cache[$count];
285 * Determine if said field of a revision is hidden
286 * @param RCCacheEntry $rc
287 * @param int $field one of DELETED_* bitfield constants
290 public static function isDeleted( $rc, $field ) {
291 return ( $rc->mAttribs['rc_deleted'] & $field ) == $field;
295 * Determine if the current user is allowed to view a particular
296 * field of this revision, if it's marked as deleted.
297 * @param RCCacheEntry $rc
301 public static function userCan( $rc, $field ) {
302 if( ( $rc->mAttribs['rc_deleted'] & $field ) == $field ) {
304 $permission = ( $rc->mAttribs['rc_deleted'] & Revision::DELETED_RESTRICTED ) == Revision::DELETED_RESTRICTED
307 wfDebug( "Checking for $permission due to $field match on {$rc->mAttribs['rc_deleted']}\n" );
308 return $wgUser->isAllowed( $permission );
314 protected function maybeWatchedLink( $link, $watched=false ) {
316 return '<strong class="mw-watched">' . $link . '</strong>';
318 return '<span class="mw-rc-unwatched">' . $link . '</span>';
322 /** Inserts a rollback link */
323 protected function insertRollback( &$s, &$rc ) {
325 if( !$rc->mAttribs['rc_new'] && $rc->mAttribs['rc_this_oldid'] && $rc->mAttribs['rc_cur_id'] ) {
326 $page = $rc->getTitle();
327 /** Check for rollback and edit permissions, disallow special pages, and only
328 * show a link on the top-most revision */
329 if ($wgUser->isAllowed('rollback') && $rc->mAttribs['page_latest'] == $rc->mAttribs['rc_this_oldid'] )
331 $rev = new Revision( array(
332 'id' => $rc->mAttribs['rc_this_oldid'],
333 'user' => $rc->mAttribs['rc_user'],
334 'user_text' => $rc->mAttribs['rc_user_text'],
335 'deleted' => $rc->mAttribs['rc_deleted']
337 $rev->setTitle( $page );
338 $s .= ' '.$this->skin->generateRollback( $rev );
343 protected function insertTags( &$s, &$rc, &$classes ) {
344 if ( empty($rc->mAttribs['ts_tags']) )
347 list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $rc->mAttribs['ts_tags'], 'changeslist' );
348 $classes = array_merge( $classes, $newClasses );
349 $s .= ' ' . $tagSummary;
352 protected function insertExtra( &$s, &$rc, &$classes ) {
353 ## Empty, used for subclassers to add anything special.
359 * Generate a list of changes using the good old system (no javascript)
361 class OldChangesList extends ChangesList {
363 * Format a line using the old system (aka without any javascript).
365 public function recentChangesLine( &$rc, $watched = false, $linenumber = NULL ) {
366 global $wgContLang, $wgLang, $wgRCShowChangedSize, $wgUser;
367 wfProfileIn( __METHOD__ );
368 # Should patrol-related stuff be shown?
369 $unpatrolled = $wgUser->useRCPatrol() && !$rc->mAttribs['rc_patrolled'];
371 $dateheader = ''; // $s now contains only <li>...</li>, for hooks' convenience.
372 $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
376 // use mw-line-even/mw-line-odd class only if linenumber is given (feature from bug 14468)
378 if( $linenumber & 1 ) {
379 $classes[] = 'mw-line-odd';
382 $classes[] = 'mw-line-even';
387 if( $rc->mAttribs['rc_type'] == RC_MOVE || $rc->mAttribs['rc_type'] == RC_MOVE_OVER_REDIRECT ) {
388 $this->insertMove( $s, $rc );
390 } elseif( $rc->mAttribs['rc_log_type'] ) {
391 $logtitle = Title::newFromText( 'Log/'.$rc->mAttribs['rc_log_type'], NS_SPECIAL );
392 $this->insertLog( $s, $logtitle, $rc->mAttribs['rc_log_type'] );
393 // Log entries (old format) or log targets, and special pages
394 } elseif( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
395 list( $name, $subpage ) = SpecialPage::resolveAliasWithSubpage( $rc->mAttribs['rc_title'] );
396 if( $name == 'Log' ) {
397 $this->insertLog( $s, $rc->getTitle(), $subpage );
401 $this->insertDiffHist( $s, $rc, $unpatrolled );
402 # M, N, b and ! (minor, new, bot and unpatrolled)
403 $s .= $this->recentChangesFlags( $rc->mAttribs['rc_new'], $rc->mAttribs['rc_minor'],
404 $unpatrolled, '', $rc->mAttribs['rc_bot'] );
405 $this->insertArticleLink( $s, $rc, $unpatrolled, $watched );
408 $this->insertTimestamp( $s, $rc );
409 # Bytes added or removed
410 if( $wgRCShowChangedSize ) {
411 $cd = $rc->getCharacterDifference();
417 $this->insertUserRelatedLinks( $s, $rc );
418 # Log action text (if any)
419 $this->insertAction( $s, $rc );
420 # Edit or log comment
421 $this->insertComment( $s, $rc );
423 $this->insertTags( $s, $rc, $classes );
425 $this->insertRollback( $s, $rc );
427 $this->insertExtra( $s, $rc, $classes );
429 # Mark revision as deleted if so
430 if( !$rc->mAttribs['rc_log_type'] && $this->isDeleted($rc,Revision::DELETED_TEXT) ) {
431 $s .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
433 # How many users watch this page
434 if( $rc->numberofWatchingusers > 0 ) {
435 $s .= ' ' . wfMsgExt( 'number_of_watching_users_RCview',
436 array( 'parsemag', 'escape' ), $wgLang->formatNum( $rc->numberofWatchingusers ) );
439 wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) );
441 wfProfileOut( __METHOD__ );
442 return "$dateheader<li class=\"".implode( ' ', $classes )."\">$s</li>\n";
448 * Generate a list of changes using an Enhanced system (uses javascript).
450 class EnhancedChangesList extends ChangesList {
452 * Add the JavaScript file for enhanced changeslist
455 public function beginRecentChangesList() {
456 global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
457 $this->rc_cache = array();
458 $this->rcMoveIndex = 0;
459 $this->rcCacheIndex = 0;
460 $this->lastdate = '';
461 $this->rclistOpen = false;
462 $script = Xml::tags( 'script', array(
463 'type' => $wgJsMimeType,
464 'src' => $wgStylePath . "/common/enhancedchanges.js?$wgStyleVersion" ), '' );
468 * Format a line for enhanced recentchange (aka with javascript and block of lines).
470 public function recentChangesLine( &$baseRC, $watched = false ) {
471 global $wgLang, $wgContLang, $wgUser;
473 wfProfileIn( __METHOD__ );
475 # Create a specialised object
476 $rc = RCCacheEntry::newFromParent( $baseRC );
478 # Extract fields from DB into the function scope (rc_xxxx variables)
479 // FIXME: Would be good to replace this extract() call with something
480 // that explicitly initializes variables.
481 extract( $rc->mAttribs );
482 $curIdEq = 'curid=' . $rc_cur_id;
484 # If it's a new day, add the headline and flush the cache
485 $date = $wgLang->date( $rc_timestamp, true );
487 if( $date != $this->lastdate ) {
488 # Process current cache
489 $ret = $this->recentChangesBlock();
490 $this->rc_cache = array();
491 $ret .= "<h4>{$date}</h4>\n";
492 $this->lastdate = $date;
495 # Should patrol-related stuff be shown?
496 if( $wgUser->useRCPatrol() ) {
497 $rc->unpatrolled = !$rc_patrolled;
499 $rc->unpatrolled = false;
502 $showdifflinks = true;
505 if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
506 $msg = ( $rc_type == RC_MOVE ) ? "1movedto2" : "1movedto2_redir";
507 $clink = wfMsg( $msg, $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
508 $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
509 // New unpatrolled pages
510 } else if( $rc->unpatrolled && $rc_type == RC_NEW ) {
511 $clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
513 } else if( $rc_type == RC_LOG ) {
515 $logtitle = SpecialPage::getTitleFor( 'Log', $rc_log_type );
516 $clink = '(' . $this->skin->makeKnownLinkObj( $logtitle,
517 LogPage::logName($rc_log_type) ) . ')';
519 $clink = $this->skin->makeLinkObj( $rc->getTitle(), '' );
522 // Log entries (old format) and special pages
523 } elseif( $rc_namespace == NS_SPECIAL ) {
524 list( $specialName, $logtype ) = SpecialPage::resolveAliasWithSubpage( $rc_title );
525 if ( $specialName == 'Log' ) {
527 $logname = LogPage::logName( $logtype );
528 $clink = '(' . $this->skin->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
530 wfDebug( "Unexpected special page in recentchanges\n" );
535 $clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '' );
538 # Don't show unusable diff links
539 if ( !ChangesList::userCan($rc,Revision::DELETED_TEXT) ) {
540 $showdifflinks = false;
543 $time = $wgContLang->time( $rc_timestamp, true, true );
544 $rc->watched = $watched;
546 $rc->timestamp = $time;
547 $rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
549 # Make "cur" and "diff" links
550 if( $rc->unpatrolled ) {
551 $rcIdQuery = "&rcid={$rc_id}";
555 $querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid";
556 $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery";
557 $aprops = ' tabindex="'.$baseRC->counter.'"';
558 $curLink = $this->skin->makeKnownLinkObj( $rc->getTitle(),
559 $this->message['cur'], $querycur, '' ,'', $aprops );
561 # Make "diff" an "cur" links
562 if( !$showdifflinks ) {
563 $curLink = $this->message['cur'];
564 $diffLink = $this->message['diff'];
565 } else if( in_array( $rc_type, array(RC_NEW,RC_LOG,RC_MOVE,RC_MOVE_OVER_REDIRECT) ) ) {
566 $curLink = ($rc_type != RC_NEW) ? $this->message['cur'] : $curLink;
567 $diffLink = $this->message['diff'];
569 $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'],
570 $querydiff, '' ,'', $aprops );
574 if( !$showdifflinks || !$rc_last_oldid ) {
575 $lastLink = $this->message['last'];
576 } else if( $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
577 $lastLink = $this->message['last'];
579 $lastLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['last'],
580 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
584 if( $this->isDeleted($rc,Revision::DELETED_USER) ) {
585 $rc->userlink = ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
587 $rc->userlink = $this->skin->userLink( $rc_user, $rc_user_text );
588 $rc->usertalklink = $this->skin->userToolLinks( $rc_user, $rc_user_text );
591 $rc->lastlink = $lastLink;
592 $rc->curlink = $curLink;
593 $rc->difflink = $diffLink;
595 # Put accumulated information into the cache, for later display
596 # Page moves go on their own line
597 $title = $rc->getTitle();
598 $secureName = $title->getPrefixedDBkey();
599 if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
600 # Use an @ character to prevent collision with page names
601 $this->rc_cache['@@' . ($this->rcMoveIndex++)] = array($rc);
603 # Logs are grouped by type
604 if( $rc_type == RC_LOG ){
605 $secureName = SpecialPage::getTitleFor( 'Log', $rc_log_type )->getPrefixedDBkey();
607 if( !isset( $this->rc_cache[$secureName] ) ) {
608 $this->rc_cache[$secureName] = array();
611 array_push( $this->rc_cache[$secureName], $rc );
614 wfProfileOut( __METHOD__ );
622 protected function recentChangesBlockGroup( $block ) {
623 global $wgLang, $wgContLang, $wgRCShowChangedSize;
625 wfProfileIn( __METHOD__ );
627 $r = '<table cellpadding="0" cellspacing="0" border="0" style="background: none"><tr>';
629 # Collate list of users
630 $userlinks = array();
632 $unpatrolled = false;
634 $curId = $currentRevision = 0;
635 # Some catalyst variables...
638 foreach( $block as $rcObj ) {
639 $oldid = $rcObj->mAttribs['rc_last_oldid'];
640 if( $rcObj->mAttribs['rc_new'] ) {
643 // If all log actions to this page were hidden, then don't
644 // give the name of the affected page for this block!
645 if( !$this->isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) {
648 $u = $rcObj->userlink;
649 if( !isset( $userlinks[$u] ) ) {
652 if( $rcObj->unpatrolled ) {
655 if( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
658 # Get the latest entry with a page_id and oldid
659 # since logs may not have these.
660 if( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
661 $curId = $rcObj->mAttribs['rc_cur_id'];
663 if( !$currentRevision && $rcObj->mAttribs['rc_this_oldid'] ) {
664 $currentRevision = $rcObj->mAttribs['rc_this_oldid'];
667 $bot = $rcObj->mAttribs['rc_bot'];
671 # Sort the list and convert to text
672 krsort( $userlinks );
675 foreach( $userlinks as $userlink => $count) {
677 $text .= $wgContLang->getDirMark();
679 $text .= ' (' . $wgLang->formatNum( $count ) . '×)';
681 array_push( $users, $text );
684 $users = ' <span class="changedby">[' .
685 implode( $this->message['semicolon-separator'], $users ) . ']</span>';
687 # ID for JS visibility toggle
688 $jsid = $this->rcCacheIndex;
689 # onclick handler to toggle hidden/expanded
690 $toggleLink = "onclick='toggleVisibility($jsid); return false'";
692 $expandTitle = htmlspecialchars( wfMsg( 'rc-enhanced-expand' ) );
693 $closeTitle = htmlspecialchars( wfMsg( 'rc-enhanced-hide' ) );
695 $tl = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
696 $tl .= "<span id='mw-rc-closearrow-$jsid' class='mw-changeslist-hidden' style='display:none'><a href='#' $toggleLink title='$closeTitle'>" . $this->downArrow() . "</a></span>";
697 $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.' ';
700 $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot );
703 $r .= ' '.$block[0]->timestamp.' </tt></td><td>';
707 $r .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
708 } else if( $allLogs ) {
709 $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
711 $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled, $block[0]->watched );
714 $r .= $wgContLang->getDirMark();
716 $curIdEq = 'curid=' . $curId;
719 static $nchanges = array();
720 if ( !isset( $nchanges[$n] ) ) {
721 $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) );
727 if( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT ) ) {
729 } else if( $isnew ) {
732 $r .= $this->skin->makeKnownLinkObj( $block[0]->getTitle(),
733 $nchanges[$n], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
739 // don't show history link for logs
740 } else if( $namehidden || !$block[0]->getTitle()->exists() ) {
741 $r .= $this->message['semicolon-separator'] . $this->message['hist'] . ')';
743 $r .= $this->message['semicolon-separator'] . $this->skin->makeKnownLinkObj( $block[0]->getTitle(),
744 $this->message['hist'], $curIdEq . '&action=history' ) . ')';
748 # Character difference (does not apply if only log items)
749 if( $wgRCShowChangedSize && !$allLogs ) {
751 $first = count($block) - 1;
752 # Some events (like logs) have an "empty" size, so we need to skip those...
753 while( $last < $first && $block[$last]->mAttribs['rc_new_len'] === NULL ) {
756 while( $first > $last && $block[$first]->mAttribs['rc_old_len'] === NULL ) {
760 $chardiff = $rcObj->getCharacterDifference( $block[$first]->mAttribs['rc_old_len'],
761 $block[$last]->mAttribs['rc_new_len'] );
763 if( $chardiff == '' ) {
766 $r .= ' ' . $chardiff. ' . . ';
771 $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers);
773 $r .= "</td></tr></table>\n";
776 $r .= '<div id="mw-rc-subentries-'.$jsid.'" class="mw-changeslist-hidden">';
777 $r .= '<table cellpadding="0" cellspacing="0" border="0" style="background: none">';
778 foreach( $block as $rcObj ) {
779 # Extract fields from DB into the function scope (rc_xxxx variables)
780 // FIXME: Would be good to replace this extract() call with something
781 // that explicitly initializes variables.
782 # Classes to apply -- TODO implement
784 extract( $rcObj->mAttribs );
786 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
787 $r .= '<tr><td valign="top">';
788 $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
789 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled, ' ', $rc_bot );
790 $r .= ' </tt></td><td valign="top">';
793 if( $rc_this_oldid != 0 ) {
794 $o = 'oldid='.$rc_this_oldid;
797 if( $rc_type == RC_LOG ) {
798 $link = '<tt>'.$rcObj->timestamp.'</tt> ';
800 } else if( !ChangesList::userCan($rcObj,Revision::DELETED_TEXT) ) {
801 $link = '<span class="history-deleted"><tt>'.$rcObj->timestamp.'</tt></span> ';
803 $rcIdEq = ($rcObj->unpatrolled && $rc_type == RC_NEW) ?
804 '&rcid='.$rcObj->mAttribs['rc_id'] : '';
805 $link = '<tt>'.$this->skin->makeKnownLinkObj( $rcObj->getTitle(),
806 $rcObj->timestamp, $curIdEq.'&'.$o.$rcIdEq ).'</tt>';
807 if( $this->isDeleted($rcObj,Revision::DELETED_TEXT) )
808 $link = '<span class="history-deleted">'.$link.'</span> ';
812 if ( !$rc_type == RC_LOG || $rc_type == RC_NEW ) {
814 $r .= $rcObj->curlink;
815 $r .= $this->message['semicolon-separator'];
816 $r .= $rcObj->lastlink;
822 if( $wgRCShowChangedSize ) {
823 $r .= ( $rcObj->getCharacterDifference() == '' ? '' : $rcObj->getCharacterDifference() . ' . . ' ) ;
826 $r .= $rcObj->userlink;
827 $r .= $rcObj->usertalklink;
829 $this->insertAction( $r, $rcObj );
831 $this->insertComment( $r, $rcObj );
833 $this->insertRollback( $r, $rcObj );
835 $this->insertTags( $r, $rcObj, $classes );
837 # Mark revision as deleted
838 if( !$rc_log_type && $this->isDeleted($rcObj,Revision::DELETED_TEXT) ) {
839 $r .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
842 $r .= "</td></tr>\n";
844 $r .= "</table></div>\n";
846 $this->rcCacheIndex++;
848 wfProfileOut( __METHOD__ );
854 * Generate HTML for an arrow or placeholder graphic
855 * @param string $dir one of '', 'd', 'l', 'r'
856 * @param string $alt text
857 * @param string $title text
858 * @return string HTML <img> tag
860 protected function arrow( $dir, $alt='', $title='' ) {
862 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
863 $encAlt = htmlspecialchars( $alt );
864 $encTitle = htmlspecialchars( $title );
865 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
869 * Generate HTML for a right- or left-facing arrow,
870 * depending on language direction.
871 * @return string HTML <img> tag
873 protected function sideArrow() {
875 $dir = $wgContLang->isRTL() ? 'l' : 'r';
876 return $this->arrow( $dir, '+', wfMsg( 'rc-enhanced-expand' ) );
880 * Generate HTML for a down-facing arrow
881 * depending on language direction.
882 * @return string HTML <img> tag
884 protected function downArrow() {
885 return $this->arrow( 'd', '-', wfMsg( 'rc-enhanced-hide' ) );
889 * Generate HTML for a spacer image
890 * @return string HTML <img> tag
892 protected function spacerArrow() {
893 return $this->arrow( '', codepointToUtf8( 0xa0 ) ); // non-breaking space
897 * Add a set of spaces
898 * @return string HTML <td> tag
900 protected function spacerIndent() {
901 return ' ';
905 * Enhanced RC ungrouped line.
906 * @return string a HTML formated line (generated using $r)
908 protected function recentChangesBlockLine( $rcObj ) {
909 global $wgContLang, $wgRCShowChangedSize;
911 wfProfileIn( __METHOD__ );
913 # Extract fields from DB into the function scope (rc_xxxx variables)
914 // FIXME: Would be good to replace this extract() call with something
915 // that explicitly initializes variables.
916 $classes = array(); // TODO implement
917 extract( $rcObj->mAttribs );
918 $curIdEq = "curid={$rc_cur_id}";
920 $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>';
921 $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . ' ';
923 if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
924 $r .= ' '; // 4 flags -> 4 spaces
926 $r .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled, ' ', $rc_bot );
928 $r .= ' '.$rcObj->timestamp.' </tt></td><td>';
929 # Article or log link
931 $logtitle = Title::newFromText( "Log/$rc_log_type", NS_SPECIAL );
932 $logname = LogPage::logName( $rc_log_type );
933 $r .= '(' . $this->skin->makeKnownLinkObj($logtitle, $logname ) . ')';
935 $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled, $rcObj->watched );
937 # Diff and hist links
938 if ( $rc_type != RC_LOG ) {
939 $r .= ' ('. $rcObj->difflink . $this->message['semicolon-separator'];
940 $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), $this->message['hist'],
941 $curIdEq.'&action=history' ) . ')';
945 if( $wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference()) ) {
949 $r .= ' '.$rcObj->userlink . $rcObj->usertalklink;
950 # Log action (if any)
952 if( $this->isDeleted($rcObj,LogPage::DELETED_ACTION) ) {
953 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
955 $r .= ' ' . LogPage::actionText( $rc_log_type, $rc_log_action, $rcObj->getTitle(),
956 $this->skin, LogPage::extractParams($rc_params), true, true );
959 $this->insertComment( $r, $rcObj );
960 $this->insertRollback( $r, $rcObj );
962 $this->insertTags( $r, $rcObj, $classes );
963 # Show how many people are watching this if enabled
964 $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers);
966 $r .= "</td></tr></table>\n";
968 wfProfileOut( __METHOD__ );
974 * If enhanced RC is in use, this function takes the previously cached
975 * RC lines, arranges them, and outputs the HTML
977 protected function recentChangesBlock() {
978 if( count ( $this->rc_cache ) == 0 ) {
982 wfProfileIn( __METHOD__ );
985 foreach( $this->rc_cache as $block ) {
986 if( count( $block ) < 2 ) {
987 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
989 $blockOut .= $this->recentChangesBlockGroup( $block );
993 wfProfileOut( __METHOD__ );
995 return '<div>'.$blockOut.'</div>';
999 * Returns text for the end of RC
1000 * If enhanced RC is in use, returns pretty much all the text
1002 public function endRecentChangesList() {
1003 return $this->recentChangesBlock() . parent::endRecentChangesList();