Further improve load order of RC and watchlist styling
[lhc/web/wiklou.git] / includes / ChangesList.php
index 3170a7d..57c8f0b 100644 (file)
@@ -121,8 +121,10 @@ class ChangesList extends ContextSource {
         */
        private function preCacheMessages() {
                if ( !isset( $this->message ) ) {
-                       foreach ( explode( ' ', 'cur diff hist last blocklink history ' .
-                       'semicolon-separator pipe-separator' ) as $msg ) {
+                       foreach ( array(
+                               'cur', 'diff', 'hist', 'last', 'blocklink', 'history',
+                               'semicolon-separator', 'pipe-separator' ) as $msg
+                       ) {
                                $this->message[$msg] = $this->msg( $msg )->escaped();
                        }
                }
@@ -332,10 +334,6 @@ class ChangesList extends ContextSource {
                                'oldid' => $rc->mAttribs['rc_last_oldid']
                        );
 
-                       if ( $unpatrolled ) {
-                               $query['rcid'] = $rc->mAttribs['rc_id'];
-                       };
-
                        $diffLink = Linker::linkKnown(
                                $rc->getTitle(),
                                $this->message['diff'],
@@ -364,13 +362,9 @@ class ChangesList extends ContextSource {
         * @param $watched
         */
        public function insertArticleLink( &$s, &$rc, $unpatrolled, $watched ) {
-               # 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
-               $params = array();
+               global $wgUseRCPatrol;
 
-               if ( $unpatrolled && $rc->mAttribs['rc_type'] == RC_NEW ) {
-                       $params['rcid'] = $rc->mAttribs['rc_id'];
-               }
+               $params = array();
 
                $articlelink = Linker::linkKnown(
                        $rc->getTitle(),
@@ -530,7 +524,7 @@ class ChangesList extends ContextSource {
         * @param $rc RecentChange
         */
        public function insertRollback( &$s, &$rc ) {
-               if ( $rc->mAttribs['rc_type'] != RC_NEW && $rc->mAttribs['rc_this_oldid'] && $rc->mAttribs['rc_cur_id'] ) {
+               if ( $rc->mAttribs['rc_type'] == RC_EDIT && $rc->mAttribs['rc_this_oldid'] && $rc->mAttribs['rc_cur_id'] ) {
                        $page = $rc->getTitle();
                        /** Check for rollback and edit permissions, disallow special pages, and only
                          * show a link on the top-most revision */
@@ -616,7 +610,8 @@ class OldChangesList extends ChangesList {
 
                // Indicate watched status on the line to allow for more
                // comprehensive styling.
-               $classes[] = $watched ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
+               $classes[] = $watched && $rc->mAttribs['rc_timestamp'] >= $watched
+                       ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
 
                // Moved pages (very very old, not supported anymore)
                if ( $rc->mAttribs['rc_type'] == RC_MOVE || $rc->mAttribs['rc_type'] == RC_MOVE_OVER_REDIRECT ) {
@@ -708,7 +703,14 @@ class EnhancedChangesList extends ChangesList {
                $this->rcCacheIndex = 0;
                $this->lastdate = '';
                $this->rclistOpen = false;
-               $this->getOutput()->addModuleStyles( 'mediawiki.special.changeslist' );
+               $this->getOutput()->addModuleStyles( array(
+                       'mediawiki.special.changeslist',
+                       'mediawiki.special.changeslist.enhanced',
+               ) );
+               $this->getOutput()->addModules( array(
+                       'jquery.makeCollapsible',
+                       'mediawiki.icon',
+               ) );
                return '';
        }
        /**
@@ -749,8 +751,7 @@ class EnhancedChangesList extends ChangesList {
                if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
                // New unpatrolled pages
                } elseif ( $rc->unpatrolled && $type == RC_NEW ) {
-                       $clink = Linker::linkKnown( $rc->getTitle(), null, array(),
-                               array( 'rcid' => $rc->mAttribs['rc_id'] ) );
+                       $clink = Linker::linkKnown( $rc->getTitle() );
                // Log entries
                } elseif ( $type == RC_LOG ) {
                        if ( $logType ) {
@@ -786,14 +787,9 @@ class EnhancedChangesList extends ChangesList {
                # called too many times (50% of CPU time on RecentChanges!).
                $thisOldid = $rc->mAttribs['rc_this_oldid'];
                $lastOldid = $rc->mAttribs['rc_last_oldid'];
-               if ( $rc->unpatrolled ) {
-                       $rcIdQuery = array( 'rcid' => $rc->mAttribs['rc_id'] );
-               } else {
-                       $rcIdQuery = array();
-               }
+
                $querycur = $curIdEq + array( 'diff' => '0', 'oldid' => $thisOldid );
-               $querydiff = $curIdEq + array( 'diff' => $thisOldid, 'oldid' =>
-                       $lastOldid ) + $rcIdQuery;
+               $querydiff = $curIdEq + array( 'diff' => $thisOldid, 'oldid' => $lastOldid );
 
                if ( !$showdifflinks ) {
                        $curLink = $this->message['cur'];
@@ -820,7 +816,7 @@ class EnhancedChangesList extends ChangesList {
                        $lastLink = $this->message['last'];
                } else {
                        $lastLink = Linker::linkKnown( $rc->getTitle(), $this->message['last'],
-                               array(), $curIdEq + array( 'diff' => $thisOldid, 'oldid' => $lastOldid ) + $rcIdQuery );
+                               array(), $curIdEq + array( 'diff' => $thisOldid, 'oldid' => $lastOldid ) );
                }
 
                # Make user links
@@ -841,7 +837,7 @@ class EnhancedChangesList extends ChangesList {
                $secureName = $title->getPrefixedDBkey();
                if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
                        # Use an @ character to prevent collision with page names
-                       $this->rc_cache['@@' . ($this->rcMoveIndex++)] = array( $rc );
+                       $this->rc_cache['@@' . ( $this->rcMoveIndex++ )] = array( $rc );
                } else {
                        # Logs are grouped by type
                        if ( $type == RC_LOG ) {
@@ -878,7 +874,8 @@ class EnhancedChangesList extends ChangesList {
                        $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns'
                                        . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] );
                }
-               $classes[] = $block[0]->watched ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
+               $classes[] = $block[0]->watched && $block[0]->mAttribs['rc_timestamp'] >= $block[0]->watched
+                       ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
                $r = Html::openElement( 'table', array( 'class' => $classes ) ) .
                        Html::openElement( 'tr' );
 
@@ -950,7 +947,7 @@ class EnhancedChangesList extends ChangesList {
                                implode( $this->message['semicolon-separator'], $users )
                        )->escaped() . '</span>';
 
-               $tl = '<span class="mw-collapsible-toggle mw-enhancedchanges-arrow mw-enhancedchanges-arrow-space"></span>';
+               $tl = '<span class="mw-collapsible-toggle mw-collapsible-arrow mw-enhancedchanges-arrow mw-enhancedchanges-arrow-space"></span>';
                $r .= "<td>$tl</td>";
 
                # Main line
@@ -1059,7 +1056,10 @@ class EnhancedChangesList extends ChangesList {
                        $classes = array();
                        $type = $rcObj->mAttribs['rc_type'];
 
-                       $r .= '<tr><td></td><td class="mw-enhanced-rc">';
+                       $trClass = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
+                               ? ' class="mw-enhanced-watched"' : '';
+
+                       $r .= '<tr' . $trClass . '><td></td><td class="mw-enhanced-rc">';
                        $r .= $this->recentChangesFlags( array(
                                'newpage' => $type == RC_NEW,
                                'minor' => $rcObj->mAttribs['rc_minor'],
@@ -1081,9 +1081,6 @@ class EnhancedChangesList extends ChangesList {
                        } elseif ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
                                $link = '<span class="history-deleted">' . $rcObj->timestamp . '</span> ';
                        } else {
-                               if ( $rcObj->unpatrolled && $type == RC_NEW) {
-                                       $params['rcid'] = $rcObj->mAttribs['rc_id'];
-                               }
 
                                $link = Linker::linkKnown(
                                                $rcObj->getTitle(),
@@ -1200,7 +1197,8 @@ class EnhancedChangesList extends ChangesList {
                        $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' .
                                        $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] );
                }
-               $classes[] = $rcObj->watched ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
+               $classes[] = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched
+                       ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
                $r = Html::openElement( 'table', array( 'class' => $classes ) ) .
                        Html::openElement( 'tr' );