From: Stephane Bisson Date: Mon, 1 May 2017 20:38:35 +0000 (-0400) Subject: RC Filters: watchlist X-Git-Tag: 1.31.0-rc.0~3374^2 X-Git-Url: http://git.cyclocoop.org//%22javascript:ModifierStyle%28%27%22.%24id.%22%27%29/%22?a=commitdiff_plain;h=9a97cb69568dc32e90b007ae53ec599622c6ba2e;p=lhc%2Fweb%2Fwiklou.git RC Filters: watchlist Introducing filtering on watchlist status watchlist=watched|watchednew|notwatched 'watchednew' is a subset of 'watched Bug: T163964 Change-Id: I04df40c8399e15a03a400b4a24afedf1df242a93 --- diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index bc241e06dc..1b92dc3f4c 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -392,6 +392,95 @@ abstract class ChangesListSpecialPage extends SpecialPage { ], ], ], + + [ + 'name' => 'watchlist', + 'title' => 'rcfilters-filtergroup-watchlist', + 'class' => ChangesListStringOptionsFilterGroup::class, + 'isFullCoverage' => true, + 'filters' => [ + [ + 'name' => 'watched', + 'label' => 'rcfilters-filter-watchlist-watched-label', + 'description' => 'rcfilters-filter-watchlist-watched-description', + 'cssClassSuffix' => 'watched', + 'isRowApplicableCallable' => function ( $ctx, $rc ) { + return $rc->getAttribute( 'wl_user' ); + } + ], + [ + 'name' => 'watchednew', + 'label' => 'rcfilters-filter-watchlist-watchednew-label', + 'description' => 'rcfilters-filter-watchlist-watchednew-description', + 'cssClassSuffix' => 'watchednew', + 'isRowApplicableCallable' => function ( $ctx, $rc ) { + return $rc->getAttribute( 'wl_user' ) && + $rc->getAttribute( 'rc_timestamp' ) > $rc->getAttribute( 'wl_notificationtimestamp' ); + }, + ], + [ + 'name' => 'notwatched', + 'label' => 'rcfilters-filter-watchlist-notwatched-label', + 'description' => 'rcfilters-filter-watchlist-notwatched-description', + 'cssClassSuffix' => 'notwatched', + 'isRowApplicableCallable' => function ( $ctx, $rc ) { + return $rc->getAttribute( 'wl_user' ) === null; + }, + ] + ], + 'default' => ChangesListStringOptionsFilterGroup::NONE, + 'queryCallable' => function ( $specialPageClassName, $context, $dbr, + &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) { + sort( $selectedValues ); + $notwatchedCond = 'wl_user IS NULL'; + $watchedCond = 'wl_user IS NOT NULL'; + $newCond = 'rc_timestamp >= wl_notificationtimestamp'; + + if ( $selectedValues === [ 'notwatched' ] ) { + $conds[] = $notwatchedCond; + return; + } + + if ( $selectedValues === [ 'watched' ] ) { + $conds[] = $watchedCond; + return; + } + + if ( $selectedValues === [ 'watchednew' ] ) { + $conds[] = $dbr->makeList( [ + $watchedCond, + $newCond + ], LIST_AND ); + return; + } + + if ( $selectedValues === [ 'notwatched', 'watched' ] ) { + // no filters + return; + } + + if ( $selectedValues === [ 'notwatched', 'watchednew' ] ) { + $conds[] = $dbr->makeList( [ + $notwatchedCond, + $dbr->makeList( [ + $watchedCond, + $newCond + ], LIST_AND ) + ], LIST_OR ); + return; + } + + if ( $selectedValues === [ 'watched', 'watchednew' ] ) { + $conds[] = $watchedCond; + return; + } + + if ( $selectedValues === [ 'notwatched', 'watched', 'watchednew' ] ) { + // no filters + return; + } + }, + ], ]; $this->reviewStatusFilterGroupDefinition = [ @@ -679,6 +768,11 @@ abstract class ChangesListSpecialPage extends SpecialPage { 'rcfilters-hideminor-conflicts-typeofchange', 'rcfilters-typeofchange-conflicts-hideminor' ); + + $watchlistGroup = $this->getFilterGroup( 'watchlist' ); + $watchlistGroup->getFilter( 'watched' )->setAsSupersetOf( + $watchlistGroup->getFilter( 'watchednew' ) + ); } /** diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 3f5b8814d3..a704d39cb4 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -1415,6 +1415,13 @@ "rcfilters-filter-minor-description": "Edits the author labeled as minor.", "rcfilters-filter-major-label": "Non-minor edits", "rcfilters-filter-major-description": "Edits not labeled as minor.", + "rcfilters-filtergroup-watchlist": "Watchlisted pages", + "rcfilters-filter-watchlist-watched-label": "On Watchlist", + "rcfilters-filter-watchlist-watched-description": "Changes to pages on your Watchlist.", + "rcfilters-filter-watchlist-watchednew-label": "New Watchlist changes", + "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-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 4339f3d647..27dc70a439 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -1603,6 +1603,13 @@ "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-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-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.",