MediaWiki master
TitleInputWidget.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Widget;
4
5use OOUI\TextInputWidget;
6
13class TitleInputWidget extends TextInputWidget {
14
15 protected $namespace = null;
16 protected $relative = null;
17 protected $suggestions = null;
18 protected $highlightFirst = null;
19 protected $validateTitle = null;
20
32 public function __construct( array $config = [] ) {
33 parent::__construct(
34 array_merge( [ 'maxLength' => 255 ], $config )
35 );
36
37 // Properties, which are ignored in PHP and just shipped back to JS
38 if ( isset( $config['namespace'] ) ) {
39 $this->namespace = $config['namespace'];
40 }
41 if ( isset( $config['relative'] ) ) {
42 $this->relative = $config['relative'];
43 }
44 if ( isset( $config['suggestions'] ) ) {
45 $this->suggestions = $config['suggestions'];
46 }
47 if ( isset( $config['highlightFirst'] ) ) {
48 $this->highlightFirst = $config['highlightFirst'];
49 }
50 if ( isset( $config['validateTitle'] ) ) {
51 $this->validateTitle = $config['validateTitle'];
52 }
53
54 // Initialization
55 $this->addClasses( [ 'mw-widget-titleInputWidget' ] );
56 }
57
58 protected function getJavaScriptClassName() {
59 return 'mw.widgets.TitleInputWidget';
60 }
61
62 public function getConfig( &$config ) {
63 if ( $this->namespace !== null ) {
64 $config['namespace'] = $this->namespace;
65 }
66 if ( $this->relative !== null ) {
67 $config['relative'] = $this->relative;
68 }
69 if ( $this->suggestions !== null ) {
70 $config['suggestions'] = $this->suggestions;
71 }
72 if ( $this->highlightFirst !== null ) {
73 $config['highlightFirst'] = $this->highlightFirst;
74 }
75 if ( $this->validateTitle !== null ) {
76 $config['validateTitle'] = $this->validateTitle;
77 }
78 $config['$overlay'] = true;
79 return parent::getConfig( $config );
80 }
81}