* (bug 9403) Sanitize newlines from search term input
[lhc/web/wiklou.git] / includes / ChangesList.php
index a2c1a26..39b94a1 100644 (file)
@@ -1,15 +1,7 @@
 <?php
-/**
- * @package MediaWiki
- * Contain class to show various lists of change:
- * - what's link here
- * - related changes
- * - recent changes
- */
 
 /**
  * @todo document
- * @package MediaWiki
  */
 class RCCacheEntry extends RecentChange
 {
@@ -17,8 +9,7 @@ class RCCacheEntry extends RecentChange
        var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ;
        var $userlink, $timestamp, $watched;
 
-       function newFromParent( $rc )
-       {
+       static function newFromParent( $rc ) {
                $rc2 = new RCCacheEntry;
                $rc2->mAttribs = $rc->mAttribs;
                $rc2->mExtra = $rc->mExtra;
@@ -27,14 +18,17 @@ class RCCacheEntry extends RecentChange
 } ;
 
 /**
- * @package MediaWiki
+ * Class to show various lists of changes:
+ * - what links here
+ * - related changes
+ * - recent changes
  */
 class ChangesList {
        # Called by history lists and recent changes
        #
 
        /** @todo document */
-       function ChangesList( &$skin ) {
+       function __construct( &$skin ) {
                $this->skin =& $skin;
                $this->preCacheMessages();
        }
@@ -47,7 +41,7 @@ class ChangesList {
         * @return ChangesList derivative
         */
        public static function newFromUser( &$user ) {
-               $sk =& $user->getSkin();
+               $sk = $user->getSkin();
                $list = NULL;
                if( wfRunHooks( 'FetchChangesList', array( &$user, &$sk, &$list ) ) ) {
                        return $user->getOption( 'usenewrc' ) ? new EnhancedChangesList( $sk ) : new OldChangesList( $sk );
@@ -64,7 +58,7 @@ class ChangesList {
                // Precache various messages
                if( !isset( $this->message ) ) {
                        foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last '.
-                               'blocklink changes history boteditletter' ) as $msg ) {
+                               'blocklink history boteditletter semicolon-separator' ) as $msg ) {
                                $this->message[$msg] = wfMsgExt( $msg, array( 'escape') );
                        }
                }
@@ -81,7 +75,7 @@ class ChangesList {
                                : $nothing;
                $f .= $bot ? '<span class="bot">' . $this->message['boteditletter'] . '</span>' : $nothing;
                $f .= $patrolled ? '<span class="unpatrolled">!</span>' : $nothing;
-               return $f;
+               return "<tt>$f</tt>";
        }
 
        /**
@@ -107,6 +101,32 @@ class ChangesList {
                }
        }
 
+       /**
+        * int $field one of DELETED_* bitfield constants
+        * @return bool
+        */
+       function isDeleted( $rc, $field ) {
+               return ($rc->mAttribs['rc_deleted'] & $field) == $field;
+       }
+       
+       /**
+        * Determine if the current user is allowed to view a particular
+        * field of this revision, if it's marked as deleted.
+        * @param int $field
+        * @return bool
+        */
+       function userCan( $rc, $field ) {
+               if( ( $rc->mAttribs['rc_deleted'] & $field ) == $field ) {
+                       global $wgUser;
+                       $permission = ( $rc->mAttribs['rc_deleted'] & Revision::DELETED_RESTRICTED ) == Revision::DELETED_RESTRICTED
+                               ? 'hiderevision'
+                               : 'deleterevision';
+                       wfDebug( "Checking for $permission due to $field match on $rc->mAttribs['rc_deleted']\n" );
+                       return $wgUser->isAllowed( $permission );
+               } else {
+                       return true;
+               }
+       }
 
        function insertMove( &$s, $rc ) {
                # Diff
@@ -142,10 +162,11 @@ class ChangesList {
                $s .= '(' . $this->skin->makeKnownLinkObj($title, $logname ) . ')';
        }
 
-
        function insertDiffHist(&$s, &$rc, $unpatrolled) {
                # Diff link
-               if( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) {
+               if( !$this->userCan($rc,Revision::DELETED_TEXT) ) {
+                       $diffLink = $this->message['diff'];
+               } else if( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) {
                        $diffLink = $this->message['diff'];
                } else {
                        $rcidparam = $unpatrolled
@@ -176,31 +197,63 @@ class ChangesList {
                $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>';
+               if( $this->isDeleted($rc,Revision::DELETED_TEXT) ) {
+                       $articlelink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '', $params );
+                       $articlelink = '<span class="history-deleted">'.$articlelink.'</span>';
+               } else {
+                   $articlelink = ' '. $this->skin->makeKnownLinkObj( $rc->getTitle(), '', $params );
+               }
+               if( $watched )
+                       $articlelink = "<strong class=\"mw-watched\">{$articlelink}</strong>";
                global $wgContLang;
                $articlelink .= $wgContLang->getDirMark();
 
+               wfRunHooks('ChangesListInsertArticleLink',
+                       array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched));
+               
                $s .= ' '.$articlelink;
        }
 
        function insertTimestamp(&$s, $rc) {
                global $wgLang;
                # Timestamp
-               $s .= '; ' . $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 */
        function insertUserRelatedLinks(&$s, &$rc) {
-               $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'] );
+               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'] );
+               }
+       }
+
+       /** insert a formatted action */
+       function insertAction(&$s, &$rc) {
+               # Add action
+               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>';
+                       } 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 );
+                       }
+               }
        }
 
        /** insert a formatted comment */
        function insertComment(&$s, &$rc) {
                # Add comment
                if( $rc->mAttribs['rc_type'] != RC_MOVE && $rc->mAttribs['rc_type'] != RC_MOVE_OVER_REDIRECT ) {
-                       $s .= $this->skin->commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
+                       // log comment
+                       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() );
+                       }
                }
        }
 
@@ -210,7 +263,24 @@ class ChangesList {
         */
        function usePatrol() {
                global $wgUseRCPatrol, $wgUser;
-               return( $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) );
+               return( $wgUseRCPatrol && ($wgUser->isAllowed('patrol') || $wgUser->isAllowed('patrolmarks')) );
+       }
+
+       /**
+        * Returns the string which indicates the number of watching users
+        */
+       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));
+                       }
+                       return $cache[$count];
+               } else {
+                       return '';
+               }
        }
 }
 
@@ -229,6 +299,7 @@ class OldChangesList extends ChangesList {
                wfProfileIn( $fname );
 
                # Extract DB fields into local scope
+               // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
                extract( $rc->mAttribs );
 
                # Should patrol-related stuff be shown?
@@ -238,18 +309,22 @@ class OldChangesList extends ChangesList {
 
                $s .= '<li>';
 
-               // moved pages
+               // Moved pages
                if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
                        $this->insertMove( $s, $rc );
-               // log entries
-               } elseif ( $rc_namespace == NS_SPECIAL ) {
+               // Log entries
+               } elseif( $rc_log_type !='' ) {
+                       $logtitle = Title::newFromText( "Log/$rc_log_type", NS_SPECIAL );
+                       $this->insertLog( $s, $logtitle, $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" );
                        }
-               // all other stuff
+               // Log entries
                } else {
                        wfProfileIn($fname.'-page');
 
@@ -271,8 +346,12 @@ class OldChangesList extends ChangesList {
                }
 
                $this->insertUserRelatedLinks($s,$rc);
+               $this->insertAction($s, $rc);
                $this->insertComment($s, $rc);
-
+               
+               # Mark revision as deleted
+               if ( !$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));
                }
@@ -301,6 +380,7 @@ 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 local variables.
                extract( $rc->mAttribs );
                $curIdEq = 'curid=' . $rc_cur_id;
 
@@ -322,11 +402,14 @@ class EnhancedChangesList extends ChangesList {
                        $rc->unpatrolled = false;
                }
 
+               $showdifflinks = true;
                # Make article link
+               // Page moves
                if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
                        $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' ) {
@@ -337,7 +420,12 @@ class EnhancedChangesList extends ChangesList {
                                wfDebug( "Unexpected special page in recentchanges\n" );
                                $clink = '';
                        }
-               } elseif( $rc->unpatrolled && $rc_type == RC_NEW ) {
+               // Page edits or log entries (group these page)
+               } else if( $this->isDeleted($rc,Revision::DELETED_TEXT) ) {
+                   $clink = '<span class="history-deleted">' . $this->skin->makeKnownLinkObj( $rc->getTitle(), '' ) . '</span>';
+                   if ( !ChangesList::userCan($rc,Revision::DELETED_TEXT) )
+                      $showdifflinks = false;
+               } else if( $rc->unpatrolled && $rc_type == RC_NEW ) {
                        # Unpatrolled new page, give rc_id in query
                        $clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" );
                } else {
@@ -360,7 +448,12 @@ class EnhancedChangesList extends ChangesList {
                $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 );
-               if( $rc_type == RC_NEW || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
+               
+               # 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'];
                        }
@@ -368,23 +461,29 @@ class EnhancedChangesList extends ChangesList {
                } else {
                        $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'], $querydiff, '' ,'', $aprops );
                }
-
+               
                # Make "last" link
-               if( $rc_last_oldid == 0 || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
+               if( !$showdifflinks ) {
+                   $lastLink = $this->message['last'];
+               } else if( $rc_last_oldid == 0 || $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'],
-                         $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
+                       $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
+               }
+               
+               # Make user links
+               if ( $this->isDeleted($rc,Revision::DELETED_USER) ) {
+                       $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 );
                }
-
-               $rc->userlink = $this->skin->userLink( $rc_user, $rc_user_text );
 
                $rc->lastlink = $lastLink;
                $rc->curlink  = $curLink;
                $rc->difflink = $diffLink;
 
-               $rc->usertalklink = $this->skin->userToolLinks( $rc_user, $rc_user_text );
-
                # Put accumulated information into the cache, for later display
                # Page moves go on their own line
                $title = $rc->getTitle();
@@ -405,11 +504,12 @@ class EnhancedChangesList extends ChangesList {
         * Enhanced RC group
         */
        function recentChangesBlockGroup( $block ) {
-               global $wgContLang, $wgRCShowChangedSize;
-               $r = '';
+               global $wgLang, $wgContLang, $wgRCShowChangedSize;
+               $r = '<table cellpadding="0" cellspacing="0"><tr>';
 
                # Collate list of users
                $isnew = false;
+               $namehidden = true;
                $unpatrolled = false;
                $userlinks = array();
                foreach( $block as $rcObj ) {
@@ -417,6 +517,11 @@ class EnhancedChangesList extends ChangesList {
                        if( $rcObj->mAttribs['rc_new'] ) {
                                $isnew = true;
                        }
+                       // If all log actions to this page were hidden, then don't
+                       // give the name of the affected page for this block!
+                       if( !($rcObj->mAttribs['rc_deleted'] & LogPage::DELETED_ACTION) ) {
+                               $namehidden = false;
+                       }
                        $u = $rcObj->userlink;
                        if( !isset( $userlinks[$u] ) ) {
                                $userlinks[$u] = 0;
@@ -441,7 +546,7 @@ class EnhancedChangesList extends ChangesList {
                        array_push( $users, $text );
                }
 
-               $users = ' <span class="changedby">['.implode('; ',$users).']</span>';
+               $users = ' <span class="changedby">[' . implode( $this->message['semicolon-separator'] . ' ', $users ) . ']</span>';
 
                # Arrow
                $rci = 'RCI'.$this->rcCacheIndex;
@@ -450,96 +555,125 @@ class EnhancedChangesList extends ChangesList {
                $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')";
                $tl  = '<span id="'.$rcm.'"><a href="'.$toggleLink.'">' . $this->sideArrow() . '</a></span>';
                $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'">' . $this->downArrow() . '</a></span>';
-               $r .= $tl;
+               $r .= '<td valign="top">'.$tl;
 
                # Main line
-               $r .= '<tt>';
-               $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, '&nbsp;', $bot );
+               $r .= ' '.$this->recentChangesFlags( $isnew, false, $unpatrolled, '&nbsp;', $bot );
 
                # Timestamp
-               $r .= ' '.$block[0]->timestamp.' </tt>';
+               $r .= '&nbsp;<tt>'.$block[0]->timestamp.'&nbsp;</tt></td><td>';
 
                # Article link
-               $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
+               if ( $namehidden )
+                       $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
+               else
+                       $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
                $r .= $wgContLang->getDirMark();
 
                $curIdEq = 'curid=' . $block[0]->mAttribs['rc_cur_id'];
                $currentRevision = $block[0]->mAttribs['rc_this_oldid'];
                if( $block[0]->mAttribs['rc_type'] != RC_LOG ) {
                        # Changes
-                       $r .= ' ('.count($block).' ';
+                       $n = count($block);
+                       static $nchanges = array();
+                       if ( !isset( $nchanges[$n] ) ) {
+                               $nchanges[$n] = wfMsgExt( 'nchanges', array( 'parsemag', 'escape'),
+                                       $wgLang->formatNum( $n ) );
+                       }
+
+                       $r .= ' (';
 
-                       if( $isnew ) {
-                               $r .= $this->message['changes'];
+                       if( !ChangesList::userCan($rcObj,Revision::DELETED_TEXT) ) {
+                           $r .= $nchanges[$n];
+                       } else if( $isnew ) {
+                               $r .= $nchanges[$n];
                        } else {
                                $r .= $this->skin->makeKnownLinkObj( $block[0]->getTitle(),
-                                       $this->message['changes'], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
+                                       $nchanges[$n], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
                        }
 
-                       # 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 . ' ';
+                       if( $wgRCShowChangedSize ) {
+                               # 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(),
+                       $r .= '(' . $this->skin->makeKnownLinkObj( $block[0]->getTitle(),
                                $this->message['history'], $curIdEq.'&action=history' );
                        $r .= ')';
                }
 
                $r .= $users;
-
-               if($block[0]->numberofWatchingusers > 0) {
-                       global $wgContLang;
-                       $r .= wfMsg('number_of_watching_users_RCview',  $wgContLang->formatNum($block[0]->numberofWatchingusers));
-               }
-               $r .= "<br />\n";
+               $r .=$this->numberofWatchingusers($block[0]->numberofWatchingusers);
+               
+               $r .= "</td></tr></table>\n";
 
                # Sub-entries
-               $r .= '<div id="'.$rci.'" style="display:none">';
+               $r .= '<div id="'.$rci.'" style="display:none; font-size:95%;"><table cellpadding="0" cellspacing="0">';
                foreach( $block as $rcObj ) {
                        # Get rc_xxxx variables
+                       // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
                        extract( $rcObj->mAttribs );
 
-                       $r .= $this->spacerArrow();
-                       $r .= '<tt>&nbsp; &nbsp; &nbsp; &nbsp;';
+                       #$r .= '<tr><td valign="top">'.$this->spacerArrow();
+                       $r .= '<tr><td valign="top">'.$this->spacerIndent();
+                       $r .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                        $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled, '&nbsp;', $rc_bot );
-                       $r .= '&nbsp;</tt>';
+                       $r .= '&nbsp;&nbsp;</td><td valign="top">';
 
                        $o = '';
                        if( $rc_this_oldid != 0 ) {
                                $o = 'oldid='.$rc_this_oldid;
                        }
+                       # Revision link
                        if( $rc_type == RC_LOG ) {
-                               $link = $rcObj->timestamp;
+                               $link = '<tt>'.$rcObj->timestamp.'</tt> ';
+                       } else if( !ChangesList::userCan($rcObj,Revision::DELETED_TEXT) ) {
+                               $link = '<span class="history-deleted"><tt>'.$rcObj->timestamp.'</tt></span> ';
                        } else {
-                               $link = $this->skin->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp, $curIdEq.'&'.$o );
+                               $link = '<tt>'.$this->skin->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp, $curIdEq.'&'.$o ).'</tt>';
+                               if( $this->isDeleted($rcObj,Revision::DELETED_TEXT) )
+                                       $link = '<span class="history-deleted">'.$link.'</span> ';
                        }
-                       $link = '<tt>'.$link.'</tt>';
-
                        $r .= $link;
-                       $r .= ' (';
-                       $r .= $rcObj->curlink;
-                       $r .= '; ';
-                       $r .= $rcObj->lastlink;
-                       $r .= ') . . ';
+                       
+                       if ( !$rc_log_type ) {
+                               $r .= ' (';
+                               $r .= $rcObj->curlink;
+                               $r .= $this->message['semicolon-separator'] . ' ';
+                               $r .= $rcObj->lastlink;
+                               $r .= ')';
+                       } else {
+                               $logname = LogPage::logName( $rc_log_type );
+                               $logtitle = Title::newFromText( "Log/$rc_log_type", NS_SPECIAL );
+                               $r .= '(' . $this->skin->makeKnownLinkObj($logtitle, $logname ) . ')';
+                       }
+                       $r .= ' . . ';
 
                        # Character diff
                        if( $wgRCShowChangedSize ) {
                                $r .= ( $rcObj->getCharacterDifference() == '' ? '' : $rcObj->getCharacterDifference() . ' . . ' ) ;
                        }
-
+                       # User links
                        $r .= $rcObj->userlink;
                        $r .= $rcObj->usertalklink;
-                       $r .= $this->skin->commentBlock( $rc_comment, $rcObj->getTitle() );
-                       $r .= "<br />\n";
+                       // log action
+                       parent::insertAction($r, $rcObj);
+                       // log comment
+                       parent::insertComment($r, $rcObj);
+                       # Mark revision as deleted
+                       if ( !$rc_log_type && $this->isDeleted($rcObj,Revision::DELETED_TEXT) )
+                               $r .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
+
+                       $r .= "</td></tr>\n";
                }
-               $r .= "</div>\n";
+               $r .= "</table></div>\n";
 
                $this->rcCacheIndex++;
                return $r;
@@ -548,7 +682,7 @@ class EnhancedChangesList extends ChangesList {
        function maybeWatchedLink( $link, $watched=false ) {
                if( $watched ) {
                        // FIXME: css style might be more appropriate
-                       return '<strong>' . $link . '</strong>';
+                       return '<strong class="mw-watched">' . $link . '</strong>';
                } else {
                        return $link;
                }
@@ -598,6 +732,20 @@ class EnhancedChangesList extends ChangesList {
        function spacerArrow() {
                return $this->arrow( '', ' ' );
        }
+       
+       /**
+        * Generate HTML for the equivalent of a spacer image for tables
+        * @return string HTML <td> tag
+        * @access private
+        */     
+       function spacerColumn() {
+               return '<td width="12"></td>';
+       }
+       
+       // Adds a few spaces
+       function spacerIndent() {
+               return '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
+       }
 
        /**
         * Enhanced RC ungrouped line.
@@ -607,51 +755,68 @@ class EnhancedChangesList extends ChangesList {
                global $wgContLang, $wgRCShowChangedSize;
 
                # Get rc_xxxx variables
+               // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
                extract( $rcObj->mAttribs );
                $curIdEq = 'curid='.$rc_cur_id;
 
-               $r = '';
-
-               # Spacer image
-               $r .= $this->spacerArrow();
+               $r = '<table cellspacing="0" cellpadding="0"><tr>';
 
+               # spacerArrow() causes issues in FF
+               $r .= $this->spacerColumn();
+               $r .= '<td valign="top">';
+               
                # Flag and Timestamp
-               $r .= '<tt>';
-
                if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
-                       $r .= '&nbsp;&nbsp;&nbsp;';
+                       $r .= '&nbsp;&nbsp;&nbsp;&nbsp;';
                } else {
-                       $r .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled, '&nbsp;', $rc_bot );
+                       $r .= '&nbsp;'.$this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled, '&nbsp;', $rc_bot );
                }
-               $r .= ' '.$rcObj->timestamp.' </tt>';
-
+               $r .= '&nbsp;<tt>'.$rcObj->timestamp.'</tt>&nbsp;&nbsp;</td><td>';
+               
                # Article link
-               $r .= $this->maybeWatchedLink( $rcObj->link, $rcObj->watched );
-
-               # Diff
-               $r .= ' ('. $rcObj->difflink .'; ';
-
-               # Hist
-               $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ') . . ';
-
+               if ( $rc_log_type !='' ) {
+                       $logtitle = Title::newFromText( "Log/$rc_log_type", NS_SPECIAL );
+                       $logname = LogPage::logName( $rc_log_type );
+                       $r .= '(' . $this->skin->makeKnownLinkObj($logtitle, $logname ) . ')';
+               // All other stuff
+               } else {
+                       $r .= $this->maybeWatchedLink( $rcObj->link, $rcObj->watched );
+               }
+               if ( $rc_type != RC_LOG ) {
+                  # Diff
+                  $r .= ' ('. $rcObj->difflink . $this->message['semicolon-separator'] . ' ';
+                  # Hist
+                  $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')';
+               }
+               $r .= ' . . ';
+               
                # 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 ) {
-                       $r .= $this->skin->commentBlock( $rc_comment, $rcObj->getTitle() );
+                       // log action
+                       if ( $this->isDeleted($rcObj,LogPage::DELETED_ACTION) ) {
+                          $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
+                       } else {
+                               $r .= ' ' . LogPage::actionText( $rc_log_type, $rc_log_action, $rcObj->getTitle(), $this->skin, LogPage::extractParams($rc_params), true, true );
+                       } 
+                       // 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() );
+                       }
                }
 
-               if( $rcObj->numberofWatchingusers > 0 ) {
-                       $r .= wfMsg('number_of_watching_users_RCview', $wgContLang->formatNum($rcObj->numberofWatchingusers));
-               }
+               $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers);
 
-               $r .= "<br />\n";
+               $r .= "</td></tr></table>\n";
                return $r;
        }
 
@@ -684,4 +849,3 @@ class EnhancedChangesList extends ChangesList {
        }
 
 }
-?>