3 namespace MediaWiki\Widget
;
8 * Complex title input widget.
10 * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
13 class ComplexTitleInputWidget
extends Widget
{
16 /** @var NamespaceInputWidget|null */
17 protected $namespace = null;
18 /** @var TitleInputWidget|null */
19 protected $title = null;
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(
40 parent
::__construct( $config );
43 $this->config
= $config;
44 $this->namespace = new NamespaceInputWidget( $config['namespace'] );
45 $this->title
= new TitleInputWidget( array_merge(
49 'namespace' => $config['namespace']['value'] ??
null,
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 );