MediaWiki  1.34.0
TitleInputWidget.php
Go to the documentation of this file.
1 <?php
2 
3 namespace MediaWiki\Widget;
4 
11 class 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 }
MediaWiki\Widget\TitleInputWidget\$suggestions
$suggestions
Definition: TitleInputWidget.php:15
MediaWiki\Widget\TitleInputWidget\$relative
$relative
Definition: TitleInputWidget.php:14
MediaWiki\Widget\TitleInputWidget\$namespace
$namespace
Definition: TitleInputWidget.php:13
MediaWiki\Widget\TitleInputWidget\$highlightFirst
$highlightFirst
Definition: TitleInputWidget.php:16
MediaWiki\Widget\TitleInputWidget\__construct
__construct(array $config=[])
Definition: TitleInputWidget.php:30
MediaWiki\Widget\TitleInputWidget
Title input widget.
Definition: TitleInputWidget.php:11
MediaWiki\Widget\TitleInputWidget\$validateTitle
$validateTitle
Definition: TitleInputWidget.php:17
MediaWiki\Widget
Definition: CheckMatrixWidget.php:3
MediaWiki\Widget\TitleInputWidget\getJavaScriptClassName
getJavaScriptClassName()
Definition: TitleInputWidget.php:56
MediaWiki\$config
Config $config
Definition: MediaWiki.php:43
MediaWiki\Widget\TitleInputWidget\getConfig
getConfig(&$config)
Definition: TitleInputWidget.php:60