Merge "Special:Newpages feed now shows first revision instead of latest revision"
[lhc/web/wiklou.git] / includes / specials / SpecialWatchlist.php
index 9e01d2d..1d76e36 100644 (file)
@@ -58,6 +58,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                        'mediawiki.special.changeslist.visitedstatus',
                        'mediawiki.special.watchlist',
                ] );
+               $output->addModuleStyles( [ 'mediawiki.special.watchlist.styles' ] );
 
                $mode = SpecialEditWatchlist::getMode( $request, $subpage );
                if ( $mode !== false ) {
@@ -109,7 +110,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
        }
 
        /**
-        * @inheritdoc
+        * @inheritDoc
         */
        protected function transformFilterDefinition( array $filterDefinition ) {
                if ( isset( $filterDefinition['showHideSuffix'] ) ) {
@@ -120,7 +121,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
        }
 
        /**
-        * @inheritdoc
+        * @inheritDoc
         */
        protected function registerFilters() {
                parent::registerFilters();
@@ -250,7 +251,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
        }
 
        /**
-        * @inheritdoc
+        * @inheritDoc
         */
        protected function buildQuery( &$tables, &$fields, &$conds, &$query_options,
                &$join_conds, FormOptions $opts
@@ -267,7 +268,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
        }
 
        /**
-        * @inheritdoc
+        * @inheritDoc
         */
        protected function doMainQuery( $tables, $fields, $conds, $query_options,
                $join_conds, FormOptions $opts
@@ -431,6 +432,23 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                $list = ChangesList::newFromContext( $this->getContext(), $this->filterGroups );
                $list->setWatchlistDivs();
                $list->initChangesListRows( $rows );
+               if ( $user->getOption( 'watchlistunwatchlinks' ) ) {
+                       $list->setChangeLinePrefixer( function ( RecentChange $rc, ChangesList $cl, $grouped ) {
+                               // Don't show unwatch link if the line is a grouped log entry using EnhancedChangesList,
+                               // since EnhancedChangesList groups log entries by performer rather than by target article
+                               if ( $rc->mAttribs['rc_type'] == RC_LOG && $cl instanceof EnhancedChangesList &&
+                                       $grouped ) {
+                                       return '';
+                               } else {
+                                       return $this->getLinkRenderer()
+                                                       ->makeKnownLink( $rc->getTitle(),
+                                                               $this->msg( 'watchlist-unwatch' )->text(), [
+                                                                       'class' => 'mw-unwatch-link',
+                                                                       'title' => $this->msg( 'tooltip-ca-unwatch' )->text()
+                                                               ], [ 'action' => 'unwatch' ] ) . ' ';
+                               }
+                       } );
+               }
                $dbr->dataSeek( $rows, 0 );
 
                if ( $this->getConfig()->get( 'RCShowWatchingUsers' )
@@ -596,7 +614,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                // default string representation, for example, and would confuse comparisons.
 
                // Misleadingly, the 'days' option supports hours too.
-               $days = array_map( 'strval', [ 1/24, 2/24, 6/24, 12/24, 1, 3, 7 ] );
+               $days = array_map( 'strval', [ 1 / 24, 2 / 24, 6 / 24, 12 / 24, 1, 3, 7 ] );
 
                $userWatchlistOption = (string)$this->getUser()->getOption( 'watchlistdays' );
                // add the user preference, if it isn't available already