summaryrefslogtreecommitdiff
path: root/includes/widget/ComplexTitleInputWidget.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-12-20 09:00:55 +0100
committerPierre Schmitz <pierre@archlinux.de>2015-12-20 09:00:55 +0100
commita2190ac74dd4d7080b12bab90e552d7aa81209ef (patch)
tree8b31f38de9882d18df54cf8d9e0de74167a094eb /includes/widget/ComplexTitleInputWidget.php
parent15e69f7b20b6596b9148030acce5b59993b95a45 (diff)
parent257401d8b2cf661adf36c84b0e3fd1cf85e33c22 (diff)
Merge branch 'mw-1.26'
Diffstat (limited to 'includes/widget/ComplexTitleInputWidget.php')
-rw-r--r--includes/widget/ComplexTitleInputWidget.php67
1 files changed, 67 insertions, 0 deletions
diff --git a/includes/widget/ComplexTitleInputWidget.php b/includes/widget/ComplexTitleInputWidget.php
new file mode 100644
index 00000000..73ef54c8
--- /dev/null
+++ b/includes/widget/ComplexTitleInputWidget.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * MediaWiki Widgets – ComplexTitleInputWidget class.
+ *
+ * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+namespace MediaWiki\Widget;
+
+/**
+ * Complex title input widget.
+ */
+class ComplexTitleInputWidget extends \OOUI\Widget {
+
+ protected $namespace = null;
+ protected $title = null;
+
+ /**
+ * Like TitleInputWidget, but the namespace has to be input through a separate dropdown field.
+ *
+ * @param array $config Configuration options
+ * @param array $config['namespace'] Configuration for the NamespaceInputWidget dropdown with list
+ * of namespaces
+ * @param array $config['title'] Configuration for the TitleInputWidget text field
+ */
+ public function __construct( array $config = array() ) {
+ // Configuration initialization
+ $config = array_merge(
+ array(
+ 'namespace' => array(),
+ 'title' => array(),
+ ),
+ $config
+ );
+
+ // Parent constructor
+ parent::__construct( $config );
+
+ // Properties
+ $this->config = $config;
+ $this->namespace = new NamespaceInputWidget( $config['namespace'] );
+ $this->title = new TitleInputWidget( array_merge(
+ $config['title'],
+ array(
+ // The inner TitleInputWidget shouldn't be infusable, only the ComplexTitleInputWidget itself can be.
+ 'infusable' => false,
+ 'relative' => true,
+ 'namespace' => isset( $config['namespace']['value'] ) ? $config['namespace']['value'] : null,
+ )
+ ) );
+
+ // Initialization
+ $this
+ ->addClasses( array( 'mw-widget-complexTitleInputWidget' ) )
+ ->appendContent( $this->namespace, $this->title );
+ }
+
+ protected function getJavaScriptClassName() {
+ return 'mw.widgets.ComplexTitleInputWidget';
+ }
+
+ public function getConfig( &$config ) {
+ $config['namespace'] = $this->config['namespace'];
+ $config['title'] = $this->config['title'];
+ return parent::getConfig( $config );
+ }
+}