Merge "Remove not used private member variable mParserWarnings from OutputPage"
[mediawiki.git] / includes / widget / ComplexTitleInputWidget.php
blobea0ef9e293cad2efea272f992c818cc8926d9df0
1 <?php
2 /**
3 * MediaWiki Widgets – ComplexTitleInputWidget class.
5 * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
6 * @license The MIT License (MIT); see LICENSE.txt
7 */
8 namespace MediaWiki\Widget;
10 /**
11 * Complex title input widget.
13 class ComplexTitleInputWidget extends \OOUI\Widget {
15 protected $namespace = null;
16 protected $title = null;
18 /**
19 * Like TitleInputWidget, but the namespace has to be input through a separate dropdown field.
21 * @param array $config Configuration options
22 * @param array $config['namespace'] Configuration for the NamespaceInputWidget dropdown
23 * with list of namespaces
24 * @param array $config['title'] Configuration for the TitleInputWidget text field
26 public function __construct( array $config = array() ) {
27 // Configuration initialization
28 $config = array_merge(
29 array(
30 'namespace' => array(),
31 'title' => array(),
33 $config
36 // Parent constructor
37 parent::__construct( $config );
39 // Properties
40 $this->config = $config;
41 $this->namespace = new NamespaceInputWidget( $config['namespace'] );
42 $this->title = new TitleInputWidget( array_merge(
43 $config['title'],
44 array(
45 // The inner TitleInputWidget shouldn't be infusable,
46 // only the ComplexTitleInputWidget itself can be.
47 'infusable' => false,
48 'relative' => true,
49 'namespace' => isset( $config['namespace']['value'] ) ?
50 $config['namespace']['value'] :
51 null,
53 ) );
55 // Initialization
56 $this
57 ->addClasses( array( 'mw-widget-complexTitleInputWidget' ) )
58 ->appendContent( $this->namespace, $this->title );
61 protected function getJavaScriptClassName() {
62 return 'mw.widgets.ComplexTitleInputWidget';
65 public function getConfig( &$config ) {
66 $config['namespace'] = $this->config['namespace'];
67 $config['title'] = $this->config['title'];
68 return parent::getConfig( $config );