MediaWiki
REL1_35
VFormHTMLForm.php
Go to the documentation of this file.
1
<?php
2
29
class
VFormHTMLForm
extends
HTMLForm
{
34
protected
$mWrapperLegend
=
false
;
35
40
protected
$displayFormat
=
'vform'
;
41
42
public
static
function
loadInputFromParameters
( $fieldname, $descriptor,
43
HTMLForm
$parent =
null
44
) {
45
$field = parent::loadInputFromParameters( $fieldname, $descriptor, $parent );
46
$field->setShowEmptyLabel(
false
);
47
return
$field;
48
}
49
50
public
function
getHTML
( $submitResult ) {
51
// This is required for VForm HTMLForms that use that style regardless
52
// of wgUseMediaWikiUIEverywhere (since they pre-date it).
53
// When wgUseMediaWikiUIEverywhere is removed, this should be consolidated
54
// with the addModuleStyles in SpecialPage->setHeaders.
55
$this->
getOutput
()->addModuleStyles( [
56
'mediawiki.ui'
,
57
'mediawiki.ui.button'
,
58
'mediawiki.ui.input'
,
59
'mediawiki.ui.checkbox'
,
60
] );
61
62
return
parent::getHTML( $submitResult );
63
}
64
65
protected
function
getFormAttributes
() {
66
$attribs = parent::getFormAttributes();
67
$attribs[
'class'
] = [
'mw-htmlform'
,
'mw-ui-vform'
,
'mw-ui-container'
];
68
return
$attribs;
69
}
70
71
public
function
wrapForm
( $html ) {
72
// Always discard $this->mWrapperLegend
73
return
Html::rawElement(
'form'
, $this->
getFormAttributes
(), $html );
74
}
75
76
public
function
getButtons
() {
77
$buttons =
''
;
78
79
if
( $this->mShowSubmit ) {
80
$attribs = [];
81
82
if
( isset( $this->mSubmitID ) ) {
83
$attribs[
'id'
] =
$this->mSubmitID
;
84
}
85
86
if
( isset( $this->mSubmitName ) ) {
87
$attribs[
'name'
] =
$this->mSubmitName
;
88
}
89
90
if
( isset( $this->mSubmitTooltip ) ) {
91
$attribs +=
Linker::tooltipAndAccesskeyAttribs
( $this->mSubmitTooltip );
92
}
93
94
$attribs[
'class'
] = [
95
'mw-htmlform-submit'
,
96
'mw-ui-button mw-ui-big mw-ui-block'
,
97
];
98
foreach
( $this->mSubmitFlags as $flag ) {
99
$attribs[
'class'
][] =
'mw-ui-'
. $flag;
100
}
101
102
$buttons .= Xml::submitButton( $this->
getSubmitText
(), $attribs ) .
"\n"
;
103
}
104
105
if
( $this->mShowReset ) {
106
$buttons .= Html::element(
107
'input'
,
108
[
109
'type'
=>
'reset'
,
110
'value'
=> $this->
msg
(
'htmlform-reset'
)->text(),
111
'class'
=>
'mw-ui-button mw-ui-big mw-ui-block'
,
112
]
113
) .
"\n"
;
114
}
115
116
if
( $this->mShowCancel ) {
117
$target = $this->mCancelTarget ?: Title::newMainPage();
118
if
( $target instanceof
Title
) {
119
$target = $target->getLocalURL();
120
}
121
$buttons .= Html::element(
122
'a'
,
123
[
124
'class'
=>
'mw-ui-button mw-ui-big mw-ui-block'
,
125
'href'
=> $target,
126
],
127
$this->
msg
(
'cancel'
)->text()
128
) .
"\n"
;
129
}
130
131
foreach
( $this->mButtons as $button ) {
132
$attrs = [
133
'type'
=>
'submit'
,
134
'name'
=> $button[
'name'
],
135
'value'
=> $button[
'value'
]
136
];
137
138
if
( $button[
'attribs'
] ) {
139
$attrs += $button[
'attribs'
];
140
}
141
142
if
( isset( $button[
'id'
] ) ) {
143
$attrs[
'id'
] = $button[
'id'
];
144
}
145
146
$attrs[
'class'
] = isset( $attrs[
'class'
] ) ? (array)$attrs[
'class'
] : [];
147
$attrs[
'class'
][] =
'mw-ui-button mw-ui-big mw-ui-block'
;
148
149
$buttons .= Html::element(
'input'
, $attrs ) .
"\n"
;
150
}
151
152
if
( !$buttons ) {
153
return
''
;
154
}
155
156
return
Html::rawElement(
'div'
,
157
[
'class'
=>
'mw-htmlform-submit-buttons'
],
"\n$buttons"
) .
"\n"
;
158
}
159
}
ContextSource\msg
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Definition
ContextSource.php:184
ContextSource\getOutput
getOutput()
Definition
ContextSource.php:121
HTMLForm
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition
HTMLForm.php:135
HTMLForm\getSubmitText
getSubmitText()
Get the text for the submit button, either customised or a default.
Definition
HTMLForm.php:1420
HTMLForm\$mSubmitID
$mSubmitID
Definition
HTMLForm.php:211
HTMLForm\$mSubmitName
$mSubmitName
Definition
HTMLForm.php:212
Linker\tooltipAndAccesskeyAttribs
static tooltipAndAccesskeyAttribs( $name, array $msgParams=[], $options=null)
Returns the attributes for the tooltip and access key.
Definition
Linker.php:2304
Title
Represents a title within MediaWiki.
Definition
Title.php:42
VFormHTMLForm
Compact stacked vertical format for forms.
Definition
VFormHTMLForm.php:29
VFormHTMLForm\getHTML
getHTML( $submitResult)
Returns the raw HTML generated by the form.
Definition
VFormHTMLForm.php:50
VFormHTMLForm\$displayFormat
string $displayFormat
Symbolic display format name.
Definition
VFormHTMLForm.php:40
VFormHTMLForm\getFormAttributes
getFormAttributes()
Get HTML attributes for the <form> tag.
Definition
VFormHTMLForm.php:65
VFormHTMLForm\getButtons
getButtons()
Get the submit and (potentially) reset buttons.
Definition
VFormHTMLForm.php:76
VFormHTMLForm\$mWrapperLegend
bool $mWrapperLegend
Wrapper and its legend are never generated in VForm mode.
Definition
VFormHTMLForm.php:34
VFormHTMLForm\loadInputFromParameters
static loadInputFromParameters( $fieldname, $descriptor, HTMLForm $parent=null)
Initialise a new Object for the field Stable to override.
Definition
VFormHTMLForm.php:42
VFormHTMLForm\wrapForm
wrapForm( $html)
Wrap the form innards in an actual "<form>" element Stable to override.
Definition
VFormHTMLForm.php:71
includes
htmlform
VFormHTMLForm.php
Generated on Sat Apr 6 2024 00:07:16 for MediaWiki by
1.9.8