wiki.techinc.nl/includes/widget/TitlesMultiselectWidget.php
Moriel Schottlender a7fd92a95e mw.widgets.TitleWidget: Add 'excludeDynamicNamespaces' config
Allow excluding all pages that are in dynamic (negative) namespaces.

Bug: T208355
Change-Id: I9b39f66ac828bc0c100a2fc347b365f75672efb1
2019-02-14 17:26:03 -08:00

50 lines
1.3 KiB
PHP

<?php
namespace MediaWiki\Widget;
/**
* Widget to select multiple titles.
*
* @copyright 2017 MediaWiki Widgets Team and others; see AUTHORS.txt
* @license MIT
*/
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 );
// Properties
if ( isset( $config['showMissing'] ) ) {
$this->showMissing = $config['showMissing'];
}
if ( isset( $config['excludeDynamicNamespaces'] ) ) {
$this->excludeDynamicNamespaces = $config['excludeDynamicNamespaces'];
}
$this->addClasses( [ 'mw-widgets-titlesMultiselectWidget' ] );
}
protected function getJavaScriptClassName() {
return 'mw.widgets.TitlesMultiselectWidget';
}
public function getConfig( &$config ) {
if ( $this->showMissing !== null ) {
$config['showMissing'] = $this->showMissing;
}
if ( $this->excludeDynamicNamespaces !== null ) {
$config['excludeDynamicNamespaces'] = $this->excludeDynamicNamespaces;
}
return parent::getConfig( $config );
}
}