aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>2019-02-21 15:26:00 +0000
committerGerrit Code Review <gerrit@wikimedia.org>2019-02-21 15:26:00 +0000
commitbf6bca499145d513a76140f6ee2df4f92f3ed397 (patch)
treeb0ca5f244d82ee1f8fa482105158712fcc31185d
parent1005e91c8c855ef76656d1b644116449e41db434 (diff)
parenta7fd92a95e2ee3bee58b46e77a0699b8bedb98de (diff)
downloadmediawikicore-bf6bca499145d513a76140f6ee2df4f92f3ed397.tar.gz
mediawikicore-bf6bca499145d513a76140f6ee2df4f92f3ed397.zip
Merge "mw.widgets.TitleWidget: Add 'excludeDynamicNamespaces' config"
-rw-r--r--includes/htmlform/fields/HTMLTitlesMultiselectField.php3
-rw-r--r--includes/widget/TitlesMultiselectWidget.php8
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js7
3 files changed, 18 insertions, 0 deletions
diff --git a/includes/htmlform/fields/HTMLTitlesMultiselectField.php b/includes/htmlform/fields/HTMLTitlesMultiselectField.php
index 7b099ca0d0b4..1cfbd5fef75d 100644
--- a/includes/htmlform/fields/HTMLTitlesMultiselectField.php
+++ b/includes/htmlform/fields/HTMLTitlesMultiselectField.php
@@ -102,6 +102,9 @@ class HTMLTitlesMultiselectField extends HTMLTitleTextField {
if ( isset( $this->mParams['showMissing'] ) ) {
$params['showMissing'] = $this->mParams['showMissing'];
}
+ if ( isset( $this->mParams['excludeDynamicNamespaces'] ) ) {
+ $params['excludeDynamicNamespaces'] = $this->mParams['excludeDynamicNamespaces'];
+ }
if ( isset( $this->mParams['input'] ) ) {
$params['input'] = $this->mParams['input'];
diff --git a/includes/widget/TitlesMultiselectWidget.php b/includes/widget/TitlesMultiselectWidget.php
index 3246e7d8914e..ac342596a8dc 100644
--- a/includes/widget/TitlesMultiselectWidget.php
+++ b/includes/widget/TitlesMultiselectWidget.php
@@ -11,10 +11,12 @@ namespace MediaWiki\Widget;
class TitlesMultiselectWidget extends TagMultiselectWidget {
protected $showMissing = null;
+ protected $excludeDynamicNamespaces = null;
/**
* @param array $config Configuration options
* - bool $config['showMissing'] Show missing pages
+ * - bool $config['excludeDynamicNamespaces'] Exclude pages in negative namespaces
*/
public function __construct( array $config = [] ) {
parent::__construct( $config );
@@ -23,6 +25,9 @@ class TitlesMultiselectWidget extends TagMultiselectWidget {
if ( isset( $config['showMissing'] ) ) {
$this->showMissing = $config['showMissing'];
}
+ if ( isset( $config['excludeDynamicNamespaces'] ) ) {
+ $this->excludeDynamicNamespaces = $config['excludeDynamicNamespaces'];
+ }
$this->addClasses( [ 'mw-widgets-titlesMultiselectWidget' ] );
}
@@ -35,6 +40,9 @@ class TitlesMultiselectWidget extends TagMultiselectWidget {
if ( $this->showMissing !== null ) {
$config['showMissing'] = $this->showMissing;
}
+ if ( $this->excludeDynamicNamespaces !== null ) {
+ $config['excludeDynamicNamespaces'] = $this->excludeDynamicNamespaces;
+ }
return parent::getConfig( $config );
}
diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js b/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
index cb1281d42c35..6f4c72c5019c 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
@@ -26,6 +26,7 @@
* @cfg {boolean} [showMissing=true] Show missing pages
* @cfg {boolean} [addQueryInput=true] Add exact user's input query to results
* @cfg {boolean} [excludeCurrentPage] Exclude the current page from suggestions
+ * @cfg {boolean} [excludeDynamicNamespaces] Exclude pages whose namespace is negative
* @cfg {boolean} [validateTitle=true] Whether the input must be a valid title
* @cfg {boolean} [required=false] Whether the input must not be empty
* @cfg {boolean} [highlightSearchQuery=true] Highlight the partial query the user used for this title
@@ -51,6 +52,7 @@
this.showMissing = config.showMissing !== false;
this.addQueryInput = config.addQueryInput !== false;
this.excludeCurrentPage = !!config.excludeCurrentPage;
+ this.excludeDynamicNamespaces = !!config.excludeDynamicNamespaces;
this.validateTitle = config.validateTitle !== undefined ? config.validateTitle : true;
this.highlightSearchQuery = config.highlightSearchQuery === undefined ? true : !!config.highlightSearchQuery;
this.cache = config.cache;
@@ -238,6 +240,11 @@
if ( this.excludeCurrentPage && suggestionPage.title === currentPageName && suggestionPage.title !== titleObj.getPrefixedText() ) {
continue;
}
+
+ // When excludeDynamicNamespaces is set, ignore all pages with negative namespace
+ if ( this.excludeDynamicNamespaces && suggestionPage.ns < 0 ) {
+ continue;
+ }
pageData[ suggestionPage.title ] = {
known: suggestionPage.known !== undefined,
missing: suggestionPage.missing !== undefined,