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'];
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 );
if ( isset( $config['showMissing'] ) ) {
$this->showMissing = $config['showMissing'];
}
+ if ( isset( $config['excludeDynamicNamespaces'] ) ) {
+ $this->excludeDynamicNamespaces = $config['excludeDynamicNamespaces'];
+ }
$this->addClasses( [ 'mw-widgets-titlesMultiselectWidget' ] );
}
if ( $this->showMissing !== null ) {
$config['showMissing'] = $this->showMissing;
}
+ if ( $this->excludeDynamicNamespaces !== null ) {
+ $config['excludeDynamicNamespaces'] = $this->excludeDynamicNamespaces;
+ }
return parent::getConfig( $config );
}
* @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
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;
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,