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;
26 protected $creatable = null;
27
41 public function __construct( array $config = [] ) {
42 parent::__construct(
43 array_merge( [ 'maxLength' => 255 ], $config )
44 );
45
46 // Properties, which are ignored in PHP and just shipped back to JS
47 if ( isset( $config['namespace'] ) ) {
48 $this->namespace = $config['namespace'];
49 }
50 if ( isset( $config['relative'] ) ) {
51 $this->relative = $config['relative'];
52 }
53 if ( isset( $config['suggestions'] ) ) {
54 $this->suggestions = $config['suggestions'];
55 }
56 if ( isset( $config['highlightFirst'] ) ) {
57 $this->highlightFirst = $config['highlightFirst'];
58 }
59 if ( isset( $config['validateTitle'] ) ) {
60 $this->validateTitle = $config['validateTitle'];
61 }
62 if ( isset( $config['creatable'] ) ) {
63 $this->creatable = $config['creatable'];
64 }
65
66 // Initialization
67 $this->addClasses( [ 'mw-widget-titleInputWidget' ] );
68 }
69
71 protected function getJavaScriptClassName() {
72 return 'mw.widgets.TitleInputWidget';
73 }
74
76 public function getConfig( &$config ) {
77 if ( $this->namespace !== null ) {
78 $config['namespace'] = $this->namespace;
79 }
80 if ( $this->relative !== null ) {
81 $config['relative'] = $this->relative;
82 }
83 if ( $this->suggestions !== null ) {
84 $config['suggestions'] = $this->suggestions;
85 }
86 if ( $this->highlightFirst !== null ) {
87 $config['highlightFirst'] = $this->highlightFirst;
88 }
89 if ( $this->validateTitle !== null ) {
90 $config['validateTitle'] = $this->validateTitle;
91 }
92 if ( $this->creatable !== null ) {
93 $config['creatable'] = $this->creatable;
94 }
95
96 $config['$overlay'] = true;
97 return parent::getConfig( $config );
98 }
99}