Implement namespace inversion on WhatLinksHere
authorPiRSquared17 <pirsquared@tools.wmflabs.org>
Wed, 19 Nov 2014 00:01:11 +0000 (00:01 +0000)
committerUmherirrender <umherirrender_de.wp@web.de>
Wed, 7 Jan 2015 19:16:08 +0000 (19:16 +0000)
This is basically the same as Ie3f72d97e2ba did for SpecialNewPages.

Bug: T18848
Change-Id: Id6cbdaca50c81129352962996dc5360f64026ed1

includes/specials/SpecialWhatlinkshere.php
languages/i18n/en.json
languages/i18n/qqq.json

index e373cff..07ea933 100644 (file)
@@ -58,6 +58,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                $opts->add( 'hidetrans', false );
                $opts->add( 'hidelinks', false );
                $opts->add( 'hideimages', false );
+               $opts->add( 'invert', false );
 
                $opts->fetchValuesFromRequest( $this->getRequest() );
                $opts->validateIntBounds( 'limit', 0, 5000 );
@@ -125,15 +126,17 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
 
                $useLinkNamespaceDBFields = $this->getConfig()->get( 'UseLinkNamespaceDBFields' );
                $namespace = $this->opts->getValue( 'namespace' );
+               $invert = $this->opts->getValue( 'invert' );
+               $nsComparison = ( $invert ? '!= ' : '= ' ) . $dbr->addQuotes( $namespace );
                if ( is_int( $namespace ) ) {
                        if ( $useLinkNamespaceDBFields ) {
-                               $conds['pagelinks']['pl_from_namespace'] = $namespace;
-                               $conds['templatelinks']['tl_from_namespace'] = $namespace;
-                               $conds['imagelinks']['il_from_namespace'] = $namespace;
+                               $conds['pagelinks'][] = "pl_from_namespace $nsComparison";
+                               $conds['templatelinks'][] = "tl_from_namespace $nsComparison";
+                               $conds['imagelinks'][] = "il_from_namespace $nsComparison";
                        } else {
-                               $conds['pagelinks']['page_namespace'] = $namespace;
-                               $conds['templatelinks']['page_namespace'] = $namespace;
-                               $conds['imagelinks']['page_namespace'] = $namespace;
+                               $conds['pagelinks'][] = "page_namespace $nsComparison";
+                               $conds['templatelinks'][] = "page_namespace $nsComparison";
+                               $conds['imagelinks'][] = "page_namespace $nsComparison";
                        }
                }
 
@@ -419,6 +422,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
 
                $target = $this->target ? $this->target->getPrefixedText() : '';
                $namespace = $this->opts->consumeValue( 'namespace' );
+               $nsinvert = $this->opts->consumeValue( 'invert' );
 
                # Build up the form
                $f = Xml::openElement( 'form', array( 'action' => wfScript() ) );
@@ -450,6 +454,15 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                        )
                );
 
+               $f .= '&#160;' .
+                       Xml::checkLabel(
+                               $this->msg( 'invert' )->text(),
+                               'invert',
+                               'nsinvert',
+                               $nsinvert,
+                               array( 'title' => $this->msg( 'tooltip-whatlinkshere-invert' )->text() )
+                       );
+
                $f .= ' ';
 
                # Submit
index 45c7105..1c40f75 100644 (file)
        "namespace": "Namespace:",
        "invert": "Invert selection",
        "tooltip-invert": "Check this box to hide changes to pages within the selected namespace (and the associated namespace if checked)",
+       "tooltip-whatlinkshere-invert": "Check this box to hide links from pages within the selected namespace.",
        "namespace_association": "Associated namespace",
        "tooltip-namespace_association": "Check this box to also include the talk or subject namespace associated with the selected namespace",
        "blanknamespace": "(Main)",
index 9b09078..2b29b5f 100644 (file)
        "namespace": "This message is located at [[Special:Contributions]].\n{{Identical|Namespace}}",
        "invert": "Displayed in [[Special:RecentChanges|RecentChanges]], [[Special:RecentChangesLinked|RecentChangesLinked]] and [[Special:Watchlist|Watchlist]].\n\nThis message means \"Invert selection of namespace\".\n\nThis message has a tooltip {{msg-mw|tooltip-invert}}\n{{Identical|Invert selection}}",
        "tooltip-invert": "Used in [[Special:Recentchanges]] as a tooltip for the invert checkbox. See also the message {{msg-mw|invert}}",
+       "tooltip-whatlinkshere-invert": "Used in [[Special:Whatlinkshere]] as a tooltip for the invert checkbox.\n\nSee also:\n* {{msg-mw|tooltip-invert}}\n* {{msg-mw|invert}}",
        "namespace_association": "Used in [[Special:Recentchanges]] with a checkbox which selects the associated namespace to be added to the selected namespace, so that both are searched (or excluded depending on another checkbox selection). The association is between a namespace and its talk namespace.\n\nThis message has a tooltip {{msg-mw|tooltip-namespace association}}",
        "tooltip-namespace_association": "Used in [[Special:Recentchanges]] as a tooltip for the associated namespace checkbox.\n\nSee also:\n* {{msg-mw|Namespace association}}",
        "blanknamespace": "Name for main namespace (blank namespace) in drop-down menus at [[Special:RecentChanges]] and other special pages.\n{{Identical|Main}}",