Merge "Special:BlockList: Update remove/change block links"
[mediawiki.git] / includes / widget / ComplexTitleInputWidget.php
blob337f316af546113c4c968c6c57d0d6c05035e3a2
1 <?php
3 namespace MediaWiki\Widget;
5 use OOUI\Widget;
7 /**
8 * Complex title input widget.
10 * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
11 * @license MIT
13 class ComplexTitleInputWidget extends Widget {
14 /** @var array */
15 protected $config;
16 /** @var NamespaceInputWidget|null */
17 protected $namespace = null;
18 /** @var TitleInputWidget|null */
19 protected $title = null;
21 /**
22 * Like TitleInputWidget, but the namespace has to be input through a separate dropdown field.
24 * @param array $config Configuration options
25 * - array $config['namespace'] Configuration for the NamespaceInputWidget dropdown
26 * with list of namespaces
27 * - array $config['title'] Configuration for the TitleInputWidget text field
28 * @phan-param array{namespace?:array,title?:array} $config
30 public function __construct( array $config = [] ) {
31 // Configuration initialization
32 $config = array_merge(
34 'namespace' => [],
35 'title' => [],
37 $config
40 parent::__construct( $config );
42 // Properties
43 $this->config = $config;
44 $this->namespace = new NamespaceInputWidget( $config['namespace'] );
45 $this->title = new TitleInputWidget( array_merge(
46 $config['title'],
48 'relative' => true,
49 'namespace' => $config['namespace']['value'] ?? null,
51 ) );
53 // Initialization
54 $this
55 ->addClasses( [ 'mw-widget-complexTitleInputWidget' ] )
56 ->appendContent( $this->namespace, $this->title );
59 protected function getJavaScriptClassName() {
60 return 'mw.widgets.ComplexTitleInputWidget';
63 public function getConfig( &$config ) {
64 $config['namespace'] = $this->config['namespace'];
65 $config['namespace']['dropdown']['$overlay'] = true;
66 $config['title'] = $this->config['title'];
67 $config['title']['$overlay'] = true;
68 return parent::getConfig( $config );