Merge "(bug 31704) Allow selection of associated namespace on the watchlist"
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 1 May 2012 22:22:09 +0000 (22:22 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 1 May 2012 22:22:09 +0000 (22:22 +0000)
RELEASE-NOTES-1.20
includes/specials/SpecialWatchlist.php

index bd8f775..8ee49fc 100644 (file)
@@ -46,6 +46,7 @@ production.
   Special:Version
 * Edit notices can now be translated.
 * (bug 22887) Add warning and tracking category for preprocessor errors
+* (bug 31704) Allow selection of associated namespace on the watchlist
 
 === Bug fixes in 1.20 ===
 * (bug 30245) Use the correct way to construct a log page title.
index e0f2ff2..eafdde4 100644 (file)
@@ -116,6 +116,7 @@ class SpecialWatchlist extends SpecialPage {
                /* bool  */ 'hideOwn'   => (int)$user->getBoolOption( 'watchlisthideown' ),
                /* ?     */ 'namespace' => 'all',
                /* ?     */ 'invert'    => false,
+               /* bool  */ 'associated' => false,
                );
                $this->customFilters = array();
                wfRunHooks( 'SpecialWatchlistFilters', array( $this, &$this->customFilters ) );
@@ -148,13 +149,20 @@ class SpecialWatchlist extends SpecialPage {
 
                # Get namespace value, if supplied, and prepare a WHERE fragment
                $nameSpace = $request->getIntOrNull( 'namespace' );
-               $invert = $request->getIntOrNull( 'invert' );
+               $invert = $request->getBool( 'invert' );
+               $associated = $request->getBool( 'associated' );
                if ( !is_null( $nameSpace ) ) {
+                       $eq_op = $invert ? '!=' : '=';\r
+                       $bool_op = $invert ? 'AND' : 'OR';
                        $nameSpace = intval( $nameSpace ); // paranioa
-                       if ( $invert ) {
-                               $nameSpaceClause = "rc_namespace != $nameSpace";
+                       if ( !$associated ) {
+                               $nameSpaceClause = "rc_namespace $eq_op $nameSpace";
                        } else {
-                               $nameSpaceClause = "rc_namespace = $nameSpace";
+                               $associatedNS = MWNamespace::getAssociated( $nameSpace );\r
+                               $nameSpaceClause =
+                                       "rc_namespace $eq_op $nameSpace " .\r
+                                       $bool_op .\r
+                                       " rc_namespace $eq_op $associatedNS";
                        }
                } else {
                        $nameSpace = '';
@@ -162,6 +170,7 @@ class SpecialWatchlist extends SpecialPage {
                }
                $values['namespace'] = $nameSpace;
                $values['invert'] = $invert;
+               $values['associated'] = $associated;
 
                if( is_null( $values['days'] ) || !is_numeric( $values['days'] ) ) {
                        $big = 1000; /* The magical big */
@@ -345,7 +354,20 @@ class SpecialWatchlist extends SpecialPage {
                                'class' => 'namespaceselector',
                        )
                ) . '&#160;';
-               $form .= Xml::checkLabel( $this->msg( 'invert' )->text(), 'invert', 'nsinvert', $invert ) . '&#160;';
+               $form .= Xml::checkLabel(
+                       $this->msg( 'invert' )->text(),
+                       'invert',
+                       'nsinvert',
+                       $invert,
+                       array( 'title' => $this->msg( 'tooltip-invert' )->text() )
+               ) . '&#160;';
+               $form .= Xml::checkLabel(
+                       $this->msg( 'namespace_association' )->text(),
+                       'associated',
+                       'associated',
+                       $associated,
+                       array( 'title' => $this->msg( 'tooltip-namespace_association' )->text() )
+               ) . '&#160;';
                $form .= Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . '</p>';
                $form .= Html::hidden( 'days', $values['days'] );
                foreach ( $filters as $key => $msg ) {