some useless calls / unitialized $matches arrays
[lhc/web/wiklou.git] / includes / ChangesList.php
index ab0b094..9e5e4b1 100644 (file)
@@ -19,6 +19,15 @@ class ChangesList {
                $this->skin =& $skin;
                $this->preCacheMessages();
        }
+       
+       function newFromUser( &$user ) {
+               $sk =& $user->getSkin();
+               if ( $user->getOption('usenewrc') ) {
+                       return new EnhancedChangesList( $sk );
+               } else {
+                       return new OldChangesList( $sk );
+               }
+       }
 
        /**
         * As we use the same small set of messages in various methods and that
@@ -144,7 +153,7 @@ class ChangesList {
        }
 
 
-       function insertMove(&$s) {
+       function insertMove( &$s, $rc ) {
                # Diff
                $s .= '(' . $this->message['diff'] . ') (';
                # Hist
@@ -152,7 +161,7 @@ class ChangesList {
                        ') . . ';
 
                # "[[x]] moved to [[y]]"
-               $msg = ( $rc_type == RC_MOVE ) ? '1movedto2' : '1movedto2_redir';
+               $msg = ( $rc->mAttribs['rc_type'] == RC_MOVE ) ? '1movedto2' : '1movedto2_redir';
                $s .= wfMsg( $msg, $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
                        $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
        }
@@ -182,15 +191,24 @@ class ChangesList {
                if ( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) {
                        $diffLink = $this->message['diff'];
                } else {
-                       $rcidparam = $unpatrolled ? '&rcid='.$rc->mAttribs['rc_id'] : '';
+                       $rcidparam = $unpatrolled
+                               ? array( 'rcid' => $rc->mAttribs['rc_id'] )
+                               : array();
                        $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'],
-                                               $curIdEq.'&diff='.$rc->mAttribs['rc_this_oldid'].'&oldid='.$rc->mAttribs['rc_last_oldid'].$rcidparam,
-                                               '', '', ' tabindex="'.$rc->counter.'"');
+                               wfArrayToCGI( array(
+                                       'curid' => $rc->mAttribs['rc_cur_id'],
+                                       'diff'  => $rc->mAttribs['rc_this_oldid'],
+                                       'oldid' => $rc->mAttribs['rc_last_oldid'] ),
+                                       $rcidparam ),
+                               '', '', ' tabindex="'.$rc->counter.'"');
                }
                $s .= '('.$diffLink.') (';
 
                # History link
-               $s .= $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['hist'], 'curid='.$this->mAttribs['rc_cur_id'].'&action=history' );
+               $s .= $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['hist'],
+                       wfArrayToCGI( array(
+                               'curid' => $rc->mAttribs['rc_cur_id'],
+                               'action' => 'history' ) ) );
                $s .= ') . . ';
        }
 
@@ -198,11 +216,10 @@ class ChangesList {
                # Article link
                # If it's a new article, there is no diff link, but if it hasn't been
                # patrolled yet, we need to give users a way to do so
-               if ( $unpatrolled && $rc->mAttribs['rc_type'] == RC_NEW ) {
-                       $articlelink .= ' '. $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'rcid='.$this->mAttribs['rc_id'] );
-               } else {
-                       $articlelink .= ' '. $this->skin->makeKnownLinkObj( $rc->getTitle(), '' );
-               }
+               $params = ( $unpatrolled && $rc->mAttribs['rc_type'] == RC_NEW )
+                       ? 'rcid='.$rc->mAttribs['rc_id']
+                       : '';
+               $articlelink = ' '. $this->skin->makeKnownLinkObj( $rc->getTitle(), '', $params );
                if($watched) $articlelink = '<strong>'.$articlelink.'</strong>';
 
                $s .= ' '.$articlelink;
@@ -263,7 +280,7 @@ class ChangesList {
                # Block link
                $blockLinkPage = Title::makeTitle( NS_SPECIAL, 'Blockip' );
                $blockLink = $this->skin->makeKnownLinkObj( $blockLinkPage,
-               htmlspecialchars( $this->message['blocklink'] ), 'ip=' . urlencode( $rc->mAttribs['user_text'] ) );
+               htmlspecialchars( $this->message['blocklink'] ), 'ip=' . urlencode( $rc->mAttribs['rc_user_text'] ) );
                $s .= $blockLink;
        }
 
@@ -285,8 +302,8 @@ class OldChangesList extends ChangesList {
         * Format a line using the old system (aka without any javascript).
         */
        function recentChangesLine( &$rc, $watched = false ) {
-               global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgUseRCPatrol,
-                       $wgOnlySysopsCanPatrol, $wgSysopUserBans;
+               global $wgLang, $wgContLang, $wgUser, $wgUseRCPatrol;
+               global $wgOnlySysopsCanPatrol, $wgSysopUserBans;
 
                $fname = 'ChangesList::recentChangesLineOld';
                wfProfileIn( $fname );
@@ -306,7 +323,7 @@ class OldChangesList extends ChangesList {
 
                // moved pages
                if ( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
-                       $this->insertMove($s);
+                       $this->insertMove( $s, $rc );
                // log entries
                } elseif( $rc_namespace == NS_SPECIAL && preg_match( '!^Log/(.*)$!', $rc_title, $matches ) ) {
                        $this->insertLog($s, $rc->getTitle(), $matches[1]);
@@ -351,8 +368,8 @@ class EnhancedChangesList extends ChangesList {
         * Format a line for enhanced recentchange (aka with javascript and block of lines).
         */
        function recentChangesLine( &$baseRC, $watched = false ) {
-               global $wgTitle, $wgLang, $wgContLang, $wgUser,
-                       $wgUseRCPatrol, $wgOnlySysopsCanPatrol, $wgSysopUserBans;
+               global $wgLang, $wgContLang, $wgUser, $wgUseRCPatrol;
+               global $wgOnlySysopsCanPatrol, $wgSysopUserBans;
 
                # Create a specialised object
                $rc = RCCacheEntry::newFromParent( $baseRC ) ;
@@ -410,16 +427,17 @@ class EnhancedChangesList extends ChangesList {
                } else {
                        $rcIdQuery = '';
                }
-               $query = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid";
+               $querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid";
+               $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid";
                $aprops = ' tabindex="'.$baseRC->counter.'"';
-               $curLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['cur'], $query, '' ,'' , $aprops );
+               $curLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['cur'], $querycur, '' ,'' , $aprops );
                if( $rc_type == RC_NEW || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
                        if( $rc_type != RC_NEW ) {
                                $curLink = $this->message['cur'];
                        }
                        $diffLink = $this->message['diff'];
                } else {
-                       $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'], $query . $rcIdQuery, '' ,'' , $aprops );
+                       $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'], $querydiff, '' ,'' , $aprops );
                }
 
                # Make "last" link
@@ -577,8 +595,8 @@ class EnhancedChangesList extends ChangesList {
                        $r .= '&nbsp;</tt>' ;
 
                        $o = '' ;
-                       if ( $rc_last_oldid != 0 ) {
-                               $o = 'oldid='.$rc_last_oldid ;
+                       if ( $rc_this_oldid != 0 ) {
+                               $o = 'oldid='.$rc_this_oldid ;
                        }
                        if ( $rc_type == RC_LOG ) {
                                $link = $rcObj->timestamp;