getOutput()->enableOOUI(); $this->getOutput()->addModuleStyles( 'mediawiki.htmlform.ooui.styles' ); } /** * Symbolic display format name. * @var string */ protected $displayFormat = 'ooui'; public static function loadInputFromParameters( $fieldname, $descriptor, HTMLForm $parent = null ) { $field = parent::loadInputFromParameters( $fieldname, $descriptor, $parent ); $field->setShowEmptyLabel( false ); return $field; } function getButtons() { $buttons = ''; if ( $this->mShowSubmit ) { $attribs = array( 'infusable' => true ); if ( isset( $this->mSubmitID ) ) { $attribs['id'] = $this->mSubmitID; } if ( isset( $this->mSubmitName ) ) { $attribs['name'] = $this->mSubmitName; } if ( isset( $this->mSubmitTooltip ) ) { $attribs += Linker::tooltipAndAccesskeyAttribs( $this->mSubmitTooltip ); } $attribs['classes'] = array( 'mw-htmlform-submit' ); $attribs['type'] = 'submit'; $attribs['label'] = $this->getSubmitText(); $attribs['value'] = $this->getSubmitText(); $attribs['flags'] = array( $this->mSubmitFlag ); $buttons .= new OOUI\ButtonInputWidget( $attribs ); } if ( $this->mShowReset ) { $buttons .= new OOUI\ButtonInputWidget( array( 'type' => 'reset', 'label' => $this->msg( 'htmlform-reset' )->text(), ) ); } foreach ( $this->mButtons as $button ) { $attrs = array(); if ( $button['attribs'] ) { $attrs += $button['attribs']; } if ( isset( $button['id'] ) ) { $attrs['id'] = $button['id']; } $attrs['classes'] = isset( $attrs['class'] ) ? (array)$attrs['class'] : array(); $buttons .= new OOUI\ButtonInputWidget( array( 'type' => 'submit', 'name' => $button['name'], 'value' => $button['value'], 'label' => $button['value'], ) + $attrs ); } $html = Html::rawElement( 'div', array( 'class' => 'mw-htmlform-submit-buttons' ), "\n$buttons" ) . "\n"; return $html; } 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 $fieldset; } function wrapForm( $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; } }