2014-12-24 17:21:32 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* HTML form generation and submission handling, vertical-form style.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
|
|
|
|
|
2023-02-16 19:27:21 +00:00
|
|
|
use MediaWiki\Html\Html;
|
2022-12-05 11:29:37 +00:00
|
|
|
|
2014-12-24 17:21:32 +00:00
|
|
|
/**
|
|
|
|
|
* Compact stacked vertical format for forms.
|
2020-07-10 19:23:59 +00:00
|
|
|
*
|
|
|
|
|
* @stable to extend
|
2014-12-24 17:21:32 +00:00
|
|
|
*/
|
|
|
|
|
class VFormHTMLForm extends HTMLForm {
|
|
|
|
|
/**
|
|
|
|
|
* Wrapper and its legend are never generated in VForm mode.
|
2016-03-24 08:44:09 +00:00
|
|
|
* @var bool
|
2014-12-24 17:21:32 +00:00
|
|
|
*/
|
|
|
|
|
protected $mWrapperLegend = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Symbolic display format name.
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $displayFormat = 'vform';
|
|
|
|
|
|
2015-09-28 11:35:28 +00:00
|
|
|
public static function loadInputFromParameters( $fieldname, $descriptor,
|
|
|
|
|
HTMLForm $parent = null
|
|
|
|
|
) {
|
2014-12-24 17:21:32 +00:00
|
|
|
$field = parent::loadInputFromParameters( $fieldname, $descriptor, $parent );
|
|
|
|
|
$field->setShowEmptyLabel( false );
|
|
|
|
|
return $field;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-04 10:40:42 +00:00
|
|
|
public function getHTML( $submitResult ) {
|
2014-12-24 17:21:32 +00:00
|
|
|
// This is required for VForm HTMLForms that use that style regardless
|
|
|
|
|
// of wgUseMediaWikiUIEverywhere (since they pre-date it).
|
|
|
|
|
// When wgUseMediaWikiUIEverywhere is removed, this should be consolidated
|
|
|
|
|
// with the addModuleStyles in SpecialPage->setHeaders.
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->getOutput()->addModuleStyles( [
|
2014-12-24 17:21:32 +00:00
|
|
|
'mediawiki.ui',
|
|
|
|
|
'mediawiki.ui.button',
|
|
|
|
|
'mediawiki.ui.input',
|
|
|
|
|
'mediawiki.ui.checkbox',
|
2016-02-17 09:09:32 +00:00
|
|
|
] );
|
2014-12-24 17:21:32 +00:00
|
|
|
|
|
|
|
|
return parent::getHTML( $submitResult );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function getFormAttributes() {
|
|
|
|
|
$attribs = parent::getFormAttributes();
|
2016-12-02 19:19:07 +00:00
|
|
|
$attribs['class'] = [ 'mw-htmlform', 'mw-ui-vform', 'mw-ui-container' ];
|
2014-12-24 17:21:32 +00:00
|
|
|
return $attribs;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-04 10:40:42 +00:00
|
|
|
public function wrapForm( $html ) {
|
2014-12-24 17:21:32 +00:00
|
|
|
// Always discard $this->mWrapperLegend
|
|
|
|
|
return Html::rawElement( 'form', $this->getFormAttributes(), $html );
|
|
|
|
|
}
|
|
|
|
|
}
|