X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fhtmlform%2FOOUIHTMLForm.php;h=eec13eeb9bfac580e5a6522d41fd2d15a504b6d4;hb=31dbc1ee2b0c32757dfaabc206e923662d233d2c;hp=60e636600469219b35c59051f72a650a72adbfc1;hpb=3c811415a1a543e5be3ad8896c8cdbc6efe529f2;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/htmlform/OOUIHTMLForm.php b/includes/htmlform/OOUIHTMLForm.php index 60e6366004..eec13eeb9b 100644 --- a/includes/htmlform/OOUIHTMLForm.php +++ b/includes/htmlform/OOUIHTMLForm.php @@ -25,17 +25,10 @@ * Compact stacked vertical format for forms, implemented using OOUI widgets. */ class OOUIHTMLForm extends HTMLForm { - /** - * Wrapper and its legend are never generated in OOUI mode. - * @var boolean - */ - protected $mWrapperLegend = false; - public function __construct( $descriptor, $context = null, $messagePrefix = '' ) { + parent::__construct( $descriptor, $context, $messagePrefix ); $this->getOutput()->enableOOUI(); - $this->getOutput()->addModules( 'mediawiki.htmlform.ooui' ); $this->getOutput()->addModuleStyles( 'mediawiki.htmlform.ooui.styles' ); - parent::__construct( $descriptor, $context, $messagePrefix ); } /** @@ -54,7 +47,7 @@ class OOUIHTMLForm extends HTMLForm { $buttons = ''; if ( $this->mShowSubmit ) { - $attribs = array(); + $attribs = array( 'infusable' => true ); if ( isset( $this->mSubmitID ) ) { $attribs['id'] = $this->mSubmitID; @@ -68,15 +61,11 @@ class OOUIHTMLForm extends HTMLForm { $attribs += Linker::tooltipAndAccesskeyAttribs( $this->mSubmitTooltip ); } - $attribs['classes'] = array( - 'mw-htmlform-submit', - $this->mSubmitModifierClass, - ); - + $attribs['classes'] = array( 'mw-htmlform-submit' ); $attribs['type'] = 'submit'; $attribs['label'] = $this->getSubmitText(); $attribs['value'] = $this->getSubmitText(); - $attribs['flags'] = array( 'primary', 'constructive' ); + $attribs['flags'] = $this->mSubmitFlags; $buttons .= new OOUI\ButtonInputWidget( $attribs ); } @@ -115,23 +104,30 @@ class OOUIHTMLForm extends HTMLForm { return $html; } - function getFormAttributes() { - $attribs = parent::getFormAttributes(); - if ( !isset( $attribs['class'] ) ) { - $attribs['class'] = ''; - } - - if ( is_string( $attribs['class'] ) ) { - $attribs['class'] = trim( $attribs['class'] . ' mw-htmlform-ooui' ); - } else { - $attribs['class'][] = 'mw-htmlform-ooui'; + function getBody() { + $fieldset = parent::getBody(); + // FIXME This only works for forms with no subsections + if ( $fieldset instanceof OOUI\FieldsetLayout ) { + $fieldset->group->prependContent( new OOUI\HtmlSnippet( $this->mHeader ) ); } - - return $attribs; + return $fieldset; } function wrapForm( $html ) { - // Always discard $this->mWrapperLegend - return Html::rawElement( 'form', $this->getFormAttributes(), $html ); + $form = new OOUI\FormLayout( $this->getFormAttributes() + array( + 'classes' => array( 'mw-htmlform-ooui' ), + 'content' => new OOUI\HtmlSnippet( $html ), + ) ); + + // Include a wrapper for style, if requested. + $form = new OOUI\PanelLayout( array( + 'classes' => array( 'mw-htmlform-ooui-wrapper' ), + 'expanded' => false, + 'padded' => $this->mWrapperLegend !== false, + 'framed' => $this->mWrapperLegend !== false, + 'content' => $form, + ) ); + + return $form; } }