X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialWatchlist.php;h=fcf1bfb8b91dbdb7843e7c0d4883a6497833dbf9;hb=5c34da77f9321fae9b43454b7e1296e3f1c248ac;hp=8418865e10d97b04b1fa993e0747834d38fe8c00;hpb=617d05ae4c195d5edfb14ab21286234e8e79d888;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 8418865e10..fcf1bfb8b9 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -32,6 +32,8 @@ use Wikimedia\Rdbms\IDatabase; * @ingroup SpecialPage */ class SpecialWatchlist extends ChangesListSpecialPage { + protected static $savedQueriesPreferenceName = 'rcfilters-wl-saved-queries'; + private $maxDays; public function __construct( $page = 'Watchlist', $restriction = 'viewmywatchlist' ) { @@ -99,11 +101,6 @@ class SpecialWatchlist extends ChangesListSpecialPage { if ( $this->isStructuredFilterUiEnabled() ) { $output->addModuleStyles( [ 'mediawiki.rcfilters.highlightCircles.seenunseen.styles' ] ); - $output->addJsConfigVars( 'wgStructuredChangeFiltersLiveUpdateSupported', false ); - $output->addJsConfigVars( - 'wgStructuredChangeFiltersSavedQueriesPreferenceName', - 'rcfilters-wl-saved-queries' - ); $output->addJsConfigVars( 'wgStructuredChangeFiltersEditWatchlistUrl', SpecialPage::getTitleFor( 'EditWatchlist' )->getLocalURL() @@ -251,6 +248,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 @@ -270,26 +283,6 @@ class SpecialWatchlist extends ChangesListSpecialPage { } } - /** - * Get a FormOptions object containing the default options - * - * @return FormOptions - */ - public function getDefaultOptions() { - $opts = parent::getDefaultOptions(); - - $opts->add( 'days', $this->getDefaultDays(), FormOptions::FLOAT ); - $opts->add( 'limit', $this->getDefaultLimit(), FormOptions::INT ); - - return $opts; - } - - public function validateOptions( FormOptions $opts ) { - $opts->validateBounds( 'days', 0, $this->maxDays ); - $opts->validateIntBounds( 'limit', 0, 5000 ); - parent::validateOptions( $opts ); - } - /** * Get all custom filters * @@ -362,23 +355,6 @@ class SpecialWatchlist extends ChangesListSpecialPage { return $opts; } - /** - * @inheritDoc - */ - protected function buildQuery( &$tables, &$fields, &$conds, &$query_options, - &$join_conds, FormOptions $opts - ) { - $dbr = $this->getDB(); - parent::buildQuery( $tables, $fields, $conds, $query_options, $join_conds, - $opts ); - - // Calculate cutoff - if ( $opts['days'] > 0 ) { - $conds[] = 'rc_timestamp > ' . - $dbr->addQuotes( $dbr->timestamp( time() - $opts['days'] * 3600 * 24 ) ); - } - } - /** * @inheritDoc */ @@ -648,16 +624,14 @@ class SpecialWatchlist extends ChangesListSpecialPage { } $lang = $this->getLanguage(); - if ( $opts['days'] > 0 ) { - $days = $opts['days']; - } else { - $days = $this->maxDays; - } $timestamp = wfTimestampNow(); $wlInfo = Html::rawElement( 'span', - [ 'class' => 'wlinfo' ], - $this->msg( 'wlnote' )->numParams( $numRows, round( $days * 24 ) )->params( + [ + 'class' => 'wlinfo', + 'data-params' => json_encode( [ 'from' => $timestamp ] ), + ], + $this->msg( 'wlnote' )->numParams( $numRows, round( $opts['days'] * 24 ) )->params( $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user ) )->parse() ) . "
\n";