Bugfis, making ?uselang=qqq an invalid language code, see
[lhc/web/wiklou.git] / includes / ChangesList.php
index e3f6d68..9518ebd 100644 (file)
@@ -108,7 +108,7 @@ class ChangesList {
        public static function showCharacterDifference( $old, $new ) {
                global $wgRCChangedSizeThreshold, $wgLang;
                $szdiff = $new - $old;
-               $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape'), $wgLang->formatNum($szdiff) );
+               $formatedSize = wfMsgExt( 'rc-change-size', array( 'parsemag', 'escape' ), $wgLang->formatNum( $szdiff ) );
                if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
                        $tag = 'strong';
                } else {
@@ -139,8 +139,8 @@ class ChangesList {
                # Diff
                $s .= '(' . $this->message['diff'] . ') (';
                # Hist
-               $s .= $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), $this->message['hist'], 'action=history' ) .
-                       ') . . ';
+               $s .= $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), $this->message['hist'], 
+                       'action=history' ) . ') . . ';
                # "[[x]] moved to [[y]]"
                $msg = ( $rc->mAttribs['rc_type'] == RC_MOVE ) ? '1movedto2' : '1movedto2_redir';
                $s .= wfMsg( $msg, $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
@@ -168,13 +168,12 @@ class ChangesList {
 
        protected function insertDiffHist( &$s, &$rc, $unpatrolled ) {
                # Diff link
-               if( !$this->userCan($rc,Revision::DELETED_TEXT) ) {
+               if( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) {
                        $diffLink = $this->message['diff'];
-               } else if( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) {
+               } else if( !$this->userCan($rc,Revision::DELETED_TEXT) ) {
                        $diffLink = $this->message['diff'];
                } else {
-                       $rcidparam = $unpatrolled ?
-                               array( 'rcid' => $rc->mAttribs['rc_id'] ) : array();
+                       $rcidparam = $unpatrolled ? array( 'rcid' => $rc->mAttribs['rc_id'] ) : array();
                        $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'],
                                wfArrayToCGI( array(
                                        'curid' => $rc->mAttribs['rc_cur_id'],
@@ -219,13 +218,14 @@ class ChangesList {
 
        protected function insertTimestamp( &$s, $rc ) {
                global $wgLang;
-               $s .= $this->message['semicolon-separator'] . $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . ';
+               $s .= $this->message['semicolon-separator'] . 
+                       $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . ';
        }
 
        /** Insert links to user page, user talk page and eventually a blocking link */
-       public function insertUserRelatedLinks(&$s, &$rc) {
-               if ( $this->isDeleted($rc,Revision::DELETED_USER) ) {
-                  $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
+       public function insertUserRelatedLinks( &$s, &$rc ) {
+               if( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
+                  $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
                } else {
                  $s .= $this->skin->userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
                  $s .= $this->skin->userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
@@ -233,26 +233,22 @@ class ChangesList {
        }
 
        /** insert a formatted action */
-       protected function insertAction(&$s, &$rc) {
-               # Add action
+       protected function insertAction( &$s, &$rc ) {
                if( $rc->mAttribs['rc_type'] == RC_LOG ) {
-                       // log action
-                       if ( $this->isDeleted($rc,LogPage::DELETED_ACTION) ) {
-                               $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
+                       if( $this->isDeleted( $rc, LogPage::DELETED_ACTION ) ) {
+                               $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
                        } else {
-                               $s .= ' ' . LogPage::actionText( $rc->mAttribs['rc_log_type'], $rc->mAttribs['rc_log_action'],
-                                       $rc->getTitle(), $this->skin, LogPage::extractParams($rc->mAttribs['rc_params']), true, true );
+                               $s .= ' '.LogPage::actionText( $rc->mAttribs['rc_log_type'], $rc->mAttribs['rc_log_action'],
+                                       $rc->getTitle(), $this->skin, LogPage::extractParams( $rc->mAttribs['rc_params'] ), true, true );
                        }
                }
        }
 
        /** insert a formatted comment */
-       protected function insertComment(&$s, &$rc) {
-               # Add comment
+       protected function insertComment( &$s, &$rc ) {
                if( $rc->mAttribs['rc_type'] != RC_MOVE && $rc->mAttribs['rc_type'] != RC_MOVE_OVER_REDIRECT ) {
-                       // log comment
-                       if ( $this->isDeleted($rc,Revision::DELETED_COMMENT) ) {
-                               $s .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
+                       if( $this->isDeleted( $rc, Revision::DELETED_COMMENT ) ) {
+                               $s .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span>';
                        } else {
                                $s .= $this->skin->commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
                        }
@@ -274,10 +270,10 @@ class ChangesList {
        protected function numberofWatchingusers( $count ) {
                global $wgLang;
                static $cache = array();
-               if ( $count > 0 ) {
-                       if ( !isset( $cache[$count] ) ) {
-                               $cache[$count] = wfMsgExt('number_of_watching_users_RCview',
-                                       array('parsemag', 'escape'), $wgLang->formatNum($count));
+               if( $count > 0 ) {
+                       if( !isset( $cache[$count] ) ) {
+                               $cache[$count] = wfMsgExt( 'number_of_watching_users_RCview',
+                                       array('parsemag', 'escape' ), $wgLang->formatNum( $count ) );
                        }
                        return $cache[$count];
                } else {
@@ -292,7 +288,7 @@ class ChangesList {
         * @return bool
         */
        public static function isDeleted( $rc, $field ) {
-               return ($rc->mAttribs['rc_deleted'] & $field) == $field;
+               return ( $rc->mAttribs['rc_deleted'] & $field ) == $field;
        }
 
        /**
@@ -308,7 +304,7 @@ class ChangesList {
                        $permission = ( $rc->mAttribs['rc_deleted'] & Revision::DELETED_RESTRICTED ) == Revision::DELETED_RESTRICTED
                                ? 'suppressrevision'
                                : 'deleterevision';
-                       wfDebug( "Checking for $permission due to $field match on $rc->mAttribs['rc_deleted']\n" );
+                       wfDebug( "Checking for $permission due to $field match on {$rc->mAttribs['rc_deleted']}\n" );
                        return $wgUser->isAllowed( $permission );
                } else {
                        return true;
@@ -317,12 +313,44 @@ class ChangesList {
 
        protected function maybeWatchedLink( $link, $watched=false ) {
                if( $watched ) {
-                       // FIXME: css style might be more appropriate
                        return '<strong class="mw-watched">' . $link . '</strong>';
                } else {
                        return '<span class="mw-rc-unwatched">' . $link . '</span>';
                }
        }
+       
+       /** Inserts a rollback link */
+       protected function insertRollback( &$s, &$rc ) {
+               global $wgUser;
+               if( !$rc->mAttribs['rc_new'] && $rc->mAttribs['rc_this_oldid'] && $wgUser->isAllowed('rollback') ) {
+                       $page = $rc->getTitle();
+                       /** Check for rollback and edit permissions, disallow special pages, and only
+                         * show a link on the top-most revision */
+                       if( $rc->mAttribs['rc_cur_id'] && $page->getLatestRevID() == $rc->mAttribs['rc_this_oldid'] 
+                               && $page->quickUserCan('rollback') && $page->quickUserCan('edit') )
+                       {
+                               $rev = new Revision( array(
+                                       'id'        => $rc->mAttribs['rc_this_oldid'],
+                                       'user'      => $rc->mAttribs['rc_user'],
+                                       'user_text' => $rc->mAttribs['rc_user_text']
+                               ) );
+                               $s .= ' '.$this->skin->generateRollback( $rev );
+                       }
+               }       
+       }
+
+       protected function insertTags( &$s, &$rc, &$classes ) {
+               if ( empty($rc->mAttribs['ts_tags']) )
+                       return;
+                       
+               list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $rc->mAttribs['ts_tags'], 'changeslist' );
+               $classes = array_merge( $classes, $newClasses );
+               $s .= ' ' . $tagSummary;
+       }
+
+       protected function insertExtra( &$s, &$rc, &$classes ) {
+               ## Empty, used for subclassers to add anything special.
+       }
 }
 
 
@@ -333,79 +361,92 @@ class OldChangesList extends ChangesList {
        /**
         * Format a line using the old system (aka without any javascript).
         */
-       public function recentChangesLine( &$rc, $watched = false ) {
-               global $wgContLang, $wgRCShowChangedSize, $wgUser;
-
+       public function recentChangesLine( &$rc, $watched = false, $linenumber = NULL ) {
+               global $wgContLang, $wgLang, $wgRCShowChangedSize, $wgUser;
                wfProfileIn( __METHOD__ );
-
-               # Extract DB fields into local scope
-               extract( $rc->mAttribs );
-
                # Should patrol-related stuff be shown?
-               $unpatrolled = $wgUser->useRCPatrol() && $rc_patrolled == 0;
+               $unpatrolled = $wgUser->useRCPatrol() && !$rc->mAttribs['rc_patrolled'];
 
-               $dateheader = ""; // $s now contains only <li>...</li>, for hooks' convenience.
-               $this->insertDateHeader($dateheader,$rc_timestamp);
+               $dateheader = ''; // $s now contains only <li>...</li>, for hooks' convenience.
+               $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
 
                $s = '';
+               $classes = array();
+               // use mw-line-even/mw-line-odd class only if linenumber is given (feature from bug 14468)
+               if( $linenumber ) {
+                       if( $linenumber & 1 ) {
+                               $classes[] = 'mw-line-odd';
+                       }
+                       else {
+                               $classes[] = 'mw-line-even';
+                       }
+               }
 
                // Moved pages
-               if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
+               if( $rc->mAttribs['rc_type'] == RC_MOVE || $rc->mAttribs['rc_type'] == RC_MOVE_OVER_REDIRECT ) {
                        $this->insertMove( $s, $rc );
                // Log entries
-               } elseif( $rc_log_type ) {
-                       $logtitle = Title::newFromText( "Log/$rc_log_type", NS_SPECIAL );
-                       $this->insertLog( $s, $logtitle, $rc_log_type );
+               } elseif( $rc->mAttribs['rc_log_type'] ) {
+                       $logtitle = Title::newFromText( 'Log/'.$rc->mAttribs['rc_log_type'], NS_SPECIAL );
+                       $this->insertLog( $s, $logtitle, $rc->mAttribs['rc_log_type'] );
                // Log entries (old format) or log targets, and special pages
-               } 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" );
+               } elseif( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
+                       list( $name, $subpage ) = SpecialPage::resolveAliasWithSubpage( $rc->mAttribs['rc_title'] );
+                       if( $name == 'Log' ) {
+                               $this->insertLog( $s, $rc->getTitle(), $subpage );
                        }
                // Regular entries
                } else {
-                       $this->insertDiffHist($s, $rc, $unpatrolled);
+                       $this->insertDiffHist( $s, $rc, $unpatrolled );
                        # M, N, b and ! (minor, new, bot and unpatrolled)
-                       $s .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $unpatrolled, '', $rc_bot );
-                       $this->insertArticleLink($s, $rc, $unpatrolled, $watched);
+                       $s .= $this->recentChangesFlags( $rc->mAttribs['rc_new'], $rc->mAttribs['rc_minor'],
+                               $unpatrolled, '', $rc->mAttribs['rc_bot'] );
+                       $this->insertArticleLink( $s, $rc, $unpatrolled, $watched );
                }
-
-               $this->insertTimestamp($s,$rc);
-
+               # Edit/log timestamp
+               $this->insertTimestamp( $s, $rc );
+               # Bytes added or removed
                if( $wgRCShowChangedSize ) {
-                       $s .= ( $rc->getCharacterDifference() == '' ? '' : $rc->getCharacterDifference() . ' . . ' );
+                       $cd = $rc->getCharacterDifference();
+                       if( $cd != '' ) {
+                               $s .= "$cd  . . ";
+                       }
                }
                # User tool links
-               $this->insertUserRelatedLinks($s,$rc);
+               $this->insertUserRelatedLinks( $s, $rc );
                # Log action text (if any)
-               $this->insertAction($s, $rc);
+               $this->insertAction( $s, $rc );
                # Edit or log comment
-               $this->insertComment($s, $rc);
-
+               $this->insertComment( $s, $rc );
+               # Tags
+               $this->insertTags( $s, $rc, $classes );
+               # Rollback
+               $this->insertRollback( $s, $rc );
+               # For subclasses
+               $this->insertExtra( $s, $rc, $classes );
+               
                # Mark revision as deleted if so
-               if ( !$rc_log_type && $this->isDeleted($rc,Revision::DELETED_TEXT) )
+               if( !$rc->mAttribs['rc_log_type'] && $this->isDeleted($rc,Revision::DELETED_TEXT) ) {
                   $s .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
-               if($rc->numberofWatchingusers > 0) {
-                       $s .= ' ' . wfMsg('number_of_watching_users_RCview',  $wgContLang->formatNum($rc->numberofWatchingusers));
+               }
+               # How many users watch this page
+               if( $rc->numberofWatchingusers > 0 ) {
+                       $s .= ' ' . wfMsgExt( 'number_of_watching_users_RCview', 
+                               array( 'parsemag', 'escape' ), $wgLang->formatNum( $rc->numberofWatchingusers ) );
                }
 
                wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) );
-               
-               $s = "<li>$s</li>\n";
 
                wfProfileOut( __METHOD__ );
-               return $dateheader . $s;
+               return "$dateheader<li class=\"".implode( ' ', $classes )."\">$s</li>\n";
        }
 }
 
 
 /**
- * Generate a list of changes using an Enhanced system (use javascript).
+ * Generate a list of changes using an Enhanced system (uses javascript).
  */
 class EnhancedChangesList extends ChangesList {
-
        /**
        *  Add the JavaScript file for enhanced changeslist
        *  @ return string
@@ -432,11 +473,13 @@ class EnhancedChangesList extends ChangesList {
                $rc = RCCacheEntry::newFromParent( $baseRC );
 
                # Extract fields from DB into the function scope (rc_xxxx variables)
+               // FIXME: Would be good to replace this extract() call with something
+               // that explicitly initializes variables.
                extract( $rc->mAttribs );
                $curIdEq = 'curid=' . $rc_cur_id;
 
                # If it's a new day, add the headline and flush the cache
-               $date = $wgLang->date( $rc_timestamp, true);
+               $date = $wgLang->date( $rc_timestamp, true );
                $ret = '';
                if( $date != $this->lastdate ) {
                        # Process current cache
@@ -460,17 +503,6 @@ 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(), '' ) );
-               // Log entries (old format) and special pages
-               } 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 = '';
-                       }
                // New unpatrolled pages
                } else if( $rc->unpatrolled && $rc_type == RC_NEW ) {
                        $clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
@@ -478,11 +510,23 @@ class EnhancedChangesList extends ChangesList {
                } else if( $rc_type == RC_LOG ) {
                        if( $rc_log_type ) {
                                $logtitle = SpecialPage::getTitleFor( 'Log', $rc_log_type );
-                               $clink = '(' . $this->skin->makeKnownLinkObj( $logtitle, LogPage::logName($rc_log_type) ) . ')';
+                               $clink = '(' . $this->skin->makeKnownLinkObj( $logtitle, 
+                                       LogPage::logName($rc_log_type) ) . ')';
                        } else {
                                $clink = $this->skin->makeLinkObj( $rc->getTitle(), '' );
                        }
                        $watched = false;
+               // Log entries (old format) and special pages
+               } 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 = '';
+                       }
                // Edits
                } else {
                        $clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '' );
@@ -508,25 +552,25 @@ class EnhancedChangesList extends ChangesList {
                $querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid";
                $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery";
                $aprops = ' tabindex="'.$baseRC->counter.'"';
-               $curLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['cur'], $querycur, '' ,'', $aprops );
+               $curLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), 
+                       $this->message['cur'], $querycur, '' ,'', $aprops );
 
                # Make "diff" an "cur" links
                if( !$showdifflinks ) {
                   $curLink = $this->message['cur'];
                   $diffLink = $this->message['diff'];
-               } else 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'];
-                       }
+               } else if( in_array( $rc_type, array(RC_NEW,RC_LOG,RC_MOVE,RC_MOVE_OVER_REDIRECT) ) ) {
+                       $curLink = ($rc_type != RC_NEW) ? $this->message['cur'] : $curLink;
                        $diffLink = $this->message['diff'];
                } else {
-                       $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'], $querydiff, '' ,'', $aprops );
+                       $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'], 
+                               $querydiff, '' ,'', $aprops );
                }
 
                # Make "last" link
-               if( !$showdifflinks ) {
+               if( !$showdifflinks || !$rc_last_oldid ) {
                    $lastLink = $this->message['last'];
-               } else if( $rc_last_oldid == 0 || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
+               } else if( $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
                        $lastLink = $this->message['last'];
                } else {
                        $lastLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['last'],
@@ -535,7 +579,7 @@ class EnhancedChangesList extends ChangesList {
 
                # Make user links
                if( $this->isDeleted($rc,Revision::DELETED_USER) ) {
-                       $rc->userlink = ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
+                       $rc->userlink = ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
                } else {
                        $rc->userlink = $this->skin->userLink( $rc_user, $rc_user_text );
                        $rc->usertalklink = $this->skin->userToolLinks( $rc_user, $rc_user_text );
@@ -580,7 +624,7 @@ class EnhancedChangesList extends ChangesList {
                $curId = $currentRevision = 0;
                # Some catalyst variables...
                $namehidden = true;
-               $alllogs = true;
+               $allLogs = true;
                foreach( $block as $rcObj ) {
                        $oldid = $rcObj->mAttribs['rc_last_oldid'];
                        if( $rcObj->mAttribs['rc_new'] ) {
@@ -599,7 +643,7 @@ class EnhancedChangesList extends ChangesList {
                                $unpatrolled = true;
                        }
                        if( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
-                               $alllogs = false;
+                               $allLogs = false;
                        }
                        # Get the latest entry with a page_id and oldid
                        # since logs may not have these.
@@ -627,17 +671,18 @@ class EnhancedChangesList extends ChangesList {
                        array_push( $users, $text );
                }
 
-               $users = ' <span class="changedby">[' . implode( $this->message['semicolon-separator'], $users ) . ']</span>';
+               $users = ' <span class="changedby">[' . 
+                       implode( $this->message['semicolon-separator'], $users ) . ']</span>';
 
                # ID for JS visibility toggle
                $jsid = $this->rcCacheIndex;
                # onclick handler to toggle hidden/expanded
                $toggleLink = "onclick='toggleVisibility($jsid); return false'";
                # Title for <a> tags
-               $expandTitle = htmlspecialchars( wfMsg('rc-enhanced-expand') );
-               $closeTitle = htmlspecialchars( wfMsg('rc-enhanced-hide') );
+               $expandTitle = htmlspecialchars( wfMsg( 'rc-enhanced-expand' ) );
+               $closeTitle = htmlspecialchars( wfMsg( 'rc-enhanced-hide' ) );
 
-               $tl  = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
+               $tl = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
                $tl .= "<span id='mw-rc-closearrow-$jsid' class='mw-changeslist-hidden' style='display:none'><a href='#' $toggleLink title='$closeTitle'>" . $this->downArrow() . "</a></span>";
                $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.'&nbsp;';
 
@@ -649,7 +694,9 @@ class EnhancedChangesList extends ChangesList {
 
                # Article link
                if( $namehidden ) {
-                       $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
+                       $r .= ' <span class="history-deleted">' . wfMsgHtml( 'rev-deleted-event' ) . '</span>';
+               } else if( $allLogs ) {
+                       $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
                } else {
                        $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled, $block[0]->watched );
                }
@@ -665,9 +712,9 @@ class EnhancedChangesList extends ChangesList {
                }
                # Total change link
                $r .= ' ';
-               if( !$alllogs ) {
+               if( !$allLogs ) {
                        $r .= '(';
-                       if( !ChangesList::userCan($rcObj,Revision::DELETED_TEXT) ) {
+                       if( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT ) ) {
                                $r .= $nchanges[$n];
                        } else if( $isnew ) {
                                $r .= $nchanges[$n];
@@ -678,7 +725,7 @@ class EnhancedChangesList extends ChangesList {
                }
 
                # History
-               if( $alllogs ) {
+               if( $allLogs ) {
                        // don't show history link for logs
                } else if( $namehidden || !$block[0]->getTitle()->exists() ) {
                        $r .= $this->message['semicolon-separator'] . $this->message['hist'] . ')';
@@ -689,7 +736,7 @@ class EnhancedChangesList extends ChangesList {
                $r .= ' . . ';
 
                # Character difference (does not apply if only log items)
-               if( $wgRCShowChangedSize && !$alllogs ) {
+               if( $wgRCShowChangedSize && !$allLogs ) {
                        $last = 0;
                        $first = count($block) - 1;
                        # Some events (like logs) have an "empty" size, so we need to skip those...
@@ -719,7 +766,9 @@ class EnhancedChangesList extends ChangesList {
                $r .= '<div id="mw-rc-subentries-'.$jsid.'" class="mw-changeslist-hidden">';
                $r .= '<table cellpadding="0" cellspacing="0"  border="0" style="background: none">';
                foreach( $block as $rcObj ) {
-                       # Get rc_xxxx variables
+                       # Extract fields from DB into the function scope (rc_xxxx variables)
+                       // FIXME: Would be good to replace this extract() call with something
+                       // that explicitly initializes variables.
                        extract( $rcObj->mAttribs );
 
                        #$r .= '<tr><td valign="top">'.$this->spacerArrow();
@@ -765,9 +814,11 @@ class EnhancedChangesList extends ChangesList {
                        $r .= $rcObj->userlink;
                        $r .= $rcObj->usertalklink;
                        // log action
-                       parent::insertAction( $r, $rcObj );
+                       $this->insertAction( $r, $rcObj );
                        // log comment
-                       parent::insertComment( $r, $rcObj );
+                       $this->insertComment( $r, $rcObj );
+                       # Rollback
+                       $this->insertRollback( $r, $rcObj );
                        # Mark revision as deleted
                        if( !$rc_log_type && $this->isDeleted($rcObj,Revision::DELETED_TEXT) ) {
                                $r .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
@@ -804,7 +855,7 @@ class EnhancedChangesList extends ChangesList {
        protected function sideArrow() {
                global $wgContLang;
                $dir = $wgContLang->isRTL() ? 'l' : 'r';
-               return $this->arrow( $dir, '+', wfMsg('rc-enhanced-expand') );
+               return $this->arrow( $dir, '+', wfMsg( 'rc-enhanced-expand' ) );
        }
 
        /**
@@ -813,7 +864,7 @@ class EnhancedChangesList extends ChangesList {
         * @return string HTML <img> tag
         */
        protected function downArrow() {
-               return $this->arrow( 'd', '-', wfMsg('rc-enhanced-hide') );
+               return $this->arrow( 'd', '-', wfMsg( 'rc-enhanced-hide' ) );
        }
 
        /**
@@ -838,7 +889,9 @@ class EnhancedChangesList extends ChangesList {
         */
        protected function recentChangesBlockLine( $rcObj ) {
                global $wgContLang, $wgRCShowChangedSize;
-               # Get rc_xxxx variables
+               # Extract fields from DB into the function scope (rc_xxxx variables)
+               // FIXME: Would be good to replace this extract() call with something
+               // that explicitly initializes variables.
                extract( $rcObj->mAttribs );
                $curIdEq = "curid={$rc_cur_id}";
 
@@ -861,13 +914,14 @@ class EnhancedChangesList extends ChangesList {
                }
                # Diff and hist links
                if ( $rc_type != RC_LOG ) {
-                  $r .= ' ('. $rcObj->difflink . $this->message['semicolon-separator'];
-                  $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')';
+                       $r .= ' ('. $rcObj->difflink . $this->message['semicolon-separator'];
+                       $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), $this->message['hist'], 
+                               $curIdEq.'&action=history' ) . ')';
                }
                $r .= ' . . ';
                # Character diff
-               if( $wgRCShowChangedSize ) {
-                       $r .= ( $rcObj->getCharacterDifference() == '' ? '' : $rcObj->getCharacterDifference() . ' . . ' ) ;
+               if( $wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference()) ) {
+                       $r .= "$cd . . ";
                }
                # User/talk
                $r .= ' '.$rcObj->userlink . $rcObj->usertalklink;
@@ -880,15 +934,8 @@ class EnhancedChangesList extends ChangesList {
                                        $this->skin, LogPage::extractParams($rc_params), true, true );
                        }
                }
-               # Edit or log comment
-               if( $rc_type != RC_MOVE && $rc_type != RC_MOVE_OVER_REDIRECT ) {
-                       // log comment
-                       if ( $this->isDeleted($rcObj,LogPage::DELETED_COMMENT) ) {
-                          $r .= ' <span class="history-deleted">' . wfMsg('rev-deleted-comment') . '</span>';
-                       } else {
-                         $r .= $this->skin->commentBlock( $rc_comment, $rcObj->getTitle() );
-                       }
-               }
+               $this->insertComment( $r, $rcObj );
+               $this->insertRollback( $r, $rcObj );
                # Show how many people are watching this if enabled
                $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers);