Fix NS_PROJECT_TALK (bug #7792)
[lhc/web/wiklou.git] / includes / ChangesList.php
index 80b8cf7..a2c1a26 100644 (file)
@@ -49,7 +49,7 @@ class ChangesList {
        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;
@@ -269,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);
 
@@ -404,7 +405,7 @@ class EnhancedChangesList extends ChangesList {
         * Enhanced RC group
         */
        function recentChangesBlockGroup( $block ) {
-               global $wgContLang;
+               global $wgContLang, $wgRCShowChangedSize;
                $r = '';
 
                # Collate list of users
@@ -413,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;
                        }
@@ -457,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 );
@@ -469,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(),
@@ -518,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";
@@ -588,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 );
@@ -616,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 ) {
@@ -643,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 {