Don't reinvent the wheel in SpecialRecentchangeslinked::getExtraOptions
authorMatmaRex <matma.rex@gmail.com>
Mon, 20 May 2013 12:00:52 +0000 (14:00 +0200)
committerMatmaRex <matma.rex@gmail.com>
Fri, 24 May 2013 19:29:44 +0000 (21:29 +0200)
Just call parent::getExtraOptions() first and then simply add the one
additional field. The 'SpecialRecentChangesPanel' hook wasn't called
from SpecialRecentchangeslinked previously, I've wrapped the call in
an if to keep the behavior the same.

Changes this causes:
* If $wgAllowCategorizedRecentChanges is true, Recentchangeslinked
  will include the category filter form as well.
* The target filter on Recentchangeslinked will be displayed at the
  end of the form, below the tag filter.

Change-Id: I4436a63356adb1e0b0daa1aa52c179974a036fa1

includes/specials/SpecialRecentchanges.php
includes/specials/SpecialRecentchangeslinked.php

index 0d6378c..1f10ad4 100644 (file)
@@ -592,10 +592,6 @@ class SpecialRecentChanges extends IncludableSpecialPage {
 
                $defaults = $opts->getAllValues();
                $nondefaults = $opts->getChangedValues();
-               $opts->consumeValues( array(
-                       'namespace', 'invert', 'associated', 'tagfilter',
-                       'categories', 'categories_any'
-               ) );
 
                $panel = array();
                $panel[] = $this->optionsPanel( $defaults, $nondefaults );
@@ -664,6 +660,10 @@ class SpecialRecentChanges extends IncludableSpecialPage {
         * @return array
         */
        function getExtraOptions( $opts ) {
+               $opts->consumeValues( array(
+                       'namespace', 'invert', 'associated', 'tagfilter', 'categories', 'categories_any'
+               ) );
+
                $extraOpts = array();
                $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
 
@@ -677,7 +677,10 @@ class SpecialRecentChanges extends IncludableSpecialPage {
                        $extraOpts['tagfilter'] = $tagFilter;
                }
 
-               wfRunHooks( 'SpecialRecentChangesPanel', array( &$extraOpts, $opts ) );
+               // Don't fire the hook for subclasses. (Or should we?)
+               if ( $this->getName() === 'Recentchanges' ) {
+                       wfRunHooks( 'SpecialRecentChangesPanel', array( &$extraOpts, $opts ) );
+               }
 
                return $extraOpts;
        }
index 062e09d..4773c4a 100644 (file)
@@ -226,21 +226,21 @@ class SpecialRecentchangeslinked extends SpecialRecentChanges {
        }
 
        /**
-        * @param $opts FormOptions
+        * Get options to be displayed in a form
+        *
+        * @param FormOptions $opts
         * @return array
         */
        function getExtraOptions( $opts ) {
-               $opts->consumeValues( array( 'showlinkedto', 'target', 'tagfilter' ) );
-               $extraOpts = array();
-               $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
+               $extraOpts = parent::getExtraOptions( $opts );
+
+               $opts->consumeValues( array( 'showlinkedto', 'target' ) );
+
                $extraOpts['target'] = array( $this->msg( 'recentchangeslinked-page' )->escaped(),
                        Xml::input( 'target', 40, str_replace( '_', ' ', $opts['target'] ) ) .
                        Xml::check( 'showlinkedto', $opts['showlinkedto'], array( 'id' => 'showlinkedto' ) ) . ' ' .
                        Xml::label( $this->msg( 'recentchangeslinked-to' )->text(), 'showlinkedto' ) );
-               $tagFilter = ChangeTags::buildTagFilterSelector( $opts['tagfilter'] );
-               if ( $tagFilter ) {
-                       $extraOpts['tagfilter'] = $tagFilter;
-               }
+
                return $extraOpts;
        }