From 05da5bbea0ca0f67dc6706884e9cca3794bf9eb4 Mon Sep 17 00:00:00 2001 From: Adam Roses Wight Date: Tue, 26 Jan 2016 20:29:16 -0800 Subject: [PATCH] New hook for filters on Special:Contributions form Bug: T124857 Change-Id: I56a3f13e8888202f832c5c18c92f3ff899f032f2 --- docs/hooks.txt | 5 +++++ includes/specials/SpecialContributions.php | 18 ++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 2b5e1e0d7e..9aacaa94d6 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2793,6 +2793,11 @@ $id: User id number, only provided for backwards-compatibility $user: User object representing user contributions are being fetched for $sp: SpecialPage instance, providing context +'SpecialContributions::getForm::filters': Called with a list of filters to render +on Special:Contributions. +$sp: SpecialContributions object, for context +&$filters: List of filters rendered as HTML + 'SpecialListusersDefaultQuery': Called right before the end of UsersPager::getDefaultQuery(). $pager: The UsersPager instance diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index ab6614bc12..1a1b490c74 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -571,8 +571,10 @@ class SpecialContributions extends IncludableSpecialPage { ) ); + $filters = array(); + if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) { - $deletedOnlyCheck = Html::rawElement( + $filters[] = Html::rawElement( 'span', array( 'class' => 'mw-input-with-label' ), Xml::checkLabel( @@ -583,11 +585,9 @@ class SpecialContributions extends IncludableSpecialPage { array( 'class' => 'mw-input' ) ) ); - } else { - $deletedOnlyCheck = ''; } - $checkLabelTopOnly = Html::rawElement( + $filters[] = Html::rawElement( 'span', array( 'class' => 'mw-input-with-label' ), Xml::checkLabel( @@ -598,7 +598,7 @@ class SpecialContributions extends IncludableSpecialPage { array( 'class' => 'mw-input' ) ) ); - $checkLabelNewOnly = Html::rawElement( + $filters[] = Html::rawElement( 'span', array( 'class' => 'mw-input-with-label' ), Xml::checkLabel( @@ -609,10 +609,16 @@ class SpecialContributions extends IncludableSpecialPage { array( 'class' => 'mw-input' ) ) ); + + Hooks::run( + 'SpecialContributions::getForm::filters', + array( $this, &$filters ) + ); + $extraOptions = Html::rawElement( 'td', array( 'colspan' => 2 ), - $deletedOnlyCheck . $checkLabelTopOnly . $checkLabelNewOnly + implode( '', $filters ) ); $dateSelectionAndSubmit = Xml::tags( 'td', array( 'colspan' => 2 ), -- 2.20.1