00001 <?php
00002
00006 class RCCacheEntry extends RecentChange {
00007 var $secureName, $link;
00008 var $curlink , $difflink, $lastlink, $usertalklink, $versionlink;
00009 var $userlink, $timestamp, $watched;
00010
00011 static function newFromParent( $rc ) {
00012 $rc2 = new RCCacheEntry;
00013 $rc2->mAttribs = $rc->mAttribs;
00014 $rc2->mExtra = $rc->mExtra;
00015 return $rc2;
00016 }
00017 }
00018
00025 class ChangesList {
00026 # Called by history lists and recent changes
00027 public $skin;
00028
00033 public function __construct( &$skin ) {
00034 $this->skin =& $skin;
00035 $this->preCacheMessages();
00036 }
00037
00045 public static function newFromUser( &$user ) {
00046 $sk = $user->getSkin();
00047 $list = NULL;
00048 if( wfRunHooks( 'FetchChangesList', array( &$user, &$sk, &$list ) ) ) {
00049 return $user->getOption( 'usenewrc' ) ?
00050 new EnhancedChangesList( $sk ) : new OldChangesList( $sk );
00051 } else {
00052 return $list;
00053 }
00054 }
00055
00060 private function preCacheMessages() {
00061 if( !isset( $this->message ) ) {
00062 foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last '.
00063 'blocklink history boteditletter semicolon-separator' ) as $msg ) {
00064 $this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
00065 }
00066 }
00067 }
00068
00069
00079 protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = ' ', $bot = false ) {
00080 $f = $new ?
00081 '<span class="newpage">' . $this->message['newpageletter'] . '</span>' : $nothing;
00082 $f .= $minor ?
00083 '<span class="minor">' . $this->message['minoreditletter'] . '</span>' : $nothing;
00084 $f .= $bot ? '<span class="bot">' . $this->message['boteditletter'] . '</span>' : $nothing;
00085 $f .= $patrolled ? '<span class="unpatrolled">!</span>' : $nothing;
00086 return $f;
00087 }
00088
00093 public function beginRecentChangesList() {
00094 $this->rc_cache = array();
00095 $this->rcMoveIndex = 0;
00096 $this->rcCacheIndex = 0;
00097 $this->lastdate = '';
00098 $this->rclistOpen = false;
00099 return '';
00100 }
00101
00108 public static function showCharacterDifference( $old, $new ) {
00109 global $wgRCChangedSizeThreshold, $wgLang;
00110 $szdiff = $new - $old;
00111 $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape' ), $wgLang->formatNum( $szdiff ) );
00112 if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
00113 $tag = 'strong';
00114 } else {
00115 $tag = 'span';
00116 }
00117 if( $szdiff === 0 ) {
00118 return "<$tag class='mw-plusminus-null'>($formatedSize)</$tag>";
00119 } elseif( $szdiff > 0 ) {
00120 return "<$tag class='mw-plusminus-pos'>(+$formatedSize)</$tag>";
00121 } else {
00122 return "<$tag class='mw-plusminus-neg'>($formatedSize)</$tag>";
00123 }
00124 }
00125
00130 public function endRecentChangesList() {
00131 if( $this->rclistOpen ) {
00132 return "</ul>\n";
00133 } else {
00134 return '';
00135 }
00136 }
00137
00138 protected function insertMove( &$s, $rc ) {
00139 # Diff
00140 $s .= '(' . $this->message['diff'] . ') (';
00141 # Hist
00142 $s .= $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), $this->message['hist'],
00143 'action=history' ) . ') . . ';
00144 # "[[x]] moved to [[y]]"
00145 $msg = ( $rc->mAttribs['rc_type'] == RC_MOVE ) ? '1movedto2' : '1movedto2_redir';
00146 $s .= wfMsg( $msg, $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
00147 $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
00148 }
00149
00150 protected function insertDateHeader( &$s, $rc_timestamp ) {
00151 global $wgLang;
00152 # Make date header if necessary
00153 $date = $wgLang->date( $rc_timestamp, true, true );
00154 if( $date != $this->lastdate ) {
00155 if( '' != $this->lastdate ) {
00156 $s .= "</ul>\n";
00157 }
00158 $s .= '<h4>'.$date."</h4>\n<ul class=\"special\">";
00159 $this->lastdate = $date;
00160 $this->rclistOpen = true;
00161 }
00162 }
00163
00164 protected function insertLog( &$s, $title, $logtype ) {
00165 $logname = LogPage::logName( $logtype );
00166 $s .= '(' . $this->skin->makeKnownLinkObj($title, $logname ) . ')';
00167 }
00168
00169 protected function insertDiffHist( &$s, &$rc, $unpatrolled ) {
00170 # Diff link
00171 if( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) {
00172 $diffLink = $this->message['diff'];
00173 } else if( !$this->userCan($rc,Revision::DELETED_TEXT) ) {
00174 $diffLink = $this->message['diff'];
00175 } else {
00176 $rcidparam = $unpatrolled ? array( 'rcid' => $rc->mAttribs['rc_id'] ) : array();
00177 $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'],
00178 wfArrayToCGI( array(
00179 'curid' => $rc->mAttribs['rc_cur_id'],
00180 'diff' => $rc->mAttribs['rc_this_oldid'],
00181 'oldid' => $rc->mAttribs['rc_last_oldid'] ),
00182 $rcidparam ),
00183 '', '', ' tabindex="'.$rc->counter.'"');
00184 }
00185 $s .= '('.$diffLink.') (';
00186 # History link
00187 $s .= $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['hist'],
00188 wfArrayToCGI( array(
00189 'curid' => $rc->mAttribs['rc_cur_id'],
00190 'action' => 'history' ) ) );
00191 $s .= ') . . ';
00192 }
00193
00194 protected function insertArticleLink( &$s, &$rc, $unpatrolled, $watched ) {
00195 global $wgContLang;
00196 # If it's a new article, there is no diff link, but if it hasn't been
00197 # patrolled yet, we need to give users a way to do so
00198 $params = ( $unpatrolled && $rc->mAttribs['rc_type'] == RC_NEW ) ?
00199 'rcid='.$rc->mAttribs['rc_id'] : '';
00200 if( $this->isDeleted($rc,Revision::DELETED_TEXT) ) {
00201 $articlelink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '', $params );
00202 $articlelink = '<span class="history-deleted">'.$articlelink.'</span>';
00203 } else {
00204 $articlelink = ' '. $this->skin->makeKnownLinkObj( $rc->getTitle(), '', $params );
00205 }
00206 # Bolden pages watched by this user
00207 if( $watched ) {
00208 $articlelink = "<strong class=\"mw-watched\">{$articlelink}</strong>";
00209 }
00210 # RTL/LTR marker
00211 $articlelink .= $wgContLang->getDirMark();
00212
00213 wfRunHooks( 'ChangesListInsertArticleLink',
00214 array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched) );
00215
00216 $s .= " $articlelink";
00217 }
00218
00219 protected function insertTimestamp( &$s, $rc ) {
00220 global $wgLang;
00221 $s .= $this->message['semicolon-separator'] .
00222 $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . ';
00223 }
00224
00226 public function insertUserRelatedLinks( &$s, &$rc ) {
00227 if( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
00228 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
00229 } else {
00230 $s .= $this->skin->userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
00231 $s .= $this->skin->userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
00232 }
00233 }
00234
00236 protected function insertAction( &$s, &$rc ) {
00237 if( $rc->mAttribs['rc_type'] == RC_LOG ) {
00238 if( $this->isDeleted( $rc, LogPage::DELETED_ACTION ) ) {
00239 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
00240 } else {
00241 $s .= ' '.LogPage::actionText( $rc->mAttribs['rc_log_type'], $rc->mAttribs['rc_log_action'],
00242 $rc->getTitle(), $this->skin, LogPage::extractParams( $rc->mAttribs['rc_params'] ), true, true );
00243 }
00244 }
00245 }
00246
00248 protected function insertComment( &$s, &$rc ) {
00249 if( $rc->mAttribs['rc_type'] != RC_MOVE && $rc->mAttribs['rc_type'] != RC_MOVE_OVER_REDIRECT ) {
00250 if( $this->isDeleted( $rc, Revision::DELETED_COMMENT ) ) {
00251 $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span>';
00252 } else {
00253 $s .= $this->skin->commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
00254 }
00255 }
00256 }
00257
00262 public static function usePatrol() {
00263 global $wgUser;
00264 return $wgUser->useRCPatrol();
00265 }
00266
00270 protected function numberofWatchingusers( $count ) {
00271 global $wgLang;
00272 static $cache = array();
00273 if( $count > 0 ) {
00274 if( !isset( $cache[$count] ) ) {
00275 $cache[$count] = wfMsgExt( 'number_of_watching_users_RCview',
00276 array('parsemag', 'escape' ), $wgLang->formatNum( $count ) );
00277 }
00278 return $cache[$count];
00279 } else {
00280 return '';
00281 }
00282 }
00283
00290 public static function isDeleted( $rc, $field ) {
00291 return ( $rc->mAttribs['rc_deleted'] & $field ) == $field;
00292 }
00293
00301 public static function userCan( $rc, $field ) {
00302 if( ( $rc->mAttribs['rc_deleted'] & $field ) == $field ) {
00303 global $wgUser;
00304 $permission = ( $rc->mAttribs['rc_deleted'] & Revision::DELETED_RESTRICTED ) == Revision::DELETED_RESTRICTED
00305 ? 'suppressrevision'
00306 : 'deleterevision';
00307 wfDebug( "Checking for $permission due to $field match on {$rc->mAttribs['rc_deleted']}\n" );
00308 return $wgUser->isAllowed( $permission );
00309 } else {
00310 return true;
00311 }
00312 }
00313
00314 protected function maybeWatchedLink( $link, $watched=false ) {
00315 if( $watched ) {
00316 return '<strong class="mw-watched">' . $link . '</strong>';
00317 } else {
00318 return '<span class="mw-rc-unwatched">' . $link . '</span>';
00319 }
00320 }
00321
00323 protected function insertRollback( &$s, &$rc ) {
00324 global $wgUser;
00325 if( !$rc->mAttribs['rc_new'] && $rc->mAttribs['rc_this_oldid'] && $rc->mAttribs['rc_cur_id'] ) {
00326 $page = $rc->getTitle();
00329 if ($wgUser->isAllowed('rollback') && $rc->mAttribs['page_latest'] == $rc->mAttribs['rc_this_oldid'] )
00330 {
00331 $rev = new Revision( array(
00332 'id' => $rc->mAttribs['rc_this_oldid'],
00333 'user' => $rc->mAttribs['rc_user'],
00334 'user_text' => $rc->mAttribs['rc_user_text'],
00335 'deleted' => $rc->mAttribs['rc_deleted']
00336 ) );
00337 $rev->setTitle( $page );
00338 $s .= ' '.$this->skin->generateRollback( $rev );
00339 }
00340 }
00341 }
00342
00343 protected function insertTags( &$s, &$rc, &$classes ) {
00344 if ( empty($rc->mAttribs['ts_tags']) )
00345 return;
00346
00347 list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $rc->mAttribs['ts_tags'], 'changeslist' );
00348 $classes = array_merge( $classes, $newClasses );
00349 $s .= ' ' . $tagSummary;
00350 }
00351
00352 protected function insertExtra( &$s, &$rc, &$classes ) {
00353 ## Empty, used for subclassers to add anything special.
00354 }
00355 }
00356
00357
00361 class OldChangesList extends ChangesList {
00365 public function recentChangesLine( &$rc, $watched = false, $linenumber = NULL ) {
00366 global $wgContLang, $wgLang, $wgRCShowChangedSize, $wgUser;
00367 wfProfileIn( __METHOD__ );
00368 # Should patrol-related stuff be shown?
00369 $unpatrolled = $wgUser->useRCPatrol() && !$rc->mAttribs['rc_patrolled'];
00370
00371 $dateheader = '';
00372 $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
00373
00374 $s = '';
00375 $classes = array();
00376
00377 if( $linenumber ) {
00378 if( $linenumber & 1 ) {
00379 $classes[] = 'mw-line-odd';
00380 }
00381 else {
00382 $classes[] = 'mw-line-even';
00383 }
00384 }
00385
00386
00387 if( $rc->mAttribs['rc_type'] == RC_MOVE || $rc->mAttribs['rc_type'] == RC_MOVE_OVER_REDIRECT ) {
00388 $this->insertMove( $s, $rc );
00389
00390 } elseif( $rc->mAttribs['rc_log_type'] ) {
00391 $logtitle = Title::newFromText( 'Log/'.$rc->mAttribs['rc_log_type'], NS_SPECIAL );
00392 $this->insertLog( $s, $logtitle, $rc->mAttribs['rc_log_type'] );
00393
00394 } elseif( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
00395 list( $name, $subpage ) = SpecialPage::resolveAliasWithSubpage( $rc->mAttribs['rc_title'] );
00396 if( $name == 'Log' ) {
00397 $this->insertLog( $s, $rc->getTitle(), $subpage );
00398 }
00399
00400 } else {
00401 $this->insertDiffHist( $s, $rc, $unpatrolled );
00402 # M, N, b and ! (minor, new, bot and unpatrolled)
00403 $s .= $this->recentChangesFlags( $rc->mAttribs['rc_new'], $rc->mAttribs['rc_minor'],
00404 $unpatrolled, '', $rc->mAttribs['rc_bot'] );
00405 $this->insertArticleLink( $s, $rc, $unpatrolled, $watched );
00406 }
00407 # Edit/log timestamp
00408 $this->insertTimestamp( $s, $rc );
00409 # Bytes added or removed
00410 if( $wgRCShowChangedSize ) {
00411 $cd = $rc->getCharacterDifference();
00412 if( $cd != '' ) {
00413 $s .= "$cd . . ";
00414 }
00415 }
00416 # User tool links
00417 $this->insertUserRelatedLinks( $s, $rc );
00418 # Log action text (if any)
00419 $this->insertAction( $s, $rc );
00420 # Edit or log comment
00421 $this->insertComment( $s, $rc );
00422 # Tags
00423 $this->insertTags( $s, $rc, $classes );
00424 # Rollback
00425 $this->insertRollback( $s, $rc );
00426 # For subclasses
00427 $this->insertExtra( $s, $rc, $classes );
00428
00429 # Mark revision as deleted if so
00430 if( !$rc->mAttribs['rc_log_type'] && $this->isDeleted($rc,Revision::DELETED_TEXT) ) {
00431 $s .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
00432 }
00433 # How many users watch this page
00434 if( $rc->numberofWatchingusers > 0 ) {
00435 $s .= ' ' . wfMsgExt( 'number_of_watching_users_RCview',
00436 array( 'parsemag', 'escape' ), $wgLang->formatNum( $rc->numberofWatchingusers ) );
00437 }
00438
00439 wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) );
00440
00441 wfProfileOut( __METHOD__ );
00442 return "$dateheader<li class=\"".implode( ' ', $classes )."\">$s</li>\n";
00443 }
00444 }
00445
00446
00450 class EnhancedChangesList extends ChangesList {
00455 public function beginRecentChangesList() {
00456 global $wgStylePath, $wgJsMimeType, $wgStyleVersion;
00457 $this->rc_cache = array();
00458 $this->rcMoveIndex = 0;
00459 $this->rcCacheIndex = 0;
00460 $this->lastdate = '';
00461 $this->rclistOpen = false;
00462 $script = Xml::tags( 'script', array(
00463 'type' => $wgJsMimeType,
00464 'src' => $wgStylePath . "/common/enhancedchanges.js?$wgStyleVersion" ), '' );
00465 return $script;
00466 }
00470 public function recentChangesLine( &$baseRC, $watched = false ) {
00471 global $wgLang, $wgContLang, $wgUser;
00472
00473 wfProfileIn( __METHOD__ );
00474
00475 # Create a specialised object
00476 $rc = RCCacheEntry::newFromParent( $baseRC );
00477
00478 # Extract fields from DB into the function scope (rc_xxxx variables)
00479
00480
00481 extract( $rc->mAttribs );
00482 $curIdEq = 'curid=' . $rc_cur_id;
00483
00484 # If it's a new day, add the headline and flush the cache
00485 $date = $wgLang->date( $rc_timestamp, true );
00486 $ret = '';
00487 if( $date != $this->lastdate ) {
00488 # Process current cache
00489 $ret = $this->recentChangesBlock();
00490 $this->rc_cache = array();
00491 $ret .= "<h4>{$date}</h4>\n";
00492 $this->lastdate = $date;
00493 }
00494
00495 # Should patrol-related stuff be shown?
00496 if( $wgUser->useRCPatrol() ) {
00497 $rc->unpatrolled = !$rc_patrolled;
00498 } else {
00499 $rc->unpatrolled = false;
00500 }
00501
00502 $showdifflinks = true;
00503 # Make article link
00504
00505 if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
00506 $msg = ( $rc_type == RC_MOVE ) ? "1movedto2" : "1movedto2_redir";
00507 $clink = wfMsg( $msg, $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
00508 $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
00509
00510 } else if( $rc->unpatrolled && $rc_type == RC_NEW ) {
00511 $clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
00512
00513 } else if( $rc_type == RC_LOG ) {
00514 if( $rc_log_type ) {
00515 $logtitle = SpecialPage::getTitleFor( 'Log', $rc_log_type );
00516 $clink = '(' . $this->skin->makeKnownLinkObj( $logtitle,
00517 LogPage::logName($rc_log_type) ) . ')';
00518 } else {
00519 $clink = $this->skin->makeLinkObj( $rc->getTitle(), '' );
00520 }
00521 $watched = false;
00522
00523 } elseif( $rc_namespace == NS_SPECIAL ) {
00524 list( $specialName, $logtype ) = SpecialPage::resolveAliasWithSubpage( $rc_title );
00525 if ( $specialName == 'Log' ) {
00526 # Log updates, etc
00527 $logname = LogPage::logName( $logtype );
00528 $clink = '(' . $this->skin->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
00529 } else {
00530 wfDebug( "Unexpected special page in recentchanges\n" );
00531 $clink = '';
00532 }
00533
00534 } else {
00535 $clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '' );
00536 }
00537
00538 # Don't show unusable diff links
00539 if ( !ChangesList::userCan($rc,Revision::DELETED_TEXT) ) {
00540 $showdifflinks = false;
00541 }
00542
00543 $time = $wgContLang->time( $rc_timestamp, true, true );
00544 $rc->watched = $watched;
00545 $rc->link = $clink;
00546 $rc->timestamp = $time;
00547 $rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
00548
00549 # Make "cur" and "diff" links
00550 if( $rc->unpatrolled ) {
00551 $rcIdQuery = "&rcid={$rc_id}";
00552 } else {
00553 $rcIdQuery = '';
00554 }
00555 $querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid";
00556 $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery";
00557 $aprops = ' tabindex="'.$baseRC->counter.'"';
00558 $curLink = $this->skin->makeKnownLinkObj( $rc->getTitle(),
00559 $this->message['cur'], $querycur, '' ,'', $aprops );
00560
00561 # Make "diff" an "cur" links
00562 if( !$showdifflinks ) {
00563 $curLink = $this->message['cur'];
00564 $diffLink = $this->message['diff'];
00565 } else if( in_array( $rc_type, array(RC_NEW,RC_LOG,RC_MOVE,RC_MOVE_OVER_REDIRECT) ) ) {
00566 $curLink = ($rc_type != RC_NEW) ? $this->message['cur'] : $curLink;
00567 $diffLink = $this->message['diff'];
00568 } else {
00569 $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'],
00570 $querydiff, '' ,'', $aprops );
00571 }
00572
00573 # Make "last" link
00574 if( !$showdifflinks || !$rc_last_oldid ) {
00575 $lastLink = $this->message['last'];
00576 } else if( $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
00577 $lastLink = $this->message['last'];
00578 } else {
00579 $lastLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['last'],
00580 $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
00581 }
00582
00583 # Make user links
00584 if( $this->isDeleted($rc,Revision::DELETED_USER) ) {
00585 $rc->userlink = ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
00586 } else {
00587 $rc->userlink = $this->skin->userLink( $rc_user, $rc_user_text );
00588 $rc->usertalklink = $this->skin->userToolLinks( $rc_user, $rc_user_text );
00589 }
00590
00591 $rc->lastlink = $lastLink;
00592 $rc->curlink = $curLink;
00593 $rc->difflink = $diffLink;
00594
00595 # Put accumulated information into the cache, for later display
00596 # Page moves go on their own line
00597 $title = $rc->getTitle();
00598 $secureName = $title->getPrefixedDBkey();
00599 if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
00600 # Use an @ character to prevent collision with page names
00601 $this->rc_cache['@@' . ($this->rcMoveIndex++)] = array($rc);
00602 } else {
00603 # Logs are grouped by type
00604 if( $rc_type == RC_LOG ){
00605 $secureName = SpecialPage::getTitleFor( 'Log', $rc_log_type )->getPrefixedDBkey();
00606 }
00607 if( !isset( $this->rc_cache[$secureName] ) ) {
00608 $this->rc_cache[$secureName] = array();
00609 }
00610
00611 array_push( $this->rc_cache[$secureName], $rc );
00612 }
00613
00614 wfProfileOut( __METHOD__ );
00615
00616 return $ret;
00617 }
00618
00622 protected function recentChangesBlockGroup( $block ) {
00623 global $wgLang, $wgContLang, $wgRCShowChangedSize;
00624
00625 wfProfileIn( __METHOD__ );
00626
00627 $r = '<table cellpadding="0" cellspacing="0" border="0" style="background: none"><tr>';
00628
00629 # Collate list of users
00630 $userlinks = array();
00631 # Other properties
00632 $unpatrolled = false;
00633 $isnew = false;
00634 $curId = $currentRevision = 0;
00635 # Some catalyst variables...
00636 $namehidden = true;
00637 $allLogs = true;
00638 foreach( $block as $rcObj ) {
00639 $oldid = $rcObj->mAttribs['rc_last_oldid'];
00640 if( $rcObj->mAttribs['rc_new'] ) {
00641 $isnew = true;
00642 }
00643
00644
00645 if( !$this->isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) {
00646 $namehidden = false;
00647 }
00648 $u = $rcObj->userlink;
00649 if( !isset( $userlinks[$u] ) ) {
00650 $userlinks[$u] = 0;
00651 }
00652 if( $rcObj->unpatrolled ) {
00653 $unpatrolled = true;
00654 }
00655 if( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
00656 $allLogs = false;
00657 }
00658 # Get the latest entry with a page_id and oldid
00659 # since logs may not have these.
00660 if( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
00661 $curId = $rcObj->mAttribs['rc_cur_id'];
00662 }
00663 if( !$currentRevision && $rcObj->mAttribs['rc_this_oldid'] ) {
00664 $currentRevision = $rcObj->mAttribs['rc_this_oldid'];
00665 }
00666
00667 $bot = $rcObj->mAttribs['rc_bot'];
00668 $userlinks[$u]++;
00669 }
00670
00671 # Sort the list and convert to text
00672 krsort( $userlinks );
00673 asort( $userlinks );
00674 $users = array();
00675 foreach( $userlinks as $userlink => $count) {
00676 $text = $userlink;
00677 $text .= $wgContLang->getDirMark();
00678 if( $count > 1 ) {
00679 $text .= ' (' . $wgLang->formatNum( $count ) . '×)';
00680 }
00681 array_push( $users, $text );
00682 }
00683
00684 $users = ' <span class="changedby">[' .
00685 implode( $this->message['semicolon-separator'], $users ) . ']</span>';
00686
00687 # ID for JS visibility toggle
00688 $jsid = $this->rcCacheIndex;
00689 # onclick handler to toggle hidden/expanded
00690 $toggleLink = "onclick='toggleVisibility($jsid); return false'";
00691 # Title for <a> tags
00692 $expandTitle = htmlspecialchars( wfMsg( 'rc-enhanced-expand' ) );
00693 $closeTitle = htmlspecialchars( wfMsg( 'rc-enhanced-hide' ) );
00694
00695 $tl = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
00696 $tl .= "<span id='mw-rc-closearrow-$jsid' class='mw-changeslist-hidden' style='display:none'><a href='#' $toggleLink title='$closeTitle'>" . $this->downArrow() . "</a></span>";
00697 $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.' ';
00698
00699 # Main line
00700 $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot );
00701
00702 # Timestamp
00703 $r .= ' '.$block[0]->timestamp.' </tt></td><td>';
00704
00705 # Article link
00706 if( $namehidden ) {
00707 $r .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
00708 } else if( $allLogs ) {
00709 $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
00710 } else {
00711 $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled, $block[0]->watched );
00712 }
00713
00714 $r .= $wgContLang->getDirMark();
00715
00716 $curIdEq = 'curid=' . $curId;
00717 # Changes message
00718 $n = count($block);
00719 static $nchanges = array();
00720 if ( !isset( $nchanges[$n] ) ) {
00721 $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) );
00722 }
00723 # Total change link
00724 $r .= ' ';
00725 if( !$allLogs ) {
00726 $r .= '(';
00727 if( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT ) ) {
00728 $r .= $nchanges[$n];
00729 } else if( $isnew ) {
00730 $r .= $nchanges[$n];
00731 } else {
00732 $r .= $this->skin->makeKnownLinkObj( $block[0]->getTitle(),
00733 $nchanges[$n], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
00734 }
00735 }
00736
00737 # History
00738 if( $allLogs ) {
00739
00740 } else if( $namehidden || !$block[0]->getTitle()->exists() ) {
00741 $r .= $this->message['semicolon-separator'] . $this->message['hist'] . ')';
00742 } else {
00743 $r .= $this->message['semicolon-separator'] . $this->skin->makeKnownLinkObj( $block[0]->getTitle(),
00744 $this->message['hist'], $curIdEq . '&action=history' ) . ')';
00745 }
00746 $r .= ' . . ';
00747
00748 # Character difference (does not apply if only log items)
00749 if( $wgRCShowChangedSize && !$allLogs ) {
00750 $last = 0;
00751 $first = count($block) - 1;
00752 # Some events (like logs) have an "empty" size, so we need to skip those...
00753 while( $last < $first && $block[$last]->mAttribs['rc_new_len'] === NULL ) {
00754 $last++;
00755 }
00756 while( $first > $last && $block[$first]->mAttribs['rc_old_len'] === NULL ) {
00757 $first--;
00758 }
00759 # Get net change
00760 $chardiff = $rcObj->getCharacterDifference( $block[$first]->mAttribs['rc_old_len'],
00761 $block[$last]->mAttribs['rc_new_len'] );
00762
00763 if( $chardiff == '' ) {
00764 $r .= ' ';
00765 } else {
00766 $r .= ' ' . $chardiff. ' . . ';
00767 }
00768 }
00769
00770 $r .= $users;
00771 $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers);
00772
00773 $r .= "</td></tr></table>\n";
00774
00775 # Sub-entries
00776 $r .= '<div id="mw-rc-subentries-'.$jsid.'" class="mw-changeslist-hidden">';
00777 $r .= '<table cellpadding="0" cellspacing="0" border="0" style="background: none">';
00778 foreach( $block as $rcObj ) {
00779 # Extract fields from DB into the function scope (rc_xxxx variables)
00780
00781
00782 # Classes to apply -- TODO implement
00783 $classes = array();
00784 extract( $rcObj->mAttribs );
00785
00786 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
00787 $r .= '<tr><td valign="top">';
00788 $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
00789 $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled, ' ', $rc_bot );
00790 $r .= ' </tt></td><td valign="top">';
00791
00792 $o = '';
00793 if( $rc_this_oldid != 0 ) {
00794 $o = 'oldid='.$rc_this_oldid;
00795 }
00796 # Log timestamp
00797 if( $rc_type == RC_LOG ) {
00798 $link = '<tt>'.$rcObj->timestamp.'</tt> ';
00799 # Revision link
00800 } else if( !ChangesList::userCan($rcObj,Revision::DELETED_TEXT) ) {
00801 $link = '<span class="history-deleted"><tt>'.$rcObj->timestamp.'</tt></span> ';
00802 } else {
00803 $rcIdEq = ($rcObj->unpatrolled && $rc_type == RC_NEW) ?
00804 '&rcid='.$rcObj->mAttribs['rc_id'] : '';
00805 $link = '<tt>'.$this->skin->makeKnownLinkObj( $rcObj->getTitle(),
00806 $rcObj->timestamp, $curIdEq.'&'.$o.$rcIdEq ).'</tt>';
00807 if( $this->isDeleted($rcObj,Revision::DELETED_TEXT) )
00808 $link = '<span class="history-deleted">'.$link.'</span> ';
00809 }
00810 $r .= $link;
00811
00812 if ( !$rc_type == RC_LOG || $rc_type == RC_NEW ) {
00813 $r .= ' (';
00814 $r .= $rcObj->curlink;
00815 $r .= $this->message['semicolon-separator'];
00816 $r .= $rcObj->lastlink;
00817 $r .= ')';
00818 }
00819 $r .= ' . . ';
00820
00821 # Character diff
00822 if( $wgRCShowChangedSize ) {
00823 $r .= ( $rcObj->getCharacterDifference() == '' ? '' : $rcObj->getCharacterDifference() . ' . . ' ) ;
00824 }
00825 # User links
00826 $r .= $rcObj->userlink;
00827 $r .= $rcObj->usertalklink;
00828
00829 $this->insertAction( $r, $rcObj );
00830
00831 $this->insertComment( $r, $rcObj );
00832 # Rollback
00833 $this->insertRollback( $r, $rcObj );
00834 # Tags
00835 $this->insertTags( $r, $rcObj, $classes );
00836
00837 # Mark revision as deleted
00838 if( !$rc_log_type && $this->isDeleted($rcObj,Revision::DELETED_TEXT) ) {
00839 $r .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
00840 }
00841
00842 $r .= "</td></tr>\n";
00843 }
00844 $r .= "</table></div>\n";
00845
00846 $this->rcCacheIndex++;
00847
00848 wfProfileOut( __METHOD__ );
00849
00850 return $r;
00851 }
00852
00860 protected function arrow( $dir, $alt='', $title='' ) {
00861 global $wgStylePath;
00862 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
00863 $encAlt = htmlspecialchars( $alt );
00864 $encTitle = htmlspecialchars( $title );
00865 return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" title=\"$encTitle\" />";
00866 }
00867
00873 protected function sideArrow() {
00874 global $wgContLang;
00875 $dir = $wgContLang->isRTL() ? 'l' : 'r';
00876 return $this->arrow( $dir, '+', wfMsg( 'rc-enhanced-expand' ) );
00877 }
00878
00884 protected function downArrow() {
00885 return $this->arrow( 'd', '-', wfMsg( 'rc-enhanced-hide' ) );
00886 }
00887
00892 protected function spacerArrow() {
00893 return $this->arrow( '', codepointToUtf8( 0xa0 ) );
00894 }
00895
00900 protected function spacerIndent() {
00901 return ' ';
00902 }
00903
00908 protected function recentChangesBlockLine( $rcObj ) {
00909 global $wgContLang, $wgRCShowChangedSize;
00910
00911 wfProfileIn( __METHOD__ );
00912
00913 # Extract fields from DB into the function scope (rc_xxxx variables)
00914
00915
00916 $classes = array();
00917 extract( $rcObj->mAttribs );
00918 $curIdEq = "curid={$rc_cur_id}";
00919
00920 $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>';
00921 $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . ' ';
00922 # Flag and Timestamp
00923 if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
00924 $r .= ' ';
00925 } else {
00926 $r .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled, ' ', $rc_bot );
00927 }
00928 $r .= ' '.$rcObj->timestamp.' </tt></td><td>';
00929 # Article or log link
00930 if( $rc_log_type ) {
00931 $logtitle = Title::newFromText( "Log/$rc_log_type", NS_SPECIAL );
00932 $logname = LogPage::logName( $rc_log_type );
00933 $r .= '(' . $this->skin->makeKnownLinkObj($logtitle, $logname ) . ')';
00934 } else {
00935 $this->insertArticleLink( $r, $rcObj, $rcObj->unpatrolled, $rcObj->watched );
00936 }
00937 # Diff and hist links
00938 if ( $rc_type != RC_LOG ) {
00939 $r .= ' ('. $rcObj->difflink . $this->message['semicolon-separator'];
00940 $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), $this->message['hist'],
00941 $curIdEq.'&action=history' ) . ')';
00942 }
00943 $r .= ' . . ';
00944 # Character diff
00945 if( $wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference()) ) {
00946 $r .= "$cd . . ";
00947 }
00948 # User/talk
00949 $r .= ' '.$rcObj->userlink . $rcObj->usertalklink;
00950 # Log action (if any)
00951 if( $rc_log_type ) {
00952 if( $this->isDeleted($rcObj,LogPage::DELETED_ACTION) ) {
00953 $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
00954 } else {
00955 $r .= ' ' . LogPage::actionText( $rc_log_type, $rc_log_action, $rcObj->getTitle(),
00956 $this->skin, LogPage::extractParams($rc_params), true, true );
00957 }
00958 }
00959 $this->insertComment( $r, $rcObj );
00960 $this->insertRollback( $r, $rcObj );
00961 # Tags
00962 $this->insertTags( $r, $rcObj, $classes );
00963 # Show how many people are watching this if enabled
00964 $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers);
00965
00966 $r .= "</td></tr></table>\n";
00967
00968 wfProfileOut( __METHOD__ );
00969
00970 return $r;
00971 }
00972
00977 protected function recentChangesBlock() {
00978 if( count ( $this->rc_cache ) == 0 ) {
00979 return '';
00980 }
00981
00982 wfProfileIn( __METHOD__ );
00983
00984 $blockOut = '';
00985 foreach( $this->rc_cache as $block ) {
00986 if( count( $block ) < 2 ) {
00987 $blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
00988 } else {
00989 $blockOut .= $this->recentChangesBlockGroup( $block );
00990 }
00991 }
00992
00993 wfProfileOut( __METHOD__ );
00994
00995 return '<div>'.$blockOut.'</div>';
00996 }
00997
01002 public function endRecentChangesList() {
01003 return $this->recentChangesBlock() . parent::endRecentChangesList();
01004 }
01005
01006 }