From c36b831e2ca6ff3e4ad0a2c59d84c260c055cc88 Mon Sep 17 00:00:00 2001 From: Stephane Bisson Date: Fri, 18 Aug 2017 11:35:42 -0400 Subject: [PATCH] WLFilters: new 'watchlist activity' filter group Bug: T171127 Change-Id: I84bf122bd042dd9b8b5495cb59a2a8f7cb77eb55 --- includes/specials/SpecialWatchlist.php | 41 ++++++++++++++++++++++++++ languages/i18n/en.json | 5 ++++ languages/i18n/qqq.json | 7 ++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 088bc1b8b3..b20b33117b 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -142,6 +142,47 @@ class SpecialWatchlist extends ChangesListSpecialPage { protected function registerFilters() { parent::registerFilters(); + $this->registerFilterGroup( new ChangesListStringOptionsFilterGroup( [ + 'name' => 'watchlistactivity', + 'title' => 'rcfilters-filtergroup-watchlistactivity', + 'class' => ChangesListStringOptionsFilterGroup::class, + 'priority' => 3, + 'isFullCoverage' => true, + 'filters' => [ + [ + 'name' => 'unseen', + 'label' => 'rcfilters-filter-watchlistactivity-unseen-label', + 'description' => 'rcfilters-filter-watchlistactivity-unseen-description', + 'cssClassSuffix' => 'watchedunseen', + 'isRowApplicableCallable' => function ( $ctx, $rc ) { + $changeTs = $rc->getAttribute( 'rc_timestamp' ); + $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' ); + return $changeTs >= $lastVisitTs; + }, + ], + [ + 'name' => 'seen', + 'label' => 'rcfilters-filter-watchlistactivity-seen-label', + 'description' => 'rcfilters-filter-watchlistactivity-seen-description', + 'cssClassSuffix' => 'watchedseen', + 'isRowApplicableCallable' => function ( $ctx, $rc ) { + $changeTs = $rc->getAttribute( 'rc_timestamp' ); + $lastVisitTs = $rc->getAttribute( 'wl_notificationtimestamp' ); + return $changeTs < $lastVisitTs; + } + ], + ], + 'default' => ChangesListStringOptionsFilterGroup::NONE, + 'queryCallable' => function ( $specialPageClassName, $context, $dbr, + &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) { + if ( $selectedValues === [ 'seen' ] ) { + $conds[] = 'rc_timestamp < wl_notificationtimestamp'; + } elseif ( $selectedValues === [ 'unseen' ] ) { + $conds[] = 'rc_timestamp >= wl_notificationtimestamp'; + } + } + ] ) ); + $user = $this->getUser(); $significance = $this->getFilterGroup( 'significance' ); diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 69b134a627..6126bbd6e7 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -1430,6 +1430,11 @@ "rcfilters-filter-watchlist-watchednew-description": "Changes to Watchlisted pages you haven't visited since the changes occurred.", "rcfilters-filter-watchlist-notwatched-label": "Not on Watchlist", "rcfilters-filter-watchlist-notwatched-description": "Everything except changes to your Watchlisted pages.", + "rcfilters-filtergroup-watchlistactivity": "Watchlist activity", + "rcfilters-filter-watchlistactivity-unseen-label": "Unseen changes", + "rcfilters-filter-watchlistactivity-unseen-description": "Changes to pages you haven't visited since the changes occurred.", + "rcfilters-filter-watchlistactivity-seen-label": "Seen changes", + "rcfilters-filter-watchlistactivity-seen-description": "Changes to pages you have visited since the changes occurred.", "rcfilters-filtergroup-changetype": "Type of change", "rcfilters-filter-pageedits-label": "Page edits", "rcfilters-filter-pageedits-description": "Edits to wiki content, discussions, category descriptions…", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 20b018261d..bc0fe2c657 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -1613,13 +1613,18 @@ "rcfilters-filter-minor-description": "Description for the filter for showing edits marked as minor.", "rcfilters-filter-major-label": "Label for the filter for showing edits not marked as minor.", "rcfilters-filter-major-description": " Description for the filter for showing edits not marked as minor.", - "rcfilters-filtergroup-watchlist": "Title for the watchlist filter group", + "rcfilters-filtergroup-watchlist": "Title for the watchlist filter group (only available on [[Special:Recentchanges]])", "rcfilters-filter-watchlist-watched-label": "Label for the filter for showing changes to pages on your watchlist.", "rcfilters-filter-watchlist-watched-description": "Description for the filter for showing changes to pages on your watchlist.", "rcfilters-filter-watchlist-watchednew-label": "Label for the filter for showing new changes to pages on your watchlist.", "rcfilters-filter-watchlist-watchednew-description": "Description for the filter for showing new changes to pages on your watchlist.", "rcfilters-filter-watchlist-notwatched-label": "Label for the filter for showing changes to pages not on your watchlist.", "rcfilters-filter-watchlist-notwatched-description": "Description for the filter for showing changes to pages not on your watchlist.", + "rcfilters-filtergroup-watchlistactivity": "Title for the watchlist activity filter group (only available on [[Special:Watchlist]])", + "rcfilters-filter-watchlistactivity-unseen-label": "Label for unseen changes in the watchlist activity filter group.", + "rcfilters-filter-watchlistactivity-unseen-description": "Description for unseen changes in the watchlist activity filter group.", + "rcfilters-filter-watchlistactivity-seen-label": "Label for seen changes in the watchlist activity filter group.", + "rcfilters-filter-watchlistactivity-seen-description": "Description for seen changes in the watchlist activity filter group.", "rcfilters-filtergroup-changetype": "Title for the filter group for edit type.", "rcfilters-filter-pageedits-label": "Label for the filter for showing edits to existing pages.", "rcfilters-filter-pageedits-description": "Description for the filter for showing edits to existing pages.", -- 2.20.1