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 | /** @var int|null */ |
16 | protected $namespace = null; |
17 | /** @var bool|null */ |
18 | protected $relative = null; |
19 | /** @var bool|null */ |
20 | protected $suggestions = null; |
21 | /** @var bool|null */ |
22 | protected $highlightFirst = null; |
23 | /** @var bool|null */ |
24 | protected $validateTitle = null; |
25 | |
26 | /** |
27 | * @param array $config Configuration options |
28 | * - int|null $config['namespace'] Namespace to prepend to queries |
29 | * - bool|null $config['relative'] If a namespace is set, |
30 | * return a title relative to it (default: true) |
31 | * - bool|null $config['suggestions'] Display search suggestions (default: true) |
32 | * - bool|null $config['highlightFirst'] Automatically highlight |
33 | * the first result (default: true) |
34 | * - bool|null $config['validateTitle'] Whether the input must |
35 | * be a valid title (default: true) |
36 | */ |
37 | public function __construct( array $config = [] ) { |
38 | parent::__construct( |
39 | array_merge( [ 'maxLength' => 255 ], $config ) |
40 | ); |
41 | |
42 | // Properties, which are ignored in PHP and just shipped back to JS |
43 | if ( isset( $config['namespace'] ) ) { |
44 | $this->namespace = $config['namespace']; |
45 | } |
46 | if ( isset( $config['relative'] ) ) { |
47 | $this->relative = $config['relative']; |
48 | } |
49 | if ( isset( $config['suggestions'] ) ) { |
50 | $this->suggestions = $config['suggestions']; |
51 | } |
52 | if ( isset( $config['highlightFirst'] ) ) { |
53 | $this->highlightFirst = $config['highlightFirst']; |
54 | } |
55 | if ( isset( $config['validateTitle'] ) ) { |
56 | $this->validateTitle = $config['validateTitle']; |
57 | } |
58 | |
59 | // Initialization |
60 | $this->addClasses( [ 'mw-widget-titleInputWidget' ] ); |
61 | } |
62 | |
63 | protected function getJavaScriptClassName() { |
64 | return 'mw.widgets.TitleInputWidget'; |
65 | } |
66 | |
67 | public function getConfig( &$config ) { |
68 | if ( $this->namespace !== null ) { |
69 | $config['namespace'] = $this->namespace; |
70 | } |
71 | if ( $this->relative !== null ) { |
72 | $config['relative'] = $this->relative; |
73 | } |
74 | if ( $this->suggestions !== null ) { |
75 | $config['suggestions'] = $this->suggestions; |
76 | } |
77 | if ( $this->highlightFirst !== null ) { |
78 | $config['highlightFirst'] = $this->highlightFirst; |
79 | } |
80 | if ( $this->validateTitle !== null ) { |
81 | $config['validateTitle'] = $this->validateTitle; |
82 | } |
83 | $config['$overlay'] = true; |
84 | return parent::getConfig( $config ); |
85 | } |
86 | } |