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
29 * Changeslist contructor
32 public function __construct( &$skin ) {
34 $this->preCacheMessages();
38 * Fetch an appropriate changes list class for the specified user
39 * Some users might want to use an enhanced list format, for instance
41 * @param $user User to fetch the list class for
42 * @return ChangesList derivative
44 public static function newFromUser( &$user ) {
45 $sk = $user->getSkin();
47 if( wfRunHooks( 'FetchChangesList', array( &$user, &$sk, &$list ) ) ) {
48 return $user->getOption( 'usenewrc' ) ?
new EnhancedChangesList( $sk ) : new OldChangesList( $sk );
55 * As we use the same small set of messages in various methods and that
56 * they are called often, we call them once and save them in $this->message
58 private function preCacheMessages() {
59 if( !isset( $this->message
) ) {
60 foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last '.
61 'blocklink history boteditletter semicolon-separator' ) as $msg ) {
62 $this->message
[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
69 * Returns the appropriate flags for new page, minor change and patrolling
72 * @param bool $patrolled
73 * @param string $nothing, string to use for empty space
77 protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = ' ', $bot = false ) {
79 '<span class="newpage">' . $this->message
['newpageletter'] . '</span>' : $nothing;
81 '<span class="minor">' . $this->message
['minoreditletter'] . '</span>' : $nothing;
82 $f .= $bot ?
'<span class="bot">' . $this->message
['boteditletter'] . '</span>' : $nothing;
83 $f .= $patrolled ?
'<span class="unpatrolled">!</span>' : $nothing;
88 * Returns text for the start of the tabular part of RC
91 public function beginRecentChangesList() {
92 $this->rc_cache
= array();
93 $this->rcMoveIndex
= 0;
94 $this->rcCacheIndex
= 0;
96 $this->rclistOpen
= false;
101 * Show formatted char difference
102 * @param int $old bytes
103 * @param int $new bytes
106 public static function showCharacterDifference( $old, $new ) {
107 global $wgRCChangedSizeThreshold, $wgLang;
108 $szdiff = $new - $old;
109 $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape'), $wgLang->formatNum($szdiff) );
110 if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
115 if( $szdiff === 0 ) {
116 return "<$tag class='mw-plusminus-null'>($formatedSize)</$tag>";
117 } elseif( $szdiff > 0 ) {
118 return "<$tag class='mw-plusminus-pos'>(+$formatedSize)</$tag>";
120 return "<$tag class='mw-plusminus-neg'>($formatedSize)</$tag>";
125 * Returns text for the end of RC
128 public function endRecentChangesList() {
129 if( $this->rclistOpen
) {
136 protected function insertMove( &$s, $rc ) {
138 $s .= '(' . $this->message
['diff'] . ') (';
140 $s .= $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), $this->message
['hist'], 'action=history' ) .
142 # "[[x]] moved to [[y]]"
143 $msg = ( $rc->mAttribs
['rc_type'] == RC_MOVE
) ?
'1movedto2' : '1movedto2_redir';
144 $s .= wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
145 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
148 protected function insertDateHeader( &$s, $rc_timestamp ) {
151 # Make date header if necessary
152 $date = $wgLang->date( $rc_timestamp, true, true );
153 if( $date != $this->lastdate
) {
154 if( '' != $this->lastdate
) {
157 $s .= '<h4>'.$date."</h4>\n<ul class=\"special\">";
158 $this->lastdate
= $date;
159 $this->rclistOpen
= true;
163 protected function insertLog( &$s, $title, $logtype ) {
164 $logname = LogPage
::logName( $logtype );
165 $s .= '(' . $this->skin
->makeKnownLinkObj($title, $logname ) . ')';
168 protected function insertDiffHist( &$s, &$rc, $unpatrolled ) {
170 if( !$this->userCan($rc,Revision
::DELETED_TEXT
) ) {
171 $diffLink = $this->message
['diff'];
172 } else if( $rc->mAttribs
['rc_type'] == RC_NEW ||
$rc->mAttribs
['rc_type'] == RC_LOG
) {
173 $diffLink = $this->message
['diff'];
175 $rcidparam = $unpatrolled ?
176 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 ) {
222 $s .= $this->message
['semicolon-separator'] . $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) {
238 if( $rc->mAttribs
['rc_type'] == RC_LOG
) {
240 if ( $this->isDeleted($rc,LogPage
::DELETED_ACTION
) ) {
241 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
243 $s .= ' ' . LogPage
::actionText( $rc->mAttribs
['rc_log_type'], $rc->mAttribs
['rc_log_action'],
244 $rc->getTitle(), $this->skin
, LogPage
::extractParams($rc->mAttribs
['rc_params']), true, true );
249 /** insert a formatted comment */
250 protected function insertComment(&$s, &$rc) {
252 if( $rc->mAttribs
['rc_type'] != RC_MOVE
&& $rc->mAttribs
['rc_type'] != RC_MOVE_OVER_REDIRECT
) {
254 if ( $this->isDeleted($rc,Revision
::DELETED_COMMENT
) ) {
255 $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
257 $s .= $this->skin
->commentBlock( $rc->mAttribs
['rc_comment'], $rc->getTitle() );
263 * Check whether to enable recent changes patrol features
266 public static function usePatrol() {
268 return $wgUser->useRCPatrol();
272 * Returns the string which indicates the number of watching users
274 protected function numberofWatchingusers( $count ) {
276 static $cache = array();
278 if ( !isset( $cache[$count] ) ) {
279 $cache[$count] = wfMsgExt('number_of_watching_users_RCview',
280 array('parsemag', 'escape'), $wgLang->formatNum($count));
282 return $cache[$count];
289 * Determine if said field of a revision is hidden
290 * @param RCCacheEntry $rc
291 * @param int $field one of DELETED_* bitfield constants
294 public static function isDeleted( $rc, $field ) {
295 return ($rc->mAttribs
['rc_deleted'] & $field) == $field;
299 * Determine if the current user is allowed to view a particular
300 * field of this revision, if it's marked as deleted.
301 * @param RCCacheEntry $rc
305 public static function userCan( $rc, $field ) {
306 if( ( $rc->mAttribs
['rc_deleted'] & $field ) == $field ) {
308 $permission = ( $rc->mAttribs
['rc_deleted'] & Revision
::DELETED_RESTRICTED
) == Revision
::DELETED_RESTRICTED
311 wfDebug( "Checking for $permission due to $field match on $rc->mAttribs['rc_deleted']\n" );
312 return $wgUser->isAllowed( $permission );
318 protected function maybeWatchedLink( $link, $watched=false ) {
320 // FIXME: css style might be more appropriate
321 return '<strong class="mw-watched">' . $link . '</strong>';
323 return '<span class="mw-rc-unwatched">' . $link . '</span>';
330 * Generate a list of changes using the good old system (no javascript)
332 class OldChangesList
extends ChangesList
{
334 * Format a line using the old system (aka without any javascript).
336 public function recentChangesLine( &$rc, $watched = false ) {
337 global $wgContLang, $wgRCShowChangedSize, $wgUser;
339 $fname = 'ChangesList::recentChangesLineOld';
340 wfProfileIn( $fname );
342 # Extract DB fields into local scope
343 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
344 extract( $rc->mAttribs
);
346 # Should patrol-related stuff be shown?
347 $unpatrolled = $wgUser->useRCPatrol() && $rc_patrolled == 0;
349 $dateheader = ""; // $s now contains only <li>...</li>, for hooks' convenience.
350 $this->insertDateHeader($dateheader,$rc_timestamp);
355 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
356 $this->insertMove( $s, $rc );
358 } elseif( $rc_log_type ) {
359 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
360 $this->insertLog( $s, $logtitle, $rc_log_type );
361 // Log entries (old format) or log targets, and special pages
362 } elseif( $rc_namespace == NS_SPECIAL
) {
363 list( $specialName, $specialSubpage ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
364 if ( $specialName == 'Log' ) {
365 $this->insertLog( $s, $rc->getTitle(), $specialSubpage );
367 wfDebug( "Unexpected special page in recentchanges\n" );
371 wfProfileIn($fname.'-page');
373 $this->insertDiffHist($s, $rc, $unpatrolled);
375 # M, N, b and ! (minor, new, bot and unpatrolled)
376 $s .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $unpatrolled, '', $rc_bot );
377 $this->insertArticleLink($s, $rc, $unpatrolled, $watched);
379 wfProfileOut($fname.'-page');
382 wfProfileIn( $fname.'-rest' );
384 $this->insertTimestamp($s,$rc);
386 if( $wgRCShowChangedSize ) {
387 $s .= ( $rc->getCharacterDifference() == '' ?
'' : $rc->getCharacterDifference() . ' . . ' );
390 $this->insertUserRelatedLinks($s,$rc);
391 # Log action text (if any)
392 $this->insertAction($s, $rc);
393 # Edit or log comment
394 $this->insertComment($s, $rc);
396 # Mark revision as deleted if so
397 if ( !$rc_log_type && $this->isDeleted($rc,Revision
::DELETED_TEXT
) )
398 $s .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
399 if($rc->numberofWatchingusers
> 0) {
400 $s .= ' ' . wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rc->numberofWatchingusers
));
403 wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) );
405 $s = "<li>$s</li>\n";
407 wfProfileOut( $fname.'-rest' );
409 wfProfileOut( $fname );
410 return $dateheader . $s;
416 * Generate a list of changes using an Enhanced system (use javascript).
418 class EnhancedChangesList
extends ChangesList
{
421 * Add the JavaScript file for enhanced changeslist
424 public function beginRecentChangesList() {
425 global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
426 $this->rc_cache
= array();
427 $this->rcMoveIndex
= 0;
428 $this->rcCacheIndex
= 0;
429 $this->lastdate
= '';
430 $this->rclistOpen
= false;
431 $script = Xml
::tags( 'script', array(
432 'type' => $wgJsMimeType,
433 'src' => $wgStylePath . "/common/enhancedchanges.js?$wgStyleVersion" ), '' );
437 * Format a line for enhanced recentchange (aka with javascript and block of lines).
439 public function recentChangesLine( &$baseRC, $watched = false ) {
440 global $wgLang, $wgContLang, $wgUser;
442 # Create a specialised object
443 $rc = RCCacheEntry
::newFromParent( $baseRC );
445 # Extract fields from DB into the function scope (rc_xxxx variables)
446 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
447 extract( $rc->mAttribs
);
448 $curIdEq = 'curid=' . $rc_cur_id;
450 # If it's a new day, add the headline and flush the cache
451 $date = $wgLang->date( $rc_timestamp, true);
453 if( $date != $this->lastdate
) {
454 # Process current cache
455 $ret = $this->recentChangesBlock();
456 $this->rc_cache
= array();
457 $ret .= "<h4>{$date}</h4>\n";
458 $this->lastdate
= $date;
461 # Should patrol-related stuff be shown?
462 if( $wgUser->useRCPatrol() ) {
463 $rc->unpatrolled
= !$rc_patrolled;
465 $rc->unpatrolled
= false;
468 $showdifflinks = true;
471 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
472 $msg = ( $rc_type == RC_MOVE
) ?
"1movedto2" : "1movedto2_redir";
473 $clink = wfMsg( $msg, $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
474 $this->skin
->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
475 // Log entries (old format) and special pages
476 } elseif( $rc_namespace == NS_SPECIAL
) {
477 list( $specialName, $logtype ) = SpecialPage
::resolveAliasWithSubpage( $rc_title );
478 if ( $specialName == 'Log' ) {
480 $logname = LogPage
::logName( $logtype );
481 $clink = '(' . $this->skin
->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
483 wfDebug( "Unexpected special page in recentchanges\n" );
486 // New unpatrolled pages
487 } else if( $rc->unpatrolled
&& $rc_type == RC_NEW
) {
488 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
490 } else if( $rc_type == RC_LOG
) {
492 $logtitle = SpecialPage
::getTitleFor( 'Log', $rc_log_type );
493 $clink = '(' . $this->skin
->makeKnownLinkObj( $logtitle, LogPage
::logName($rc_log_type) ) . ')';
495 $clink = $this->skin
->makeLinkObj( $rc->getTitle(), '' );
500 $clink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), '' );
503 # Don't show unusable diff links
504 if ( !ChangesList
::userCan($rc,Revision
::DELETED_TEXT
) ) {
505 $showdifflinks = false;
508 $time = $wgContLang->time( $rc_timestamp, true, true );
509 $rc->watched
= $watched;
511 $rc->timestamp
= $time;
512 $rc->numberofWatchingusers
= $baseRC->numberofWatchingusers
;
514 # Make "cur" and "diff" links
515 if( $rc->unpatrolled
) {
516 $rcIdQuery = "&rcid={$rc_id}";
520 $querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid";
521 $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery";
522 $aprops = ' tabindex="'.$baseRC->counter
.'"';
523 $curLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['cur'], $querycur, '' ,'', $aprops );
525 # Make "diff" an "cur" links
526 if( !$showdifflinks ) {
527 $curLink = $this->message
['cur'];
528 $diffLink = $this->message
['diff'];
529 } else if( $rc_type == RC_NEW ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
530 if( $rc_type != RC_NEW
) {
531 $curLink = $this->message
['cur'];
533 $diffLink = $this->message
['diff'];
535 $diffLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['diff'], $querydiff, '' ,'', $aprops );
539 if( !$showdifflinks ) {
540 $lastLink = $this->message
['last'];
541 } else if( $rc_last_oldid == 0 ||
$rc_type == RC_LOG ||
$rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
542 $lastLink = $this->message
['last'];
544 $lastLink = $this->skin
->makeKnownLinkObj( $rc->getTitle(), $this->message
['last'],
545 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
549 if( $this->isDeleted($rc,Revision
::DELETED_USER
) ) {
550 $rc->userlink
= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
552 $rc->userlink
= $this->skin
->userLink( $rc_user, $rc_user_text );
553 $rc->usertalklink
= $this->skin
->userToolLinks( $rc_user, $rc_user_text );
556 $rc->lastlink
= $lastLink;
557 $rc->curlink
= $curLink;
558 $rc->difflink
= $diffLink;
560 # Put accumulated information into the cache, for later display
561 # Page moves go on their own line
562 $title = $rc->getTitle();
563 $secureName = $title->getPrefixedDBkey();
564 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
565 # Use an @ character to prevent collision with page names
566 $this->rc_cache
['@@' . ($this->rcMoveIndex++
)] = array($rc);
568 # Logs are grouped by type
569 if( $rc_type == RC_LOG
){
570 $secureName = SpecialPage
::getTitleFor( 'Log', $rc_log_type )->getPrefixedDBkey();
572 if( !isset( $this->rc_cache
[$secureName] ) ) {
573 $this->rc_cache
[$secureName] = array();
575 array_push( $this->rc_cache
[$secureName], $rc );
583 protected function recentChangesBlockGroup( $block ) {
584 global $wgLang, $wgContLang, $wgRCShowChangedSize;
585 $r = '<table cellpadding="0" cellspacing="0" border="0" style="background: none"><tr>';
587 # Collate list of users
588 $userlinks = array();
590 $unpatrolled = false;
592 $curId = $currentRevision = 0;
593 # Some catalyst variables...
596 foreach( $block as $rcObj ) {
597 $oldid = $rcObj->mAttribs
['rc_last_oldid'];
598 if( $rcObj->mAttribs
['rc_new'] ) {
601 // If all log actions to this page were hidden, then don't
602 // give the name of the affected page for this block!
603 if( !$this->isDeleted( $rcObj, LogPage
::DELETED_ACTION
) ) {
606 $u = $rcObj->userlink
;
607 if( !isset( $userlinks[$u] ) ) {
610 if( $rcObj->unpatrolled
) {
613 if( $rcObj->mAttribs
['rc_type'] != RC_LOG
) {
616 # Get the latest entry with a page_id and oldid
617 # since logs may not have these.
618 if( !$curId && $rcObj->mAttribs
['rc_cur_id'] ) {
619 $curId = $rcObj->mAttribs
['rc_cur_id'];
621 if( !$currentRevision && $rcObj->mAttribs
['rc_this_oldid'] ) {
622 $currentRevision = $rcObj->mAttribs
['rc_this_oldid'];
625 $bot = $rcObj->mAttribs
['rc_bot'];
629 # Sort the list and convert to text
630 krsort( $userlinks );
633 foreach( $userlinks as $userlink => $count) {
635 $text .= $wgContLang->getDirMark();
637 $text .= ' (' . $wgLang->formatNum( $count ) . '×)';
639 array_push( $users, $text );
642 $users = ' <span class="changedby">[' . implode( $this->message
['semicolon-separator'], $users ) . ']</span>';
644 # ID for JS visibility toggle
645 $jsid = $this->rcCacheIndex
;
646 # onclick handler to toggle hidden/expanded
647 $toggleLink = "onclick='toggleVisibility($jsid); return false'";
649 $expandTitle = htmlspecialchars( wfMsg('rc-enhanced-expand') );
650 $closeTitle = htmlspecialchars( wfMsg('rc-enhanced-hide') );
652 $tl = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
653 $tl .= "<span id='mw-rc-closearrow-$jsid' class='mw-changeslist-hidden' style='display:none'><a href='#' $toggleLink title='$closeTitle'>" . $this->downArrow() . "</a></span>";
654 $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.' ';
657 $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot );
660 $r .= ' '.$block[0]->timestamp
.' </tt></td><td>';
664 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
666 $r .= $this->maybeWatchedLink( $block[0]->link
, $block[0]->watched
);
669 $r .= $wgContLang->getDirMark();
671 $curIdEq = 'curid=' . $curId;
674 static $nchanges = array();
675 if ( !isset( $nchanges[$n] ) ) {
676 $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) );
682 if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
684 } else if( $isnew ) {
687 $r .= $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
688 $nchanges[$n], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
694 // don't show history link for logs
695 } else if( $namehidden ||
!$block[0]->getTitle()->exists() ) {
696 $r .= $this->message
['semicolon-separator'] . $this->message
['hist'] . ')';
698 $r .= $this->message
['semicolon-separator'] . $this->skin
->makeKnownLinkObj( $block[0]->getTitle(),
699 $this->message
['hist'], $curIdEq . '&action=history' ) . ')';
703 # Character difference (does not apply if only log items)
704 if( $wgRCShowChangedSize && !$alllogs ) {
706 $first = count($block) - 1;
707 # Some events (like logs) have an "empty" size, so we need to skip those...
708 while( $last < $first && $block[$last]->mAttribs
['rc_new_len'] === NULL ) {
711 while( $first > $last && $block[$first]->mAttribs
['rc_old_len'] === NULL ) {
715 $chardiff = $rcObj->getCharacterDifference( $block[$first]->mAttribs
['rc_old_len'],
716 $block[$last]->mAttribs
['rc_new_len'] );
718 if( $chardiff == '' ) {
721 $r .= ' ' . $chardiff. ' . . ';
726 $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers
);
728 $r .= "</td></tr></table>\n";
731 $r .= '<div id="mw-rc-subentries-'.$jsid.'" class="mw-changeslist-hidden"><table cellpadding="0" cellspacing="0" border="0" style="background: none">';
732 foreach( $block as $rcObj ) {
733 # Get rc_xxxx variables
734 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
735 extract( $rcObj->mAttribs
);
737 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
738 $r .= '<tr><td valign="top">';
739 $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
740 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
741 $r .= ' </tt></td><td valign="top">';
744 if( $rc_this_oldid != 0 ) {
745 $o = 'oldid='.$rc_this_oldid;
748 if( $rc_type == RC_LOG
) {
749 $link = '<tt>'.$rcObj->timestamp
.'</tt> ';
751 } else if( !ChangesList
::userCan($rcObj,Revision
::DELETED_TEXT
) ) {
752 $link = '<span class="history-deleted"><tt>'.$rcObj->timestamp
.'</tt></span> ';
754 $rcIdEq = ($rcObj->unpatrolled
&& $rc_type == RC_NEW
) ?
'&rcid='.$rcObj->mAttribs
['rc_id'] : '';
756 $link = '<tt>'.$this->skin
->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp
, $curIdEq.'&'.$o.$rcIdEq ).'</tt>';
757 if( $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) )
758 $link = '<span class="history-deleted">'.$link.'</span> ';
762 if ( !$rc_type == RC_LOG ||
$rc_type == RC_NEW
) {
764 $r .= $rcObj->curlink
;
765 $r .= $this->message
['semicolon-separator'];
766 $r .= $rcObj->lastlink
;
772 if( $wgRCShowChangedSize ) {
773 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : $rcObj->getCharacterDifference() . ' . . ' ) ;
776 $r .= $rcObj->userlink
;
777 $r .= $rcObj->usertalklink
;
779 parent
::insertAction( $r, $rcObj );
781 parent
::insertComment( $r, $rcObj );
782 # Mark revision as deleted
783 if( !$rc_log_type && $this->isDeleted($rcObj,Revision
::DELETED_TEXT
) ) {
784 $r .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
787 $r .= "</td></tr>\n";
789 $r .= "</table></div>\n";
791 $this->rcCacheIndex++
;
796 * Generate HTML for an arrow or placeholder graphic
797 * @param string $dir one of '', 'd', 'l', 'r'
798 * @param string $alt text
799 * @param string $title text
800 * @return string HTML <img> tag
802 protected function arrow( $dir, $alt='', $title='' ) {
804 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
805 $encAlt = htmlspecialchars( $alt );
806 $encTitle = htmlspecialchars( $title );
807 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
811 * Generate HTML for a right- or left-facing arrow,
812 * depending on language direction.
813 * @return string HTML <img> tag
815 protected function sideArrow() {
817 $dir = $wgContLang->isRTL() ?
'l' : 'r';
818 return $this->arrow( $dir, '+', wfMsg('rc-enhanced-expand') );
822 * Generate HTML for a down-facing arrow
823 * depending on language direction.
824 * @return string HTML <img> tag
826 protected function downArrow() {
827 return $this->arrow( 'd', '-', wfMsg('rc-enhanced-hide') );
831 * Generate HTML for a spacer image
832 * @return string HTML <img> tag
834 protected function spacerArrow() {
835 return $this->arrow( '', codepointToUtf8( 0xa0 ) ); // non-breaking space
839 * Add a set of spaces
840 * @return string HTML <td> tag
842 protected function spacerIndent() {
843 return ' ';
847 * Enhanced RC ungrouped line.
848 * @return string a HTML formated line (generated using $r)
850 protected function recentChangesBlockLine( $rcObj ) {
851 global $wgContLang, $wgRCShowChangedSize;
853 # Get rc_xxxx variables
854 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
855 extract( $rcObj->mAttribs
);
856 $curIdEq = 'curid='.$rc_cur_id;
858 $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>';
860 $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . ' ';
863 if( $rc_type == RC_MOVE ||
$rc_type == RC_MOVE_OVER_REDIRECT
) {
864 $r .= ' '; // 4 flags -> 4 spaces
866 $r .= $this->recentChangesFlags( $rc_type == RC_NEW
, $rc_minor, $rcObj->unpatrolled
, ' ', $rc_bot );
868 $r .= ' '.$rcObj->timestamp
.' </tt></td><td>';
870 # Article or log link
872 $logtitle = Title
::newFromText( "Log/$rc_log_type", NS_SPECIAL
);
873 $logname = LogPage
::logName( $rc_log_type );
874 $r .= '(' . $this->skin
->makeKnownLinkObj($logtitle, $logname ) . ')';
875 } else if( !$this->userCan($rcObj,Revision
::DELETED_TEXT
) ) {
876 $r .= '<span class="history-deleted">' . $rcObj->link
. '</span>';
878 $r .= $this->maybeWatchedLink( $rcObj->link
, $rcObj->watched
);
881 # Diff and hist links
882 if ( $rc_type != RC_LOG
) {
883 $r .= ' ('. $rcObj->difflink
. $this->message
['semicolon-separator'];
884 $r .= $this->skin
->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')';
889 if( $wgRCShowChangedSize ) {
890 $r .= ( $rcObj->getCharacterDifference() == '' ?
'' : $rcObj->getCharacterDifference() . ' . . ' ) ;
894 $r .= ' '.$rcObj->userlink
. $rcObj->usertalklink
;
896 # Log action (if any)
898 if( $this->isDeleted($rcObj,LogPage
::DELETED_ACTION
) ) {
899 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
901 $r .= ' ' . LogPage
::actionText( $rc_log_type, $rc_log_action, $rcObj->getTitle(),
902 $this->skin
, LogPage
::extractParams($rc_params), true, true );
906 # Edit or log comment
907 if( $rc_type != RC_MOVE
&& $rc_type != RC_MOVE_OVER_REDIRECT
) {
909 if ( $this->isDeleted($rcObj,LogPage
::DELETED_COMMENT
) ) {
910 $r .= ' <span class="history-deleted">' . wfMsg('rev-deleted-comment') . '</span>';
912 $r .= $this->skin
->commentBlock( $rc_comment, $rcObj->getTitle() );
916 # Show how many people are watching this if enabled
917 $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers
);
919 $r .= "</td></tr></table>\n";
924 * If enhanced RC is in use, this function takes the previously cached
925 * RC lines, arranges them, and outputs the HTML
927 protected function recentChangesBlock() {
928 if( count ( $this->rc_cache
) == 0 ) {
932 foreach( $this->rc_cache
as $block ) {
933 if( count( $block ) < 2 ) {
934 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
936 $blockOut .= $this->recentChangesBlockGroup( $block );
940 return '<div>'.$blockOut.'</div>';
944 * Returns text for the end of RC
945 * If enhanced RC is in use, returns pretty much all the text
947 public function endRecentChangesList() {
948 return $this->recentChangesBlock() . parent
::endRecentChangesList();