Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 28 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
HTMLSelectNamespace | |
0.00% |
0 / 27 |
|
0.00% |
0 / 5 |
56 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
12 | |||
getInputHTML | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
2 | |||
getInputOOUI | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
getOOUIModules | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
shouldInfuseOOUI | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\HTMLForm\Field; |
4 | |
5 | use MediaWiki\Html\Html; |
6 | use MediaWiki\HTMLForm\HTMLFormField; |
7 | |
8 | /** |
9 | * Wrapper for Html::namespaceSelector to use in HTMLForm |
10 | * |
11 | * @stable to extend |
12 | */ |
13 | class HTMLSelectNamespace extends HTMLFormField { |
14 | |
15 | /** @var string|null */ |
16 | protected $mAllValue; |
17 | /** @var bool */ |
18 | protected $mUserLang; |
19 | |
20 | /** |
21 | * @stable to call |
22 | * @inheritDoc |
23 | */ |
24 | public function __construct( $params ) { |
25 | parent::__construct( $params ); |
26 | |
27 | $this->mAllValue = array_key_exists( 'all', $params ) |
28 | ? $params['all'] |
29 | : 'all'; |
30 | $this->mUserLang = array_key_exists( 'in-user-lang', $params ) |
31 | ? $params['in-user-lang'] |
32 | : false; |
33 | } |
34 | |
35 | /** |
36 | * @inheritDoc |
37 | * @stable to override |
38 | */ |
39 | public function getInputHTML( $value ) { |
40 | return Html::namespaceSelector( |
41 | [ |
42 | 'selected' => $value, |
43 | 'all' => $this->mAllValue, |
44 | 'in-user-lang' => $this->mUserLang, |
45 | ], [ |
46 | 'name' => $this->mName, |
47 | 'id' => $this->mID, |
48 | 'class' => 'namespaceselector', |
49 | ] |
50 | ); |
51 | } |
52 | |
53 | /** |
54 | * @inheritDoc |
55 | * @stable to override |
56 | */ |
57 | public function getInputOOUI( $value ) { |
58 | return new \MediaWiki\Widget\NamespaceInputWidget( [ |
59 | 'value' => $value, |
60 | 'name' => $this->mName, |
61 | 'id' => $this->mID, |
62 | 'includeAllValue' => $this->mAllValue, |
63 | 'userLang' => $this->mUserLang, |
64 | ] ); |
65 | } |
66 | |
67 | /** |
68 | * @inheritDoc |
69 | * @stable to override |
70 | */ |
71 | protected function getOOUIModules() { |
72 | // FIXME: NamespaceInputWidget should be in its own module (probably?) |
73 | return [ 'mediawiki.widgets' ]; |
74 | } |
75 | |
76 | /** |
77 | * @inheritDoc |
78 | * @stable to override |
79 | */ |
80 | protected function shouldInfuseOOUI() { |
81 | return true; |
82 | } |
83 | } |
84 | |
85 | /** @deprecated class alias since 1.42 */ |
86 | class_alias( HTMLSelectNamespace::class, 'HTMLSelectNamespace' ); |