Merge "mw.rcfilters.ui.SaveFiltersPopupButtonWidget: Remove pointless option"
[lhc/web/wiklou.git] / includes / specials / SpecialWatchlist.php
index fcf1bfb..2ad70a6 100644 (file)
@@ -33,6 +33,8 @@ use Wikimedia\Rdbms\IDatabase;
  */
 class SpecialWatchlist extends ChangesListSpecialPage {
        protected static $savedQueriesPreferenceName = 'rcfilters-wl-saved-queries';
+       protected static $daysPreferenceName = 'watchlistdays';
+       protected static $limitPreferenceName = 'wllimit';
 
        private $maxDays;
 
@@ -108,18 +110,13 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                }
        }
 
-       public function isStructuredFilterUiEnabled() {
-               return $this->getRequest()->getBool( 'rcfilters' ) || (
-                       $this->getConfig()->get( 'StructuredChangeFiltersOnWatchlist' ) &&
-                       $this->getUser()->getOption( 'rcenhancedfilters' )
+       public static function checkStructuredFilterUiEnabled( Config $config, User $user ) {
+               return (
+                       $config->get( 'StructuredChangeFiltersOnWatchlist' ) &&
+                       $user->getOption( 'rcenhancedfilters' )
                );
        }
 
-       public function isStructuredFilterUiEnabledByDefault() {
-               return $this->getConfig()->get( 'StructuredChangeFiltersOnWatchlist' ) &&
-                       $this->getUser()->getDefaultOption( 'rcenhancedfilters' );
-       }
-
        /**
         * Return an array of subpages that this special page will accept.
         *
@@ -333,15 +330,8 @@ class SpecialWatchlist extends ChangesListSpecialPage {
 
                        // This is how we handle the fact that HTML forms don't submit
                        // unchecked boxes.
-                       foreach ( $this->filterGroups as $filterGroup ) {
-                               if ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
-                                       /** @var ChangesListBooleanFilter $filter */
-                                       foreach ( $filterGroup->getFilters() as $filter ) {
-                                               if ( $filter->displaysOnUnstructuredUi() ) {
-                                                       $allBooleansFalse[$filter->getName()] = false;
-                                               }
-                                       }
-                               }
+                       foreach ( $this->getLegacyShowHideFilters() as $filter ) {
+                               $allBooleansFalse[ $filter->getName() ] = false;
                        }
 
                        $params = $params + $allBooleansFalse;
@@ -364,8 +354,9 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                $dbr = $this->getDB();
                $user = $this->getUser();
 
-               $tables = array_merge( [ 'recentchanges', 'watchlist' ], $tables );
-               $fields = array_merge( RecentChange::selectFields(), $fields );
+               $rcQuery = RecentChange::getQueryInfo();
+               $tables = array_merge( $tables, $rcQuery['tables'], [ 'watchlist' ] );
+               $fields = array_merge( $rcQuery['fields'], $fields );
 
                $join_conds = array_merge(
                        [
@@ -378,6 +369,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                                        ],
                                ],
                        ],
+                       $rcQuery['joins'],
                        $join_conds
                );
 
@@ -646,21 +638,15 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                # Spit out some control panel links
                $links = [];
                $namesOfDisplayedFilters = [];
-               foreach ( $this->getFilterGroups() as $groupName => $group ) {
-                       if ( !$group->isPerGroupRequestParameter() ) {
-                               foreach ( $group->getFilters() as $filterName => $filter ) {
-                                       if ( $filter->displaysOnUnstructuredUi( $this ) ) {
-                                               $namesOfDisplayedFilters[] = $filterName;
-                                               $links[] = $this->showHideCheck(
-                                                       $nondefaults,
-                                                       $filter->getShowHide(),
-                                                       $filterName,
-                                                       $opts[$filterName],
-                                                       $filter->isFeatureAvailableOnStructuredUi( $this )
-                                               );
-                                       }
-                               }
-                       }
+               foreach ( $this->getLegacyShowHideFilters() as $filterName => $filter ) {
+                       $namesOfDisplayedFilters[] = $filterName;
+                       $links[] = $this->showHideCheck(
+                               $nondefaults,
+                               $filter->getShowHide(),
+                               $filterName,
+                               $opts[ $filterName ],
+                               $filter->isFeatureAvailableOnStructuredUi( $this )
+                       );
                }
 
                $hiddenFields = $nondefaults;
@@ -866,11 +852,12 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                return Html::rawElement(
                        'span',
                        $attribs,
-                       Xml::checkLabel(
-                               $this->msg( $message, '' )->text(),
-                               $name,
-                               $name,
-                               (int)$value
+                       // not using Html::checkLabel because that would escape the contents
+                       Html::check( $name, (int)$value, [ 'id' => $name ] ) . Html::rawElement(
+                               'label',
+                               $attribs + [ 'for' => $name ],
+                               // <nowiki/> at beginning to avoid messages with "$1 ..." being parsed as pre tags
+                               $this->msg( $message, '<nowiki/>' )->parse()
                        )
                );
        }
@@ -887,12 +874,4 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                $count = $store->countWatchedItems( $this->getUser() );
                return floor( $count / 2 );
        }
-
-       function getDefaultLimit() {
-               return $this->getUser()->getIntOption( 'wllimit' );
-       }
-
-       function getDefaultDays() {
-               return floatval( $this->getUser()->getOption( 'watchlistdays' ) );
-       }
 }