X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=includes%2FHTMLForm.php;h=d260862c0c01dc371004e5b63e003c423913bbee;hb=6d4f5d142f28ade566dd6cd97af129c582e6f27b;hp=5de34d6712a91e1ef3e6cf7b137f23fd2740c130;hpb=aa6f866bd196e666b9c6e295733276d6a018dbba;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php
index 5de34d6712..d260862c0c 100644
--- a/includes/HTMLForm.php
+++ b/includes/HTMLForm.php
@@ -94,7 +94,7 @@
class HTMLForm extends ContextSource {
// A mapping of 'type' inputs onto standard HTMLFormField subclasses
- private static $typeMappings = array(
+ public static $typeMappings = array(
'api' => 'HTMLApiField',
'text' => 'HTMLTextField',
'textarea' => 'HTMLTextAreaField',
@@ -187,6 +187,7 @@ class HTMLForm extends ContextSource {
'table',
'div',
'raw',
+ 'vform',
);
/**
@@ -223,8 +224,15 @@ class HTMLForm extends ContextSource {
}
$field = self::loadInputFromParameters( $fieldname, $info );
+ // FIXME During field's construct, the parent form isn't available!
+ // could add a 'parent' name-value to $info, could add a third parameter.
$field->mParent = $this;
+ // vform gets too much space if empty labels generate HTML.
+ if ( $this->isVForm() ) {
+ $field->setShowEmptyLabel( false );
+ }
+
$setSection =& $loadedDescriptor;
if ( $section ) {
$sectionParts = explode( '/', $section );
@@ -272,6 +280,15 @@ class HTMLForm extends ContextSource {
return $this->displayFormat;
}
+ /**
+ * Test if displayFormat is 'vform'
+ * @since 1.22
+ * @return Bool
+ */
+ public function isVForm() {
+ return $this->displayFormat === 'vform';
+ }
+
/**
* Add the HTMLForm-specific JavaScript, if it hasn't been
* done already.
@@ -626,6 +643,11 @@ class HTMLForm extends ContextSource {
# For good measure (it is the default)
$this->getOutput()->preventClickjacking();
$this->getOutput()->addModules( 'mediawiki.htmlform' );
+ if ( $this->isVForm() ) {
+ $this->getOutput()->addModuleStyles( 'mediawiki.ui' );
+ // TODO should vertical form set setWrapperLegend( false )
+ // to hide ugly fieldsets?
+ }
$html = ''
. $this->getErrors( $submitResult )
@@ -660,13 +682,16 @@ class HTMLForm extends ContextSource {
$attribs = array(
'action' => $this->getAction(),
'method' => $this->getMethod(),
- 'class' => 'visualClear',
+ 'class' => array( 'visualClear' ),
'enctype' => $encType,
);
if ( !empty( $this->mId ) ) {
$attribs['id'] = $this->mId;
}
+ if ( $this->isVForm() ) {
+ array_push( $attribs['class'], 'mw-ui-vform', 'mw-ui-container' );
+ }
return Html::rawElement( 'form', $attribs, $html );
}
@@ -717,9 +742,22 @@ class HTMLForm extends ContextSource {
$attribs += Linker::tooltipAndAccesskeyAttribs( $this->mSubmitTooltip );
}
- $attribs['class'] = 'mw-htmlform-submit';
+ $attribs['class'] = array( 'mw-htmlform-submit' );
+
+ if ( $this->isVForm() ) {
+ // mw-ui-block is necessary because the buttons aren't necessarily in an
+ // immediate child div of the vform.
+ array_push( $attribs['class'], 'mw-ui-button', 'mw-ui-big', 'mw-ui-primary', 'mw-ui-block' );
+ }
$html .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n";
+
+ // Buttons are top-level form elements in table and div layouts,
+ // but vform wants all elements inside divs to get spaced-out block
+ // styling.
+ if ( $this->isVForm() ) {
+ $html = Html::rawElement( 'div', null, "\n$html\n" );
+ }
}
if ( $this->mShowReset ) {
@@ -913,7 +951,8 @@ class HTMLForm extends ContextSource {
/**
* Prompt the whole form to be wrapped in a "