1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* MediaWiki Widgets – SearchInputWidget class. |
4
|
|
|
* |
5
|
|
|
* @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt |
6
|
|
|
* @license The MIT License (MIT); see LICENSE.txt |
7
|
|
|
*/ |
8
|
|
|
namespace MediaWiki\Widget; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Search input widget. |
12
|
|
|
*/ |
13
|
|
|
class SearchInputWidget extends TitleInputWidget { |
14
|
|
|
|
15
|
|
|
protected $pushPending = false; |
16
|
|
|
protected $performSearchOnClick = true; |
17
|
|
|
protected $validateTitle = false; |
18
|
|
|
protected $highlightFirst = false; |
19
|
|
|
protected $dataLocation = 'header'; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @param array $config Configuration options |
23
|
|
|
* @param int|null $config['pushPending'] Whether the input should be visually marked as |
|
|
|
|
24
|
|
|
* "pending", while requesting suggestions (default: true) |
25
|
|
|
* @param boolean|null $config['performSearchOnClick'] If true, the script will start a search |
|
|
|
|
26
|
|
|
* whenever a user hits a suggestion. If false, the text of the suggestion is inserted into the |
27
|
|
|
* text field only (default: true) |
28
|
|
|
* @param string $config['dataLocation'] Where the search input field will be |
|
|
|
|
29
|
|
|
* used (header or content, default: header) |
30
|
|
|
*/ |
31
|
|
|
public function __construct( array $config = [] ) { |
32
|
|
|
$config = array_merge( [ |
33
|
|
|
'maxLength' => null, |
34
|
|
|
'type' => 'search', |
35
|
|
|
'icon' => 'search', |
36
|
|
|
], $config ); |
37
|
|
|
|
38
|
|
|
// Parent constructor |
39
|
|
|
parent::__construct( $config ); |
40
|
|
|
|
41
|
|
|
// Properties, which are ignored in PHP and just shipped back to JS |
42
|
|
|
if ( isset( $config['pushPending'] ) ) { |
43
|
|
|
$this->pushPending = $config['pushPending']; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
if ( isset( $config['performSearchOnClick'] ) ) { |
47
|
|
|
$this->performSearchOnClick = $config['performSearchOnClick']; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
if ( isset( $config['dataLocation'] ) ) { |
51
|
|
|
// identifies the location of the search bar for tracking purposes |
52
|
|
|
$this->dataLocation = $config['dataLocation']; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
// Initialization |
56
|
|
|
$this->addClasses( [ 'mw-widget-searchInputWidget' ] ); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
protected function getJavaScriptClassName() { |
60
|
|
|
return 'mw.widgets.SearchInputWidget'; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function getConfig( &$config ) { |
64
|
|
|
$config['pushPending'] = $this->pushPending; |
65
|
|
|
$config['performSearchOnClick'] = $this->performSearchOnClick; |
66
|
|
|
if ( $this->dataLocation ) { |
67
|
|
|
$config['dataLocation'] = $this->dataLocation; |
68
|
|
|
} |
69
|
|
|
return parent::getConfig( $config ); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.