summaryrefslogtreecommitdiff
path: root/www/wiki/includes/htmlform/fields/HTMLSelectNamespace.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/includes/htmlform/fields/HTMLSelectNamespace.php')
-rw-r--r--www/wiki/includes/htmlform/fields/HTMLSelectNamespace.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/www/wiki/includes/htmlform/fields/HTMLSelectNamespace.php b/www/wiki/includes/htmlform/fields/HTMLSelectNamespace.php
new file mode 100644
index 00000000..f13aa177
--- /dev/null
+++ b/www/wiki/includes/htmlform/fields/HTMLSelectNamespace.php
@@ -0,0 +1,44 @@
+<?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';
+ }
+
+ public 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;
+ }
+}