WLFilters: new 'watchlist activity' filter group
authorStephane Bisson <sbisson@wikimedia.org>
Fri, 18 Aug 2017 15:35:42 +0000 (11:35 -0400)
committerSbisson <sbisson@wikimedia.org>
Fri, 18 Aug 2017 19:54:36 +0000 (19:54 +0000)
Bug: T171127
Change-Id: I84bf122bd042dd9b8b5495cb59a2a8f7cb77eb55

includes/specials/SpecialWatchlist.php
languages/i18n/en.json
languages/i18n/qqq.json

index 088bc1b..b20b331 100644 (file)
@@ -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' );
index 69b134a..6126bbd 100644 (file)
        "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…",
index 20b0182..bc0fe2c 100644 (file)
        "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.",