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;
17 protected $namespace = null;
19 protected $title = null;
20
30 public function __construct( array $config = [] ) {
31 // Configuration initialization
32 $config = array_merge(
33 [
34 'namespace' => [],
35 'title' => [],
36 ],
38 );
39
40 parent::__construct( $config );
41
42 // Properties
43 $this->config = $config;
44 $this->namespace = new NamespaceInputWidget( $config['namespace'] );
45 $this->title = new TitleInputWidget( array_merge(
46 $config['title'],
47 [
48 'relative' => true,
49 'namespace' => $config['namespace']['value'] ?? null,
50 ]
51 ) );
52
53 // Initialization
54 $this
55 ->addClasses( [ 'mw-widget-complexTitleInputWidget' ] )
56 ->appendContent( $this->namespace, $this->title );
57 }
58
59 protected function getJavaScriptClassName() {
60 return 'mw.widgets.ComplexTitleInputWidget';
61 }
62
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 );
69 }
70}
__construct(array $config=[])
Like TitleInputWidget, but the namespace has to be input through a separate dropdown field.