4 * HTML form generation and submission handling, vertical-form style.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
25 * Compact stacked vertical format for forms.
27 class VFormHTMLForm
extends HTMLForm
{
29 * Wrapper and its legend are never generated in VForm mode.
32 protected $mWrapperLegend = false;
35 * Symbolic display format name.
38 protected $displayFormat = 'vform';
40 public static function loadInputFromParameters( $fieldname, $descriptor,
41 HTMLForm
$parent = null
43 $field = parent
::loadInputFromParameters( $fieldname, $descriptor, $parent );
44 $field->setShowEmptyLabel( false );
48 public function getHTML( $submitResult ) {
49 // This is required for VForm HTMLForms that use that style regardless
50 // of wgUseMediaWikiUIEverywhere (since they pre-date it).
51 // When wgUseMediaWikiUIEverywhere is removed, this should be consolidated
52 // with the addModuleStyles in SpecialPage->setHeaders.
53 $this->getOutput()->addModuleStyles( [
55 'mediawiki.ui.button',
57 'mediawiki.ui.checkbox',
60 return parent
::getHTML( $submitResult );
63 protected function getFormAttributes() {
64 $attribs = parent
::getFormAttributes();
65 $attribs['class'] = [ 'mw-htmlform', 'mw-ui-vform', 'mw-ui-container' ];
69 public function wrapForm( $html ) {
70 // Always discard $this->mWrapperLegend
71 return Html
::rawElement( 'form', $this->getFormAttributes(), $html );
74 public function getButtons() {
77 if ( $this->mShowSubmit
) {
80 if ( isset( $this->mSubmitID
) ) {
81 $attribs['id'] = $this->mSubmitID
;
84 if ( isset( $this->mSubmitName
) ) {
85 $attribs['name'] = $this->mSubmitName
;
88 if ( isset( $this->mSubmitTooltip
) ) {
89 $attribs +
= Linker
::tooltipAndAccesskeyAttribs( $this->mSubmitTooltip
);
94 'mw-ui-button mw-ui-big mw-ui-block',
96 foreach ( $this->mSubmitFlags
as $flag ) {
97 $attribs['class'][] = 'mw-ui-' . $flag;
100 $buttons .= Xml
::submitButton( $this->getSubmitText(), $attribs ) . "\n";
103 if ( $this->mShowReset
) {
104 $buttons .= Html
::element(
108 'value' => $this->msg( 'htmlform-reset' )->text(),
109 'class' => 'mw-ui-button mw-ui-big mw-ui-block',
114 if ( $this->mShowCancel
) {
115 $target = $this->mCancelTarget ?
: Title
::newMainPage();
116 if ( $target instanceof Title
) {
117 $target = $target->getLocalURL();
119 $buttons .= Html
::element(
122 'class' => 'mw-ui-button mw-ui-big mw-ui-block',
125 $this->msg( 'cancel' )->text()
129 foreach ( $this->mButtons
as $button ) {
132 'name' => $button['name'],
133 'value' => $button['value']
136 if ( $button['attribs'] ) {
137 $attrs +
= $button['attribs'];
140 if ( isset( $button['id'] ) ) {
141 $attrs['id'] = $button['id'];
144 $attrs['class'] = isset( $attrs['class'] ) ?
(array)$attrs['class'] : [];
145 $attrs['class'][] = 'mw-ui-button mw-ui-big mw-ui-block';
147 $buttons .= Html
::element( 'input', $attrs ) . "\n";
154 return Html
::rawElement( 'div',
155 [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n";