X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialWatchlist.php;h=e8e828df08f1dd745a7e477a41e6c89f05295c8b;hb=2443406d3765e31dc734ea74985420773940c37d;hp=8a474864f086ba0953edf1f023a9839dae67ddfd;hpb=c728912b38bc220a60ba159272428380661d19a0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 8a474864f0..e8e828df08 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -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,10 +110,10 @@ 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' ) ); } @@ -248,6 +250,22 @@ class SpecialWatchlist extends ChangesListSpecialPage { $hideLiu = $registration->getFilter( 'hideliu' ); $hideLiu->setDefault( $user->getBoolOption( 'watchlisthideliu' ) ); + // Selecting both hideanons and hideliu on watchlist preferances + // gives mutually exclusive filters, so those are ignored + if ( $user->getBoolOption( 'watchlisthideanons' ) && + !$user->getBoolOption( 'watchlisthideliu' ) + ) { + $this->getFilterGroup( 'userExpLevel' ) + ->setDefault( 'registered' ); + } + + if ( $user->getBoolOption( 'watchlisthideliu' ) && + !$user->getBoolOption( 'watchlisthideanons' ) + ) { + $this->getFilterGroup( 'userExpLevel' ) + ->setDefault( 'unregistered' ); + } + $reviewStatus = $this->getFilterGroup( 'reviewStatus' ); if ( $reviewStatus !== null ) { // Conditional on feature being available and rights @@ -317,15 +335,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; @@ -348,8 +359,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( [ @@ -362,6 +374,7 @@ class SpecialWatchlist extends ChangesListSpecialPage { ], ], ], + $rcQuery['joins'], $join_conds ); @@ -630,21 +643,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; @@ -850,11 +857,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 ], + // at beginning to avoid messages with "$1 ..." being parsed as pre tags + $this->msg( $message, '' )->parse() ) ); } @@ -871,12 +879,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' ) ); - } }