Fix hook situation for Skin::doEditSectionLink
[mediawiki.git] / includes / htmlform / VFormHTMLForm.php
blob7826a0c79d40201731824af8deb23c42933c9df9
1 <?php
3 /**
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
21 * @file
24 /**
25 * Compact stacked vertical format for forms.
27 class VFormHTMLForm extends HTMLForm {
28 /**
29 * Wrapper and its legend are never generated in VForm mode.
30 * @var boolean
32 protected $mWrapperLegend = false;
34 /**
35 * Symbolic display format name.
36 * @var string
38 protected $displayFormat = 'vform';
40 public function isVForm() {
41 return true;
44 public static function loadInputFromParameters( $fieldname, $descriptor, HTMLForm $parent = null ) {
45 $field = parent::loadInputFromParameters( $fieldname, $descriptor, $parent );
46 $field->setShowEmptyLabel( false );
47 return $field;
50 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( array(
56 'mediawiki.ui',
57 'mediawiki.ui.button',
58 'mediawiki.ui.input',
59 'mediawiki.ui.checkbox',
60 ) );
62 return parent::getHTML( $submitResult );
65 protected function getFormAttributes() {
66 $attribs = parent::getFormAttributes();
67 array_push( $attribs['class'], 'mw-ui-vform', 'mw-ui-container' );
68 return $attribs;
71 function wrapForm( $html ) {
72 // Always discard $this->mWrapperLegend
73 return Html::rawElement( 'form', $this->getFormAttributes(), $html );
76 function getButtons() {
77 $buttons = '';
79 if ( $this->mShowSubmit ) {
80 $attribs = array();
82 if ( isset( $this->mSubmitID ) ) {
83 $attribs['id'] = $this->mSubmitID;
86 if ( isset( $this->mSubmitName ) ) {
87 $attribs['name'] = $this->mSubmitName;
90 if ( isset( $this->mSubmitTooltip ) ) {
91 $attribs += Linker::tooltipAndAccesskeyAttribs( $this->mSubmitTooltip );
94 $attribs['class'] = array(
95 'mw-htmlform-submit',
96 'mw-ui-button mw-ui-big mw-ui-block',
97 $this->mSubmitModifierClass,
100 $buttons .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n";
103 if ( $this->mShowReset ) {
104 $buttons .= Html::element(
105 'input',
106 array(
107 'type' => 'reset',
108 'value' => $this->msg( 'htmlform-reset' )->text(),
109 'class' => 'mw-ui-button mw-ui-big mw-ui-block',
111 ) . "\n";
114 foreach ( $this->mButtons as $button ) {
115 $attrs = array(
116 'type' => 'submit',
117 'name' => $button['name'],
118 'value' => $button['value']
121 if ( $button['attribs'] ) {
122 $attrs += $button['attribs'];
125 if ( isset( $button['id'] ) ) {
126 $attrs['id'] = $button['id'];
129 $attrs['class'] = isset( $attrs['class'] ) ? (array)$attrs['class'] : array();
130 $attrs['class'][] = 'mw-ui-button mw-ui-big mw-ui-block';
132 $buttons .= Html::element( 'input', $attrs ) . "\n";
135 $html = Html::rawElement( 'div',
136 array( 'class' => 'mw-htmlform-submit-buttons' ), "\n$buttons" ) . "\n";
138 return $html;