wiki.techinc.nl/includes/htmlform/fields/HTMLSelectNamespace.php
Bartosz Dziewoński 6a366c3300 HTMLForm: Refactor loading of modules required to infuse fields
Rather than have a master list in autoinfuse.js (duplicated in
hide-if.js), we put this information in each field class and put it
in the generated HTML as a separate 'data-' attribute. This also
allows new fields defined by extensions to be correctly autoinfused.

Change-Id: I3da75706209cbc16b19cc3f02b355e58ca75fec9
2016-08-22 17:35:35 +00:00

45 lines
964 B
PHP

<?php
/**
* Wrapper for Html::namespaceSelector to use in HTMLForm
*/
class HTMLSelectNamespace extends HTMLFormField {
public function __construct( $params ) {
parent::__construct( $params );
$this->mAllValue = array_key_exists( 'all', $params )
? $params['all']
: 'all';
}
function getInputHTML( $value ) {
return Html::namespaceSelector(
[
'selected' => $value,
'all' => $this->mAllValue
], [
'name' => $this->mName,
'id' => $this->mID,
'class' => 'namespaceselector',
]
);
}
public function getInputOOUI( $value ) {
return new MediaWiki\Widget\NamespaceInputWidget( [
'value' => $value,
'name' => $this->mName,
'id' => $this->mID,
'includeAllValue' => $this->mAllValue,
] );
}
protected function getOOUIModules() {
// FIXME: NamespaceInputWidget should be in its own module (probably?)
return [ 'mediawiki.widgets' ];
}
protected function shouldInfuseOOUI() {
return true;
}
}