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'] && $wgUser->isAllowed('rollback') ) {
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( $rc->mAttribs
['rc_cur_id'] && $page->getLatestRevID() == $rc->mAttribs
['rc_this_oldid']
330 && $page->quickUserCan('rollback') && $page->quickUserCan('edit') )
332 $rev = new Revision( array(
333 'id' => $rc->mAttribs
['rc_this_oldid'],
334 'user' => $rc->mAttribs
['rc_user'],
335 'user_text' => $rc->mAttribs
['rc_user_text']
337 $s .= ' '.$this->skin
->generateRollback( $rev );
342 protected function insertTags( &$s, &$rc, &$classes ) {
343 if ( empty($rc->mAttribs
['ts_tags']) )
346 list($tagSummary, $newClasses) = ChangeTags
::formatSummaryRow( $rc->mAttribs
['ts_tags'], 'changeslist' );
347 $classes = array_merge( $classes, $newClasses );
348 $s .= ' ' . $tagSummary;
351 protected function insertExtra( &$s, &$rc, &$classes ) {
352 ## Empty, used for subclassers to add anything special.
358 * Generate a list of changes using the good old system (no javascript)
360 class OldChangesList
extends ChangesList
{
362 * Format a line using the old system (aka without any javascript).
364 public function recentChangesLine( &$rc, $watched = false, $linenumber = NULL ) {
365 global $wgContLang, $wgLang, $wgRCShowChangedSize, $wgUser;
366 wfProfileIn( __METHOD__
);
367 # Should patrol-related stuff be shown?
368 $unpatrolled = $wgUser->useRCPatrol() && !$rc->mAttribs
['rc_patrolled'];
370 $dateheader = ''; // $s now contains only <li>...</li>, for hooks' convenience.
371 $this->insertDateHeader( $dateheader, $rc->mAttribs
['rc_timestamp'] );
375 // use mw-line-even/mw-line-odd class only if linenumber is given (feature from bug 14468)
377 if( $linenumber & 1 ) {
378 $classes[] = 'mw-line-odd';
381 $classes[] = 'mw-line-even';
386 if( $rc->mAttribs
['rc_type'] == RC_MOVE ||
$rc->mAttribs
['rc_type'] == RC_MOVE_OVER_REDIRECT
) {
387 $this->insertMove( $s, $rc );
389 } elseif( $rc->mAttribs
['rc_log_type'] ) {
390 $logtitle = Title
::newFromText( 'Log/'.$rc->mAttribs
['rc_log_type'], NS_SPECIAL
);
391 $this->insertLog( $s, $logtitle, $rc->mAttribs
['rc_log_type'] );
392 // Log entries (old format) or log targets, and special pages
393 } elseif( $rc->mAttribs
['rc_namespace'] == NS_SPECIAL
) {
394 list( $name, $subpage ) = SpecialPage
::resolveAliasWithSubpage( $rc->mAttribs
['rc_title'] );
395 if( $name == 'Log' ) {
396 $this->insertLog( $s, $rc->getTitle(), $subpage );
400 $this->insertDiffHist( $s, $rc, $unpatrolled );
401 # M, N, b and ! (minor, new, bot and unpatrolled)
402 $s .= $this->recentChangesFlags( $rc->mAttribs
['rc_new'], $rc->mAttribs
['rc_minor'],
403 $unpatrolled, '', $rc->mAttribs
['rc_bot'] );
404 $this->insertArticleLink( $s, $rc, $unpatrolled, $watched );
407 $this->insertTimestamp( $s, $rc );
408 # Bytes added or removed
409 if( $wgRCShowChangedSize ) {
410 $cd = $rc->getCharacterDifference();
416 $this->insertUserRelatedLinks( $s, $rc );
417 # Log action text (if any)
418 $this->insertAction( $s, $rc );
419 # Edit or log comment
420 $this->insertComment( $s, $rc );
422 $this->insertTags( $s, $rc, $classes );
424 $this->insertRollback( $s, $rc );
426 $this->insertExtra( $s, $rc, $classes );
428 # Mark revision as deleted if so
429 if( !$rc->mAttribs
['rc_log_type'] && $this->isDeleted($rc,Revision
::DELETED_TEXT
) ) {
430 $s .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
432 # How many users watch this page
433 if( $rc->numberofWatchingusers
> 0 ) {
434 $s .= ' ' . wfMsgExt( 'number_of_watching_users_RCview',
435 array( 'parsemag', 'escape' ), $wgLang->formatNum( $rc->numberofWatchingusers
) );
438 wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) );
440 wfProfileOut( __METHOD__
);
441 return "$dateheader<li class=\"".implode( ' ', $classes )."\">$s</li>\n";
447 * Generate a list of changes using an Enhanced system (uses javascript).
449 class EnhancedChangesList
extends ChangesList
{
451 * Add the JavaScript file for enhanced changeslist
454 public function beginRecentChangesList() {
455 global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
456 $this->rc_cache
= array();
457 $this->rcMoveIndex
= 0;
458 $this->rcCacheIndex
= 0;
459 $this->lastdate
= '';
460 $this->rclistOpen
= false;
461 $script = Xml
::tags( 'script', array(
462 'type' => $wgJsMimeType,
463 'src' => $wgStylePath . "/common/enhancedchanges.js?$wgStyleVersion" ), '' );
467 * Format a line for enhanced recentchange (aka with javascript and block of lines).
469 public function recentChangesLine( &$baseRC, $watched = false ) {
471 global $wgLang, $wgContLang, $wgUser;
473 # Create a specialised object
474 $rc = RCCacheEntry
::newFromParent( $baseRC );
476 # Extract fields from DB into the function scope (rc_xxxx variables)
477 // FIXME: Would be good to replace this extract() call with something
478 // that explicitly initializes variables.
479 extract( $rc->mAttribs
);
480 $curIdEq = 'curid=' . $rc_cur_id;
482 # If it's a new day, add the headline and flush the cache
483 $date = $wgLang->date( $rc_timestamp, true );
485 if( $date != $this->lastdate
) {
486 # Process current cache
487 $ret = $this->recentChangesBlock();
488 $this->rc_cache
= array();
489 $ret .= "<h4>{$date}</h4>\n";
490 $this->lastdate
= $date;
493 # Should patrol-related stuff be shown?
494 if( $wgUser->useRCPatrol() ) {
495 $rc->unpatrolled
= !$rc_patrolled;
497 $rc->unpatrolled
= false;
500 $showdifflinks = true;
503 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
504 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
505 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
506 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
507 // New unpatrolled pages
508 } else if( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
509 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
511 } else if( $rc_type == RC_LOG
) {
513 $logtitle = SpecialPage
::getTitleFor( 'Log', $rc_log_type );
514 $clink = '(' . $this->skin
->makeKnownLinkObj( $logtitle,
515 LogPage
::logName($rc_log_type) ) . ')';
517 $clink = $this->skin
->makeLinkObj( $rc->getTitle(), '' );
520 // Log entries (old format) and special pages
521 } elseif( $rc_namespace == NS_SPECIAL
) {
522 list( $specialName, $logtype ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
523 if ( $specialName == 'Log' ) {
525 $logname = LogPage
::logName( $logtype );
526 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
528 wfDebug( "Unexpected special page in recentchanges\n" );
533 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
536 # Don't show unusable diff links
537 if ( !ChangesList
::userCan($rc,Revision
::DELETED_TEXT
) ) {
538 $showdifflinks = false;
541 $time = $wgContLang->time( $rc_timestamp, true, true );
542 $rc->watched
= $watched;
544 $rc->timestamp
= $time;
545 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
547 # Make "cur" and "diff" links
548 if( $rc->unpatrolled
) {
549 $rcIdQuery = "&rcid={$rc_id}";
553 $querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid";
554 $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery";
555 $aprops = ' tabindex="'.$baseRC->counter
.'"';
556 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(),
557 $this->message
['cur'], $querycur, '' ,'', $aprops );
559 # Make "diff" an "cur" links
560 if( !$showdifflinks ) {
561 $curLink = $this->message
['cur'];
562 $diffLink = $this->message
['diff'];
563 } else if( in_array( $rc_type, array(RC_NEW
,RC_LOG
,RC_MOVE
,RC_MOVE_OVER_REDIRECT
) ) ) {
564 $curLink = ($rc_type != RC_NEW
) ?
$this->message
['cur'] : $curLink;
565 $diffLink = $this->message
['diff'];
567 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['diff'],
568 $querydiff, '' ,'', $aprops );
572 if( !$showdifflinks ||
!$rc_last_oldid ) {
573 $lastLink = $this->message
['last'];
574 } else if( $rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
575 $lastLink = $this->message
['last'];
577 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['last'],
578 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
582 if( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
583 $rc->userlink
= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
585 $rc->userlink
= $this->skin
->userLink( $rc_user, $rc_user_text );
586 $rc->usertalklink
= $this->skin
->userToolLinks( $rc_user, $rc_user_text );
589 $rc->lastlink
= $lastLink;
590 $rc->curlink
= $curLink;
591 $rc->difflink
= $diffLink;
593 # Put accumulated information into the cache, for later display
594 # Page moves go on their own line
595 $title = $rc->getTitle();
596 $secureName = $title->getPrefixedDBkey();
597 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
598 # Use an @ character to prevent collision with page names
599 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
601 # Logs are grouped by type
602 if( $rc_type == RC_LOG
){
603 $secureName = SpecialPage
::getTitleFor( 'Log', $rc_log_type )->getPrefixedDBkey();
605 if( !isset( $this->rc_cache
[$secureName] ) ) {
606 $this->rc_cache
[$secureName] = array();
609 array_push( $this->rc_cache
[$secureName], $rc );
617 protected function recentChangesBlockGroup( $block ) {
618 global $wgLang, $wgContLang, $wgRCShowChangedSize;
619 $r = '<table cellpadding="0" cellspacing="0" border="0" style="background: none"><tr>';
621 # Collate list of users
622 $userlinks = array();
624 $unpatrolled = false;
626 $curId = $currentRevision = 0;
627 # Some catalyst variables...
630 foreach( $block as $rcObj ) {
631 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
632 if( $rcObj->mAttribs
['rc_new'] ) {
635 // If all log actions to this page were hidden, then don't
636 // give the name of the affected page for this block!
637 if( !$this->isDeleted( $rcObj, LogPage
::DELETED_ACTION
) ) {
640 $u = $rcObj->userlink
;
641 if( !isset( $userlinks[$u] ) ) {
644 if( $rcObj->unpatrolled
) {
647 if( $rcObj->mAttribs
['rc_type'] != RC_LOG
) {
650 # Get the latest entry with a page_id and oldid
651 # since logs may not have these.
652 if( !$curId && $rcObj->mAttribs
['rc_cur_id'] ) {
653 $curId = $rcObj->mAttribs
['rc_cur_id'];
655 if( !$currentRevision && $rcObj->mAttribs
['rc_this_oldid'] ) {
656 $currentRevision = $rcObj->mAttribs
['rc_this_oldid'];
659 $bot = $rcObj->mAttribs
['rc_bot'];
663 # Sort the list and convert to text
664 krsort( $userlinks );
667 foreach( $userlinks as $userlink => $count) {
669 $text .= $wgContLang->getDirMark();
671 $text .= ' (' . $wgLang->formatNum( $count ) . '×)';
673 array_push( $users, $text );
676 $users = ' <span class="changedby">[' .
677 implode( $this->message
['semicolon-separator'], $users ) . ']</span>';
679 # ID for JS visibility toggle
680 $jsid = $this->rcCacheIndex
;
681 # onclick handler to toggle hidden/expanded
682 $toggleLink = "onclick='toggleVisibility($jsid); return false'";
684 $expandTitle = htmlspecialchars( wfMsg( 'rc-enhanced-expand' ) );
685 $closeTitle = htmlspecialchars( wfMsg( 'rc-enhanced-hide' ) );
687 $tl = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
688 $tl .= "<span id='mw-rc-closearrow-$jsid' class='mw-changeslist-hidden' style='display:none'><a href='#' $toggleLink title='$closeTitle'>" . $this->downArrow() . "</a></span>";
689 $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.' ';
692 $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot );
695 $r .= ' '.$block[0]->timestamp
.' </tt></td><td>';
699 $r .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
700 } else if( $allLogs ) {
701 $r .= $this->maybeWatchedLink( $block[0]->link
, $block[0]->watched
);
703 $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled
, $block[0]->watched
);
706 $r .= $wgContLang->getDirMark();
708 $curIdEq = 'curid=' . $curId;
711 static $nchanges = array();
712 if ( !isset( $nchanges[$n] ) ) {
713 $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) );
719 if( !ChangesList
::userCan( $rcObj, Revision
::DELETED_TEXT
) ) {
721 } else if( $isnew ) {
724 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
725 $nchanges[$n], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
731 // don't show history link for logs
732 } else if( $namehidden ||
!$block[0]->getTitle()->exists() ) {
733 $r .= $this->message
['semicolon-separator'] . $this->message
['hist'] . ')';
735 $r .= $this->message
['semicolon-separator'] . $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
736 $this->message
['hist'], $curIdEq . '&action=history' ) . ')';
740 # Character difference (does not apply if only log items)
741 if( $wgRCShowChangedSize && !$allLogs ) {
743 $first = count($block) - 1;
744 # Some events (like logs) have an "empty" size, so we need to skip those...
745 while( $last < $first && $block[$last]->mAttribs
['rc_new_len'] === NULL ) {
748 while( $first > $last && $block[$first]->mAttribs
['rc_old_len'] === NULL ) {
752 $chardiff = $rcObj->getCharacterDifference( $block[$first]->mAttribs
['rc_old_len'],
753 $block[$last]->mAttribs
['rc_new_len'] );
755 if( $chardiff == '' ) {
758 $r .= ' ' . $chardiff. ' . . ';
763 $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers
);
765 $r .= "</td></tr></table>\n";
768 $r .= '<div id="mw-rc-subentries-'.$jsid.'" class="mw-changeslist-hidden">';
769 $r .= '<table cellpadding="0" cellspacing="0" border="0" style="background: none">';
770 foreach( $block as $rcObj ) {
771 # Extract fields from DB into the function scope (rc_xxxx variables)
772 // FIXME: Would be good to replace this extract() call with something
773 // that explicitly initializes variables.
774 # Classes to apply -- TODO implement
776 extract( $rcObj->mAttribs
);
778 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
779 $r .= '<tr><td valign="top">';
780 $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
781 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
782 $r .= ' </tt></td><td valign="top">';
785 if( $rc_this_oldid != 0 ) {
786 $o = 'oldid='.$rc_this_oldid;
789 if( $rc_type == RC_LOG
) {
790 $link = '<tt>'.$rcObj->timestamp
.'</tt> ';
792 } else if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
793 $link = '<span class="history-deleted"><tt>'.$rcObj->timestamp
.'</tt></span> ';
795 $rcIdEq = ($rcObj->unpatrolled
&& $rc_type == RC_NEW
) ?
796 '&rcid='.$rcObj->mAttribs
['rc_id'] : '';
797 $link = '<tt>'.$this->skin
->makeKnownLinkObj( $rcObj->getTitle(),
798 $rcObj->timestamp
, $curIdEq.'&'.$o.$rcIdEq ).'</tt>';
799 if( $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) )
800 $link = '<span class="history-deleted">'.$link.'</span> ';
804 if ( !$rc_type == RC_LOG ||
$rc_type == RC_NEW
) {
806 $r .= $rcObj->curlink
;
807 $r .= $this->message
['semicolon-separator'];
808 $r .= $rcObj->lastlink
;
814 if( $wgRCShowChangedSize ) {
815 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : $rcObj->getCharacterDifference() . ' . . ' ) ;
818 $r .= $rcObj->userlink
;
819 $r .= $rcObj->usertalklink
;
821 $this->insertAction( $r, $rcObj );
823 $this->insertComment( $r, $rcObj );
825 $this->insertRollback( $r, $rcObj );
827 $this->insertTags( $r, $rcObj, $classes );
829 # Mark revision as deleted
830 if( !$rc_log_type && $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) ) {
831 $r .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
834 $r .= "</td></tr>\n";
836 $r .= "</table></div>\n";
838 $this->rcCacheIndex++
;
843 * Generate HTML for an arrow or placeholder graphic
844 * @param string $dir one of '', 'd', 'l', 'r'
845 * @param string $alt text
846 * @param string $title text
847 * @return string HTML <img> tag
849 protected function arrow( $dir, $alt='', $title='' ) {
851 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
852 $encAlt = htmlspecialchars( $alt );
853 $encTitle = htmlspecialchars( $title );
854 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
858 * Generate HTML for a right- or left-facing arrow,
859 * depending on language direction.
860 * @return string HTML <img> tag
862 protected function sideArrow() {
864 $dir = $wgContLang->isRTL() ?
'l' : 'r';
865 return $this->arrow( $dir, '+', wfMsg( 'rc-enhanced-expand' ) );
869 * Generate HTML for a down-facing arrow
870 * depending on language direction.
871 * @return string HTML <img> tag
873 protected function downArrow() {
874 return $this->arrow( 'd', '-', wfMsg( 'rc-enhanced-hide' ) );
878 * Generate HTML for a spacer image
879 * @return string HTML <img> tag
881 protected function spacerArrow() {
882 return $this->arrow( '', codepointToUtf8( 0xa0 ) ); // non-breaking space
886 * Add a set of spaces
887 * @return string HTML <td> tag
889 protected function spacerIndent() {
890 return ' ';
894 * Enhanced RC ungrouped line.
895 * @return string a HTML formated line (generated using $r)
897 protected function recentChangesBlockLine( $rcObj ) {
898 global $wgContLang, $wgRCShowChangedSize;
899 # Extract fields from DB into the function scope (rc_xxxx variables)
900 // FIXME: Would be good to replace this extract() call with something
901 // that explicitly initializes variables.
902 $classes = array(); // TODO implement
903 extract( $rcObj->mAttribs
);
904 $curIdEq = "curid={$rc_cur_id}";
906 $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>';
907 $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . ' ';
909 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
910 $r .= ' '; // 4 flags -> 4 spaces
912 $r .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
914 $r .= ' '.$rcObj->timestamp
.' </tt></td><td>';
915 # Article or log link
917 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
918 $logname = LogPage
::logName( $rc_log_type );
919 $r .= '(' . $this->skin
->makeKnownLinkObj($logtitle, $logname ) . ')';
921 $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled
, $rcObj->watched
);
923 # Diff and hist links
924 if ( $rc_type != RC_LOG
) {
925 $r .= ' ('. $rcObj->difflink
. $this->message
['semicolon-separator'];
926 $r .= $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $this->message
['hist'],
927 $curIdEq.'&action=history' ) . ')';
931 if( $wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference()) ) {
935 $r .= ' '.$rcObj->userlink
. $rcObj->usertalklink
;
936 # Log action (if any)
938 if( $this->isDeleted($rcObj,LogPage
::DELETED_ACTION
) ) {
939 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
941 $r .= ' ' . LogPage
::actionText( $rc_log_type, $rc_log_action, $rcObj->getTitle(),
942 $this->skin
, LogPage
::extractParams($rc_params), true, true );
945 $this->insertComment( $r, $rcObj );
946 $this->insertRollback( $r, $rcObj );
948 $this->insertTags( $r, $rcObj, $classes );
949 # Show how many people are watching this if enabled
950 $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers
);
952 $r .= "</td></tr></table>\n";
957 * If enhanced RC is in use, this function takes the previously cached
958 * RC lines, arranges them, and outputs the HTML
960 protected function recentChangesBlock() {
961 if( count ( $this->rc_cache
) == 0 ) {
965 foreach( $this->rc_cache
as $block ) {
966 if( count( $block ) < 2 ) {
967 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
969 $blockOut .= $this->recentChangesBlockGroup( $block );
972 return '<div>'.$blockOut.'</div>';
976 * Returns text for the end of RC
977 * If enhanced RC is in use, returns pretty much all the text
979 public function endRecentChangesList() {
980 return $this->recentChangesBlock() . parent
::endRecentChangesList();