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
16 protected $namespace = null;
18 protected $relative = null;
20 protected $suggestions = null;
22 protected $highlightFirst = null;
24 protected $validateTitle = null;
25
37 public function __construct( array $config = [] ) {
38 parent::__construct(
39 array_merge( [ 'maxLength' => 255 ], $config )
40 );
41
42 // Properties, which are ignored in PHP and just shipped back to JS
43 if ( isset( $config['namespace'] ) ) {
44 $this->namespace = $config['namespace'];
45 }
46 if ( isset( $config['relative'] ) ) {
47 $this->relative = $config['relative'];
48 }
49 if ( isset( $config['suggestions'] ) ) {
50 $this->suggestions = $config['suggestions'];
51 }
52 if ( isset( $config['highlightFirst'] ) ) {
53 $this->highlightFirst = $config['highlightFirst'];
54 }
55 if ( isset( $config['validateTitle'] ) ) {
56 $this->validateTitle = $config['validateTitle'];
57 }
58
59 // Initialization
60 $this->addClasses( [ 'mw-widget-titleInputWidget' ] );
61 }
62
63 protected function getJavaScriptClassName() {
64 return 'mw.widgets.TitleInputWidget';
65 }
66
67 public function getConfig( &$config ) {
68 if ( $this->namespace !== null ) {
69 $config['namespace'] = $this->namespace;
70 }
71 if ( $this->relative !== null ) {
72 $config['relative'] = $this->relative;
73 }
74 if ( $this->suggestions !== null ) {
75 $config['suggestions'] = $this->suggestions;
76 }
77 if ( $this->highlightFirst !== null ) {
78 $config['highlightFirst'] = $this->highlightFirst;
79 }
80 if ( $this->validateTitle !== null ) {
81 $config['validateTitle'] = $this->validateTitle;
82 }
83 $config['$overlay'] = true;
84 return parent::getConfig( $config );
85 }
86}