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