MediaWiki REL1_30
SearchInputWidget.php
Go to the documentation of this file.
1<?php
8namespace MediaWiki\Widget;
9
14
15 protected $pushPending = false;
16 protected $performSearchOnClick = true;
17 protected $validateTitle = false;
18 protected $highlightFirst = false;
19 protected $dataLocation = 'header';
20
31 public function __construct( array $config = [] ) {
32 $config = array_merge( [
33 'maxLength' => null,
34 'icon' => 'search',
35 ], $config );
36
37 // Parent constructor
38 parent::__construct( $config );
39
40 // Properties, which are ignored in PHP and just shipped back to JS
41 if ( isset( $config['pushPending'] ) ) {
42 $this->pushPending = $config['pushPending'];
43 }
44
45 if ( isset( $config['performSearchOnClick'] ) ) {
46 $this->performSearchOnClick = $config['performSearchOnClick'];
47 }
48
49 if ( isset( $config['dataLocation'] ) ) {
50 // identifies the location of the search bar for tracking purposes
51 $this->dataLocation = $config['dataLocation'];
52 }
53
54 // Initialization
55 $this->addClasses( [ 'mw-widget-searchInputWidget' ] );
56 }
57
58 protected function getInputElement( $config ) {
59 return ( new \OOUI\Tag( 'input' ) )->setAttributes( [ 'type' => 'search' ] );
60 }
61
62 protected function getJavaScriptClassName() {
63 return 'mw.widgets.SearchInputWidget';
64 }
65
66 public function getConfig( &$config ) {
67 $config['pushPending'] = $this->pushPending;
68 $config['performSearchOnClick'] = $this->performSearchOnClick;
69 if ( $this->dataLocation ) {
70 $config['dataLocation'] = $this->dataLocation;
71 }
72 return parent::getConfig( $config );
73 }
74}
MediaWiki Widgets – ComplexNamespaceInputWidget class.