X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialWatchlist.php;h=dcd2ffa9937cd2cd08f70e23a397b3525f3abffb;hb=314b27242227909ab37010e699f9ecefce86d108;hp=b20b33117b2a565483085fc43c412da802c9f02a;hpb=c01536f8c082ef4a4384479db25bbba6ddb1ea4c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index b20b33117b..dcd2ffa993 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -97,11 +97,17 @@ class SpecialWatchlist extends ChangesListSpecialPage { parent::execute( $subpage ); 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() + ); } } @@ -142,6 +148,40 @@ class SpecialWatchlist extends ChangesListSpecialPage { protected function registerFilters() { parent::registerFilters(); + // legacy 'extended' filter + $this->registerFilterGroup( new ChangesListBooleanFilterGroup( [ + 'name' => 'extended-group', + 'filters' => [ + [ + 'name' => 'extended', + 'isReplacedInStructuredUi' => true, + 'activeValue' => false, + 'default' => $this->getUser()->getBoolOption( 'extendwatchlist' ), + 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, + &$fields, &$conds, &$query_options, &$join_conds ) { + $nonRevisionTypes = [ RC_LOG ]; + Hooks::run( 'SpecialWatchlistGetNonRevisionTypes', [ &$nonRevisionTypes ] ); + if ( $nonRevisionTypes ) { + $conds[] = $dbr->makeList( + [ + 'rc_this_oldid=page_latest', + 'rc_type' => $nonRevisionTypes, + ], + LIST_OR + ); + } + }, + ] + ], + + ] ) ); + + if ( $this->isStructuredFilterUiEnabled() ) { + $this->getFilterGroup( 'lastRevision' ) + ->getFilter( 'hidepreviousrevisions' ) + ->setDefault( !$this->getUser()->getBoolOption( 'extendwatchlist' ) ); + } + $this->registerFilterGroup( new ChangesListStringOptionsFilterGroup( [ 'name' => 'watchlistactivity', 'title' => 'rcfilters-filtergroup-watchlistactivity', @@ -157,7 +197,7 @@ class SpecialWatchlist extends ChangesListSpecialPage { 'isRowApplicableCallable' => function ( $ctx, $rc ) { $changeTs = $rc->getAttribute( 'rc_timestamp' ); $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' ); - return $changeTs >= $lastVisitTs; + return $lastVisitTs !== null && $changeTs >= $lastVisitTs; }, ], [ @@ -168,7 +208,7 @@ class SpecialWatchlist extends ChangesListSpecialPage { 'isRowApplicableCallable' => function ( $ctx, $rc ) { $changeTs = $rc->getAttribute( 'rc_timestamp' ); $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' ); - return $changeTs < $lastVisitTs; + return $lastVisitTs === null || $changeTs < $lastVisitTs; } ], ], @@ -176,9 +216,15 @@ class SpecialWatchlist extends ChangesListSpecialPage { 'queryCallable' => function ( $specialPageClassName, $context, $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) { if ( $selectedValues === [ 'seen' ] ) { - $conds[] = 'rc_timestamp < wl_notificationtimestamp'; + $conds[] = $dbr->makeList( [ + 'wl_notificationtimestamp IS NULL', + 'rc_timestamp < wl_notificationtimestamp' + ], LIST_OR ); } elseif ( $selectedValues === [ 'unseen' ] ) { - $conds[] = 'rc_timestamp >= wl_notificationtimestamp'; + $conds[] = $dbr->makeList( [ + 'wl_notificationtimestamp IS NOT NULL', + 'rc_timestamp >= wl_notificationtimestamp' + ], LIST_AND ); } } ] ) ); @@ -228,7 +274,6 @@ class SpecialWatchlist extends ChangesListSpecialPage { $user = $this->getUser(); $opts->add( 'days', $user->getOption( 'watchlistdays' ), FormOptions::FLOAT ); - $opts->add( 'extended', $user->getBoolOption( 'extendwatchlist' ) ); $opts->add( 'limit', $user->getIntOption( 'wllimit' ), FormOptions::INT ); return $opts; @@ -292,8 +337,11 @@ class SpecialWatchlist extends ChangesListSpecialPage { // unchecked boxes. foreach ( $this->filterGroups as $filterGroup ) { if ( $filterGroup instanceof ChangesListBooleanFilterGroup ) { + /** @var ChangesListBooleanFilter $filter */ foreach ( $filterGroup->getFilters() as $filter ) { - $allBooleansFalse[$filter->getName()] = false; + if ( $filter->displaysOnUnstructuredUi() ) { + $allBooleansFalse[$filter->getName()] = false; + } } } } @@ -335,25 +383,6 @@ class SpecialWatchlist extends ChangesListSpecialPage { $dbr = $this->getDB(); $user = $this->getUser(); - # Toggle watchlist content (all recent edits or just the latest) - if ( $opts['extended'] ) { - $usePage = false; - } else { - # Top log Ids for a page are not stored - $nonRevisionTypes = [ RC_LOG ]; - Hooks::run( 'SpecialWatchlistGetNonRevisionTypes', [ &$nonRevisionTypes ] ); - if ( $nonRevisionTypes ) { - $conds[] = $dbr->makeList( - [ - 'rc_this_oldid=page_latest', - 'rc_type' => $nonRevisionTypes, - ], - LIST_OR - ); - } - $usePage = true; - } - $tables = array_merge( [ 'recentchanges', 'watchlist' ], $tables ); $fields = array_merge( RecentChange::selectFields(), $fields ); @@ -375,18 +404,11 @@ class SpecialWatchlist extends ChangesListSpecialPage { $join_conds ); - if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) { - $fields[] = 'wl_notificationtimestamp'; - } + $tables[] = 'page'; + $fields[] = 'page_latest'; + $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ]; - $rollbacker = $user->isAllowed( 'rollback' ); - if ( $usePage || $rollbacker ) { - $tables[] = 'page'; - $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ]; - if ( $rollbacker ) { - $fields[] = 'page_latest'; - } - } + $fields[] = 'wl_notificationtimestamp'; // Log entries with DELETED_ACTION must not show up unless the user has // the necessary rights. @@ -415,6 +437,10 @@ class SpecialWatchlist extends ChangesListSpecialPage { $this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts ); + if ( $this->areFiltersInConflict() ) { + return false; + } + return $dbr->select( $tables, $fields, @@ -793,21 +819,25 @@ class SpecialWatchlist extends ChangesListSpecialPage { $showUpdatedMarker = $this->getConfig()->get( 'ShowUpdatedMarker' ); // Show watchlist header - $form .= "

"; + $watchlistHeader = ''; if ( $numItems == 0 ) { - $form .= $this->msg( 'nowatchlist' )->parse() . "\n"; + $watchlistHeader = $this->msg( 'nowatchlist' )->parse(); } else { - $form .= $this->msg( 'watchlist-details' )->numParams( $numItems )->parse() . "\n"; + $watchlistHeader .= $this->msg( 'watchlist-details' )->numParams( $numItems )->parse() . "\n"; if ( $this->getConfig()->get( 'EnotifWatchlist' ) && $user->getOption( 'enotifwatchlistpages' ) ) { - $form .= $this->msg( 'wlheader-enotif' )->parse() . "\n"; + $watchlistHeader .= $this->msg( 'wlheader-enotif' )->parse() . "\n"; } if ( $showUpdatedMarker ) { - $form .= $this->msg( 'wlheader-showupdated' )->parse() . "\n"; + $watchlistHeader .= $this->msg( 'wlheader-showupdated' )->parse() . "\n"; } } - $form .= "

"; + $form .= Html::rawElement( + 'p', + [ 'class' => 'watchlistDetails' ], + $watchlistHeader + ); if ( $numItems > 0 && $showUpdatedMarker ) { $form .= Xml::openElement( 'form', [ 'method' => 'post', @@ -858,4 +888,12 @@ class SpecialWatchlist extends ChangesListSpecialPage { $count = $store->countWatchedItems( $this->getUser() ); return floor( $count / 2 ); } + + function getDefaultLimit() { + return $this->getUser()->getIntOption( 'wllimit' ); + } + + function getDefaultDays() { + return $this->getUser()->getIntOption( 'watchlistdays' ); + } }