wiki.techinc.nl/includes/htmlform/HTMLSelectNamespace.php
Bartosz Dziewoński 2ac9e2a432 Implement NamespaceInputWidget
* Add PHP version of NamespaceInputWidget, co-authored by Florian,
  which consists of a DropdownInputWidget offering a choice of
  namespaces and two CheckboxInputWidgets allowing to also match
  associated namespace (talk/content) or to invert the choice.
* Add an incomplete JS version of NamespaceInputWidget, which is only
  really functional when infused from the PHP version (it can't
  generate the dropdown by itself, for example). Implement some JS to
  improve the experience of selecting the "all namespaces" option in
  the dropdown (by disabling the checkboxes when this happens).
* Split off a 'mediawiki.widgets.styles' module, which has the basic
  styles for PHP widgets which are to be loaded in the head. Make
  OutputPage::enableOOUI() also add this module (which should stay
  reasonably small).
* Use the new widget in HTMLForm's HTMLSelectNamespace field. It can
  be seen in action on Special:LinkSearch, for example.

Co-Authored-By: Florian <florian.schmidt.welzow@t-online.de>
Co-Authored-By: Bartosz Dziewoński <matma.rex@gmail.com>
Change-Id: I5cbfa9d0f6a8641148ce476b7dbe65e9096b4485
2015-07-17 13:33:59 +00:00

35 lines
872 B
PHP

<?php
/**
* Wrapper for Html::namespaceSelector to use in HTMLForm
*/
class HTMLSelectNamespace extends HTMLFormField {
public function __construct( $params ) {
parent::__construct( $params );
$this->mAllValue = isset( $this->mParams['all'] ) ? $this->mParams['all'] : 'all';
}
function getInputHTML( $value ) {
return Html::namespaceSelector(
array(
'selected' => $value,
'all' => $this->mAllValue
), array(
'name' => $this->mName,
'id' => $this->mID,
'class' => 'namespaceselector',
)
);
}
public function getInputOOUI( $value ) {
return new MediaWiki\Widget\NamespaceInputWidget( array(
'valueNamespace' => $value,
'nameNamespace' => $this->mName,
'id' => $this->mID,
'includeAllValue' => $this->mAllValue,
// Disable additional checkboxes
'nameInvert' => null,
'nameAssociated' => null,
) );
}
}