New hook for filters on Special:Contributions form
authorAdam Roses Wight <awight@wikimedia.org>
Wed, 27 Jan 2016 04:29:16 +0000 (20:29 -0800)
committerAdam Roses Wight <awight@wikimedia.org>
Wed, 27 Jan 2016 04:29:16 +0000 (20:29 -0800)
Bug: T124857
Change-Id: I56a3f13e8888202f832c5c18c92f3ff899f032f2

docs/hooks.txt
includes/specials/SpecialContributions.php

index 2b5e1e0..9aacaa9 100644 (file)
@@ -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
index ab6614b..1a1b490 100644 (file)
@@ -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 ),