MediaWiki master
ComplexTitleInputWidget.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Widget;
4
5use OOUI\Widget;
6
13class ComplexTitleInputWidget extends Widget {
15 protected $config;
16 protected $namespace = null;
17 protected $title = null;
18
28 public function __construct( array $config = [] ) {
29 // Configuration initialization
30 $config = array_merge(
31 [
32 'namespace' => [],
33 'title' => [],
34 ],
36 );
37
38 parent::__construct( $config );
39
40 // Properties
41 $this->config = $config;
42 $this->namespace = new NamespaceInputWidget( $config['namespace'] );
43 $this->title = new TitleInputWidget( array_merge(
44 $config['title'],
45 [
46 'relative' => true,
47 'namespace' => $config['namespace']['value'] ?? null,
48 ]
49 ) );
50
51 // Initialization
52 $this
53 ->addClasses( [ 'mw-widget-complexTitleInputWidget' ] )
54 ->appendContent( $this->namespace, $this->title );
55 }
56
57 protected function getJavaScriptClassName() {
58 return 'mw.widgets.ComplexTitleInputWidget';
59 }
60
61 public function getConfig( &$config ) {
62 $config['namespace'] = $this->config['namespace'];
63 $config['namespace']['dropdown']['$overlay'] = true;
64 $config['title'] = $this->config['title'];
65 $config['title']['$overlay'] = true;
66 return parent::getConfig( $config );
67 }
68}
__construct(array $config=[])
Like TitleInputWidget, but the namespace has to be input through a separate dropdown field.