MediaWiki
master
ComplexNamespaceInputWidget.php
Go to the documentation of this file.
1
<?php
2
3
namespace
MediaWiki\Widget
;
4
5
use OOUI\CheckboxInputWidget;
6
use OOUI\Exception;
7
use OOUI\FieldLayout;
8
use OOUI\Widget;
9
17
class
ComplexNamespaceInputWidget
extends
Widget {
18
19
protected
$config
;
20
protected
$namespace
;
21
protected
$associated
=
null
;
22
protected
$associatedLabel
=
null
;
23
protected
$invert
=
null
;
24
protected
$invertLabel
=
null
;
25
45
public
function
__construct
( array
$config
= [] ) {
46
// Configuration initialization
47
$config
= array_merge(
48
[
49
// Config options for nested widgets
50
'namespace'
=> [],
51
'invert'
=> [],
52
'invertLabel'
=> [],
53
'associated'
=> [],
54
'associatedLabel'
=> [],
55
],
56
$config
57
);
58
59
parent::__construct(
$config
);
60
61
// Properties
62
$this->config =
$config
;
63
64
$this->
namespace
= new
NamespaceInputWidget
(
$config
['namespace'] );
65
if
(
$config
[
'associated'
] !==
null
) {
66
$this->associated =
new
CheckboxInputWidget( array_merge(
67
[
'value'
=>
'1'
],
68
$config
[
'associated'
]
69
) );
70
// TODO Should use a LabelWidget? But they don't work like HTML <label>s yet
71
$this->associatedLabel =
new
FieldLayout(
72
$this->associated,
73
array_merge(
74
[
'align'
=>
'inline'
],
75
$config
[
'associatedLabel'
]
76
)
77
);
78
}
79
if
(
$config
[
'invert'
] !==
null
) {
80
$this->invert =
new
CheckboxInputWidget( array_merge(
81
[
'value'
=>
'1'
],
82
$config
[
'invert'
]
83
) );
84
// TODO Should use a LabelWidget? But they don't work like HTML <label>s yet
85
$this->invertLabel =
new
FieldLayout(
86
$this->invert,
87
array_merge(
88
[
'align'
=>
'inline'
],
89
$config
[
'invertLabel'
]
90
)
91
);
92
}
93
94
// Initialization
95
$this
96
->addClasses( [
'mw-widget-complexNamespaceInputWidget'
] )
97
->appendContent( $this->
namespace
, $this->associatedLabel, $this->invertLabel );
98
}
99
100
protected
function
getJavaScriptClassName
() {
101
return
'mw.widgets.ComplexNamespaceInputWidget'
;
102
}
103
104
public
function
getConfig
( &
$config
) {
105
$config
= array_merge(
106
$config
,
107
array_intersect_key(
108
$this->config,
109
array_fill_keys(
110
[
111
'namespace'
,
112
'invert'
,
113
'invertLabel'
,
114
'associated'
,
115
'associatedLabel'
116
],
117
true
118
)
119
)
120
);
121
$config
[
'namespace'
][
'dropdown'
][
'$overlay'
] =
true
;
122
return
parent::getConfig(
$config
);
123
}
124
}
MediaWiki\Widget\ComplexNamespaceInputWidget
Namespace input widget.
Definition
ComplexNamespaceInputWidget.php:17
MediaWiki\Widget\ComplexNamespaceInputWidget\$namespace
$namespace
Definition
ComplexNamespaceInputWidget.php:20
MediaWiki\Widget\ComplexNamespaceInputWidget\getJavaScriptClassName
getJavaScriptClassName()
Definition
ComplexNamespaceInputWidget.php:100
MediaWiki\Widget\ComplexNamespaceInputWidget\$invert
$invert
Definition
ComplexNamespaceInputWidget.php:23
MediaWiki\Widget\ComplexNamespaceInputWidget\$invertLabel
$invertLabel
Definition
ComplexNamespaceInputWidget.php:24
MediaWiki\Widget\ComplexNamespaceInputWidget\$associated
$associated
Definition
ComplexNamespaceInputWidget.php:21
MediaWiki\Widget\ComplexNamespaceInputWidget\__construct
__construct(array $config=[])
Definition
ComplexNamespaceInputWidget.php:45
MediaWiki\Widget\ComplexNamespaceInputWidget\$config
$config
Definition
ComplexNamespaceInputWidget.php:19
MediaWiki\Widget\ComplexNamespaceInputWidget\getConfig
getConfig(&$config)
Definition
ComplexNamespaceInputWidget.php:104
MediaWiki\Widget\ComplexNamespaceInputWidget\$associatedLabel
$associatedLabel
Definition
ComplexNamespaceInputWidget.php:22
MediaWiki\Widget\NamespaceInputWidget
Namespace input widget.
Definition
NamespaceInputWidget.php:15
MediaWiki\Widget
Definition
CheckMatrixWidget.php:3
includes
widget
ComplexNamespaceInputWidget.php
Generated on Thu Apr 25 2024 07:35:59 for MediaWiki by
1.10.0