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