MediaWiki  1.34.0
SearchInputWidget.php
Go to the documentation of this file.
1 <?php
2 
3 namespace MediaWiki\Widget;
4 
12 
13  protected $performSearchOnClick = true;
14  protected $validateTitle = false;
15  protected $highlightFirst = false;
16  protected $dataLocation = 'header';
17  protected $showDescriptions = false;
18 
27  public function __construct( array $config = [] ) {
28  $config = array_merge( [
29  'maxLength' => null,
30  'icon' => 'search',
31  ], $config );
32 
33  parent::__construct( $config );
34 
35  // Properties, which are ignored in PHP and just shipped back to JS
36  if ( isset( $config['performSearchOnClick'] ) ) {
37  $this->performSearchOnClick = $config['performSearchOnClick'];
38  }
39 
40  if ( isset( $config['dataLocation'] ) ) {
41  // identifies the location of the search bar for tracking purposes
42  $this->dataLocation = $config['dataLocation'];
43  }
44 
45  if ( !empty( $config['showDescriptions'] ) ) {
46  $this->showDescriptions = true;
47  }
48 
49  // Initialization
50  $this->addClasses( [ 'mw-widget-searchInputWidget' ] );
51  }
52 
53  protected function getInputElement( $config ) {
54  return ( new \OOUI\Tag( 'input' ) )->setAttributes( [ 'type' => 'search' ] );
55  }
56 
57  protected function getJavaScriptClassName() {
58  return 'mw.widgets.SearchInputWidget';
59  }
60 
61  public function getConfig( &$config ) {
62  $config['performSearchOnClick'] = $this->performSearchOnClick;
63  if ( $this->dataLocation ) {
64  $config['dataLocation'] = $this->dataLocation;
65  }
66  if ( $this->showDescriptions ) {
67  $config['showDescriptions'] = true;
68  }
69  $config['$overlay'] = true;
70  return parent::getConfig( $config );
71  }
72 }
MediaWiki\Widget\SearchInputWidget\getInputElement
getInputElement( $config)
Definition: SearchInputWidget.php:53
MediaWiki\Widget\SearchInputWidget\getConfig
getConfig(&$config)
Definition: SearchInputWidget.php:61
MediaWiki\Widget\SearchInputWidget\__construct
__construct(array $config=[])
Definition: SearchInputWidget.php:27
MediaWiki\Widget\SearchInputWidget\$validateTitle
$validateTitle
Definition: SearchInputWidget.php:14
MediaWiki\Widget\SearchInputWidget
Search input widget.
Definition: SearchInputWidget.php:11
MediaWiki\Widget\SearchInputWidget\$highlightFirst
$highlightFirst
Definition: SearchInputWidget.php:15
MediaWiki\Widget\SearchInputWidget\$performSearchOnClick
$performSearchOnClick
Definition: SearchInputWidget.php:13
MediaWiki\Widget\TitleInputWidget
Title input widget.
Definition: TitleInputWidget.php:11
MediaWiki\Widget
Definition: CheckMatrixWidget.php:3
MediaWiki\Widget\SearchInputWidget\$showDescriptions
$showDescriptions
Definition: SearchInputWidget.php:17
MediaWiki\$config
Config $config
Definition: MediaWiki.php:43
MediaWiki\Widget\SearchInputWidget\getJavaScriptClassName
getJavaScriptClassName()
Definition: SearchInputWidget.php:57
MediaWiki\Widget\SearchInputWidget\$dataLocation
$dataLocation
Definition: SearchInputWidget.php:16