From 2f622d30768ed1f8a8a864bad6edfbb876891dc3 Mon Sep 17 00:00:00 2001 From: "This, that and the other" Date: Wed, 7 Oct 2015 22:04:09 +1100 Subject: [PATCH] Allow minor edits to be filtered out of Special:Contributions Just another checkbox and option flag... Bug: T16086 Change-Id: Iacc66213798fa527adc3346fe1763ab0e04d2afe --- includes/api/ApiFeedContributions.php | 2 ++ includes/api/i18n/en.json | 1 + includes/api/i18n/qqq.json | 1 + includes/specials/SpecialContributions.php | 21 +++++++++++++++++++++ includes/specials/pagers/ContribsPager.php | 5 +++++ languages/i18n/en.json | 1 + languages/i18n/qqq.json | 1 + 7 files changed, 32 insertions(+) diff --git a/includes/api/ApiFeedContributions.php b/includes/api/ApiFeedContributions.php index e28b0684d5..c7dc303ada 100644 --- a/includes/api/ApiFeedContributions.php +++ b/includes/api/ApiFeedContributions.php @@ -79,6 +79,7 @@ class ApiFeedContributions extends ApiBase { 'deletedOnly' => $params['deletedonly'], 'topOnly' => $params['toponly'], 'newOnly' => $params['newonly'], + 'hideMinor' => $params['hideminor'], 'showSizeDiff' => $params['showsizediff'], ] ); @@ -208,6 +209,7 @@ class ApiFeedContributions extends ApiBase { 'deletedonly' => false, 'toponly' => false, 'newonly' => false, + 'hideminor' => false, 'showsizediff' => [ ApiBase::PARAM_DFLT => false, ], diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json index 4e9309e699..dab7437ab7 100644 --- a/includes/api/i18n/en.json +++ b/includes/api/i18n/en.json @@ -154,6 +154,7 @@ "apihelp-feedcontributions-param-deletedonly": "Show only deleted contributions.", "apihelp-feedcontributions-param-toponly": "Only show edits that are latest revisions.", "apihelp-feedcontributions-param-newonly": "Only show edits that are page creations.", + "apihelp-feedcontributions-param-hideminor": "Hide minor edits.", "apihelp-feedcontributions-param-showsizediff": "Show the size difference between revisions.", "apihelp-feedcontributions-example-simple": "Return contributions for user Example.", diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json index 6137457c1b..e7fe5ce7cc 100644 --- a/includes/api/i18n/qqq.json +++ b/includes/api/i18n/qqq.json @@ -150,6 +150,7 @@ "apihelp-feedcontributions-param-deletedonly": "{{doc-apihelp-param|feedcontributions|deletedonly}}", "apihelp-feedcontributions-param-toponly": "{{doc-apihelp-param|feedcontributions|toponly}}", "apihelp-feedcontributions-param-newonly": "{{doc-apihelp-param|feedcontributions|newonly}}", + "apihelp-feedcontributions-param-hideminor": "{{doc-apihelp-param|feedcontributions|hideminor}}", "apihelp-feedcontributions-param-showsizediff": "{{doc-apihelp-param|feedcontributions|showsizediff}}", "apihelp-feedcontributions-example-simple": "{{doc-apihelp-example|feedcontributions}}", "apihelp-feedrecentchanges-description": "{{doc-apihelp-description|feedrecentchanges}}", diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 431b556cb3..ac7e62ed2e 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -72,6 +72,7 @@ class SpecialContributions extends IncludableSpecialPage { $this->opts['target'] = $target; $this->opts['topOnly'] = $request->getBool( 'topOnly' ); $this->opts['newOnly'] = $request->getBool( 'newOnly' ); + $this->opts['hideMinor'] = $request->getBool( 'hideMinor' ); $nt = Title::makeTitleSafe( NS_USER, $target ); if ( !$nt ) { @@ -142,6 +143,9 @@ class SpecialContributions extends IncludableSpecialPage { if ( $this->opts['newOnly'] ) { $feedParams['newonly'] = true; } + if ( $this->opts['hideMinor'] ) { + $feedParams['hideminor'] = true; + } if ( $this->opts['deletedOnly'] ) { $feedParams['deletedonly'] = true; } @@ -188,6 +192,7 @@ class SpecialContributions extends IncludableSpecialPage { 'deletedOnly' => $this->opts['deletedOnly'], 'topOnly' => $this->opts['topOnly'], 'newOnly' => $this->opts['newOnly'], + 'hideMinor' => $this->opts['hideMinor'], 'nsInvert' => $this->opts['nsInvert'], 'associated' => $this->opts['associated'], ] ); @@ -441,6 +446,10 @@ class SpecialContributions extends IncludableSpecialPage { $this->opts['newOnly'] = false; } + if ( !isset( $this->opts['hideMinor'] ) ) { + $this->opts['hideMinor'] = false; + } + $form = Html::openElement( 'form', [ @@ -461,6 +470,7 @@ class SpecialContributions extends IncludableSpecialPage { 'month', 'topOnly', 'newOnly', + 'hideMinor', 'associated', 'tagfilter' ]; @@ -609,6 +619,17 @@ class SpecialContributions extends IncludableSpecialPage { [ 'class' => 'mw-input' ] ) ); + $filters[] = Html::rawElement( + 'span', + [ 'class' => 'mw-input-with-label' ], + Xml::checkLabel( + $this->msg( 'sp-contributions-hideminor' )->text(), + 'hideMinor', + 'mw-hide-minor-edits', + $this->opts['hideMinor'], + [ 'class' => 'mw-input' ] + ) + ); Hooks::run( 'SpecialContributions::getForm::filters', diff --git a/includes/specials/pagers/ContribsPager.php b/includes/specials/pagers/ContribsPager.php index d90c37bab7..193a44460a 100644 --- a/includes/specials/pagers/ContribsPager.php +++ b/includes/specials/pagers/ContribsPager.php @@ -64,6 +64,7 @@ class ContribsPager extends ReverseChronologicalPager { $this->deletedOnly = !empty( $options['deletedOnly'] ); $this->topOnly = !empty( $options['topOnly'] ); $this->newOnly = !empty( $options['newOnly'] ); + $this->hideMinor = !empty( $options['hideMinor'] ); $year = isset( $options['year'] ) ? $options['year'] : false; $month = isset( $options['month'] ) ? $options['month'] : false; @@ -246,6 +247,10 @@ class ContribsPager extends ReverseChronologicalPager { $condition[] = 'rev_parent_id = 0'; } + if ( $this->hideMinor ) { + $condition[] = 'rev_minor_edit = 0'; + } + return [ $tables, $index, $condition, $join_conds ]; } diff --git a/languages/i18n/en.json b/languages/i18n/en.json index f135f409a0..9ca08ec919 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -2292,6 +2292,7 @@ "sp-contributions-username": "IP address or username:", "sp-contributions-toponly": "Only show edits that are latest revisions", "sp-contributions-newonly": "Only show edits that are page creations", + "sp-contributions-hideminor": "Hide minor edits", "sp-contributions-submit": "Search", "sp-contributions-explain": "", "sp-contributions-footer": "-", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index e2a4f8b121..07fd848e0b 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -2473,6 +2473,7 @@ "sp-contributions-username": "This message appears whenever someone requests [[Special:Contributions]].\n{{Identical|IP address or username}}", "sp-contributions-toponly": "A checkbox at [[Special:Mycontributions|Special:Contributions]]", "sp-contributions-newonly": "Used as checkbox label at [[Special:Mycontributions|Special:Contributions]].\n\n\"page creation\" means the \"first revision\" of a page.\n\nPreceded by {{msg-mw|Sp-contributions-toponly}}.", + "sp-contributions-hideminor": "Used as checkbox label at [[Special:Mycontributions|Special:Contributions]].\n\nSee also:\n* {{msg-mw|Tog-hideminor}}", "sp-contributions-submit": "{{Identical|Search}}", "sp-contributions-explain": "{{optional}}", "sp-contributions-footer": "{{ignored}}This is the footer for users that are not anonymous or newbie on [[Special:Contributions]].", -- 2.20.1