X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/includes/htmlform/fields/HTMLFormFieldWithButton.php diff --git a/includes/htmlform/fields/HTMLFormFieldWithButton.php b/includes/htmlform/fields/HTMLFormFieldWithButton.php new file mode 100644 index 00000000..b2290ce3 --- /dev/null +++ b/includes/htmlform/fields/HTMLFormFieldWithButton.php @@ -0,0 +1,75 @@ +mButtonClass = $info['buttonclass']; + } + if ( isset( $info['buttonid'] ) ) { + $this->mButtonId = $info['buttonid']; + } + if ( isset( $info['buttonname'] ) ) { + $this->mButtonName = $info['buttonname']; + } + if ( isset( $info['buttondefault'] ) ) { + $this->mButtonValue = $info['buttondefault']; + } + if ( isset( $info['buttontype'] ) ) { + $this->mButtonType = $info['buttontype']; + } + if ( isset( $info['buttonflags'] ) ) { + $this->mButtonFlags = $info['buttonflags']; + } + parent::__construct( $info ); + } + + public function getInputHTML( $value ) { + $attr = [ + 'class' => 'mw-htmlform-submit ' . $this->mButtonClass, + 'id' => $this->mButtonId, + ] + $this->getAttributes( [ 'disabled', 'tabindex' ] ); + + return Html::input( $this->mButtonName, $this->mButtonValue, $this->mButtonType, $attr ); + } + + public function getInputOOUI( $value ) { + return new OOUI\ButtonInputWidget( [ + 'name' => $this->mButtonName, + 'value' => $this->mButtonValue, + 'type' => $this->mButtonType, + 'label' => $this->mButtonValue, + 'flags' => $this->mButtonFlags, + ] + OOUI\Element::configFromHtmlAttributes( + $this->getAttributes( [ 'disabled', 'tabindex' ] ) + ) ); + } + + /** + * Combines the passed element with a button. + * @param String $element Element to combine the button with. + * @return String + */ + public function getElement( $element ) { + return $element . ' ' . $this->getInputHTML( '' ); + } +}