Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 27 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
TitleInputWidget | |
0.00% |
0 / 27 |
|
0.00% |
0 / 3 |
182 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
42 | |||
getJavaScriptClassName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getConfig | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
42 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Widget; |
4 | |
5 | use OOUI\TextInputWidget; |
6 | |
7 | /** |
8 | * Title input widget. |
9 | * |
10 | * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt |
11 | * @license MIT |
12 | */ |
13 | class TitleInputWidget extends TextInputWidget { |
14 | |
15 | protected $namespace = null; |
16 | protected $relative = null; |
17 | protected $suggestions = null; |
18 | protected $highlightFirst = null; |
19 | protected $validateTitle = null; |
20 | |
21 | /** |
22 | * @param array $config Configuration options |
23 | * - int|null $config['namespace'] Namespace to prepend to queries |
24 | * - bool|null $config['relative'] If a namespace is set, |
25 | * return a title relative to it (default: true) |
26 | * - bool|null $config['suggestions'] Display search suggestions (default: true) |
27 | * - bool|null $config['highlightFirst'] Automatically highlight |
28 | * the first result (default: true) |
29 | * - bool|null $config['validateTitle'] Whether the input must |
30 | * be a valid title (default: true) |
31 | */ |
32 | public function __construct( array $config = [] ) { |
33 | parent::__construct( |
34 | array_merge( [ 'maxLength' => 255 ], $config ) |
35 | ); |
36 | |
37 | // Properties, which are ignored in PHP and just shipped back to JS |
38 | if ( isset( $config['namespace'] ) ) { |
39 | $this->namespace = $config['namespace']; |
40 | } |
41 | if ( isset( $config['relative'] ) ) { |
42 | $this->relative = $config['relative']; |
43 | } |
44 | if ( isset( $config['suggestions'] ) ) { |
45 | $this->suggestions = $config['suggestions']; |
46 | } |
47 | if ( isset( $config['highlightFirst'] ) ) { |
48 | $this->highlightFirst = $config['highlightFirst']; |
49 | } |
50 | if ( isset( $config['validateTitle'] ) ) { |
51 | $this->validateTitle = $config['validateTitle']; |
52 | } |
53 | |
54 | // Initialization |
55 | $this->addClasses( [ 'mw-widget-titleInputWidget' ] ); |
56 | } |
57 | |
58 | protected function getJavaScriptClassName() { |
59 | return 'mw.widgets.TitleInputWidget'; |
60 | } |
61 | |
62 | public function getConfig( &$config ) { |
63 | if ( $this->namespace !== null ) { |
64 | $config['namespace'] = $this->namespace; |
65 | } |
66 | if ( $this->relative !== null ) { |
67 | $config['relative'] = $this->relative; |
68 | } |
69 | if ( $this->suggestions !== null ) { |
70 | $config['suggestions'] = $this->suggestions; |
71 | } |
72 | if ( $this->highlightFirst !== null ) { |
73 | $config['highlightFirst'] = $this->highlightFirst; |
74 | } |
75 | if ( $this->validateTitle !== null ) { |
76 | $config['validateTitle'] = $this->validateTitle; |
77 | } |
78 | $config['$overlay'] = true; |
79 | return parent::getConfig( $config ); |
80 | } |
81 | } |