summaryrefslogtreecommitdiff
path: root/includes/ChangesList.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/ChangesList.php')
-rw-r--r--includes/ChangesList.php81
1 files changed, 56 insertions, 25 deletions
diff --git a/includes/ChangesList.php b/includes/ChangesList.php
index 6797bb41..a2c1a265 100644
--- a/includes/ChangesList.php
+++ b/includes/ChangesList.php
@@ -46,10 +46,10 @@ class ChangesList {
* @param $user User to fetch the list class for
* @return ChangesList derivative
*/
- function newFromUser( &$user ) {
+ public static function newFromUser( &$user ) {
$sk =& $user->getSkin();
$list = NULL;
- if( wfRunHooks( 'FetchChangesList', array( &$user, &$skin, &$list ) ) ) {
+ if( wfRunHooks( 'FetchChangesList', array( &$user, &$sk, &$list ) ) ) {
return $user->getOption( 'usenewrc' ) ? new EnhancedChangesList( $sk ) : new OldChangesList( $sk );
} else {
return $list;
@@ -184,7 +184,7 @@ class ChangesList {
$s .= ' '.$articlelink;
}
- function insertTimestamp(&$s, &$rc) {
+ function insertTimestamp(&$s, $rc) {
global $wgLang;
# Timestamp
$s .= '; ' . $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . ';
@@ -212,8 +212,6 @@ class ChangesList {
global $wgUseRCPatrol, $wgUser;
return( $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) );
}
-
-
}
@@ -225,15 +223,13 @@ class OldChangesList extends ChangesList {
* Format a line using the old system (aka without any javascript).
*/
function recentChangesLine( &$rc, $watched = false ) {
- global $wgContLang;
+ global $wgContLang, $wgRCShowChangedSize;
$fname = 'ChangesList::recentChangesLineOld';
wfProfileIn( $fname );
-
# Extract DB fields into local scope
extract( $rc->mAttribs );
- $curIdEq = 'curid=' . $rc_cur_id;
# Should patrol-related stuff be shown?
$unpatrolled = $this->usePatrol() && $rc_patrolled == 0;
@@ -246,8 +242,13 @@ class OldChangesList extends ChangesList {
if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
$this->insertMove( $s, $rc );
// log entries
- } elseif( $rc_namespace == NS_SPECIAL && preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
- $this->insertLog($s, $rc->getTitle(), $matches[1]);
+ } elseif ( $rc_namespace == NS_SPECIAL ) {
+ list( $specialName, $specialSubpage ) = SpecialPage::resolveAliasWithSubpage( $rc_title );
+ if ( $specialName == 'Log' ) {
+ $this->insertLog( $s, $rc->getTitle(), $specialSubpage );
+ } else {
+ wfDebug( "Unexpected special page in recentchanges\n" );
+ }
// all other stuff
} else {
wfProfileIn($fname.'-page');
@@ -264,6 +265,11 @@ class OldChangesList extends ChangesList {
wfProfileIn( $fname.'-rest' );
$this->insertTimestamp($s,$rc);
+
+ if( $wgRCShowChangedSize ) {
+ $s .= ( $rc->getCharacterDifference() == '' ? '' : $rc->getCharacterDifference() . ' . . ' );
+ }
+
$this->insertUserRelatedLinks($s,$rc);
$this->insertComment($s, $rc);
@@ -321,11 +327,16 @@ class EnhancedChangesList extends ChangesList {
$msg = ( $rc_type == RC_MOVE ) ? "1movedto2" : "1movedto2_redir";
$clink = wfMsg( $msg, $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
$this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
- } elseif( $rc_namespace == NS_SPECIAL && preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
- # Log updates, etc
- $logtype = $matches[1];
- $logname = LogPage::logName( $logtype );
- $clink = '(' . $this->skin->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
+ } elseif( $rc_namespace == NS_SPECIAL ) {
+ list( $specialName, $logtype ) = SpecialPage::resolveAliasWithSubpage( $rc_title );
+ if ( $specialName == 'Log' ) {
+ # Log updates, etc
+ $logname = LogPage::logName( $logtype );
+ $clink = '(' . $this->skin->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')';
+ } else {
+ wfDebug( "Unexpected special page in recentchanges\n" );
+ $clink = '';
+ }
} elseif( $rc->unpatrolled && $rc_type == RC_NEW ) {
# Unpatrolled new page, give rc_id in query
$clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
@@ -394,7 +405,7 @@ class EnhancedChangesList extends ChangesList {
* Enhanced RC group
*/
function recentChangesBlockGroup( $block ) {
- global $wgContLang;
+ global $wgContLang, $wgRCShowChangedSize;
$r = '';
# Collate list of users
@@ -403,7 +414,6 @@ class EnhancedChangesList extends ChangesList {
$userlinks = array();
foreach( $block as $rcObj ) {
$oldid = $rcObj->mAttribs['rc_last_oldid'];
- $newid = $rcObj->mAttribs['rc_this_oldid'];
if( $rcObj->mAttribs['rc_new'] ) {
$isnew = true;
}
@@ -447,8 +457,7 @@ class EnhancedChangesList extends ChangesList {
$r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot );
# Timestamp
- $r .= ' '.$block[0]->timestamp.' ';
- $r .= '</tt>';
+ $r .= ' '.$block[0]->timestamp.' </tt>';
# Article link
$r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
@@ -459,13 +468,23 @@ class EnhancedChangesList extends ChangesList {
if( $block[0]->mAttribs['rc_type'] != RC_LOG ) {
# Changes
$r .= ' ('.count($block).' ';
+
if( $isnew ) {
$r .= $this->message['changes'];
} else {
$r .= $this->skin->makeKnownLinkObj( $block[0]->getTitle(),
$this->message['changes'], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
}
- $r .= '; ';
+
+ # Character difference
+ $chardiff = $rcObj->getCharacterDifference( $block[ count( $block ) - 1 ]->mAttribs['rc_old_len'],
+ $block[0]->mAttribs['rc_new_len'] );
+ if( $chardiff == '' ) {
+ $r .= '; ';
+ } else {
+ $r .= '; ' . $chardiff . ' ';
+ }
+
# History
$r .= $this->skin->makeKnownLinkObj( $block[0]->getTitle(),
@@ -508,7 +527,14 @@ class EnhancedChangesList extends ChangesList {
$r .= $rcObj->curlink;
$r .= '; ';
$r .= $rcObj->lastlink;
- $r .= ') . . '.$rcObj->userlink;
+ $r .= ') . . ';
+
+ # Character diff
+ if( $wgRCShowChangedSize ) {
+ $r .= ( $rcObj->getCharacterDifference() == '' ? '' : $rcObj->getCharacterDifference() . ' . . ' ) ;
+ }
+
+ $r .= $rcObj->userlink;
$r .= $rcObj->usertalklink;
$r .= $this->skin->commentBlock( $rc_comment, $rcObj->getTitle() );
$r .= "<br />\n";
@@ -578,7 +604,7 @@ class EnhancedChangesList extends ChangesList {
* @return string a HTML formated line (generated using $r)
*/
function recentChangesBlockLine( $rcObj ) {
- global $wgContLang;
+ global $wgContLang, $wgRCShowChangedSize;
# Get rc_xxxx variables
extract( $rcObj->mAttribs );
@@ -606,10 +632,15 @@ class EnhancedChangesList extends ChangesList {
$r .= ' ('. $rcObj->difflink .'; ';
# Hist
- $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
+ $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ') . . ';
+
+ # Character diff
+ if( $wgRCShowChangedSize ) {
+ $r .= ( $rcObj->getCharacterDifference() == '' ? '' : '&nbsp;' . $rcObj->getCharacterDifference() . ' . . ' ) ;
+ }
# User/talk
- $r .= ') . . '.$rcObj->userlink . $rcObj->usertalklink;
+ $r .= $rcObj->userlink . $rcObj->usertalklink;
# Comment
if( $rc_type != RC_MOVE && $rc_type != RC_MOVE_OVER_REDIRECT ) {
@@ -633,7 +664,7 @@ class EnhancedChangesList extends ChangesList {
return '';
}
$blockOut = '';
- foreach( $this->rc_cache as $secureName => $block ) {
+ foreach( $this->rc_cache as $block ) {
if( count( $block ) < 2 ) {
$blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
} else {