From c1f9b1f7b1b77776192048005dcc66dcf3df2bfb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 27 Dec 2014 15:41:37 +0100 Subject: Update to MediaWiki 1.24.1 --- includes/htmlform/HTMLRadioField.php | 71 ++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 includes/htmlform/HTMLRadioField.php (limited to 'includes/htmlform/HTMLRadioField.php') diff --git a/includes/htmlform/HTMLRadioField.php b/includes/htmlform/HTMLRadioField.php new file mode 100644 index 00000000..8765407b --- /dev/null +++ b/includes/htmlform/HTMLRadioField.php @@ -0,0 +1,71 @@ +getOptions() ); + + if ( in_array( strval( $value ), $validOptions, true ) ) { + return true; + } else { + return $this->msg( 'htmlform-select-badoption' )->parse(); + } + } + + /** + * This returns a block of all the radio options, in one cell. + * @see includes/HTMLFormField#getInputHTML() + * + * @param string $value + * + * @return string + */ + function getInputHTML( $value ) { + $html = $this->formatOptions( $this->getOptions(), strval( $value ) ); + + return $html; + } + + function formatOptions( $options, $value ) { + $html = ''; + + $attribs = $this->getAttributes( array( 'disabled', 'tabindex' ) ); + $elementFunc = array( 'Html', $this->mOptionsLabelsNotFromMessage ? 'rawElement' : 'element' ); + + # @todo Should this produce an unordered list perhaps? + foreach ( $options as $label => $info ) { + if ( is_array( $info ) ) { + $html .= Html::rawElement( 'h1', array(), $label ) . "\n"; + $html .= $this->formatOptions( $info, $value ); + } else { + $id = Sanitizer::escapeId( $this->mID . "-$info" ); + $radio = Xml::radio( $this->mName, $info, $info === $value, $attribs + array( 'id' => $id ) ); + $radio .= ' ' . call_user_func( $elementFunc, 'label', array( 'for' => $id ), $label ); + + $html .= ' ' . Html::rawElement( + 'div', + array( 'class' => 'mw-htmlform-flatlist-item' ), + $radio + ); + } + } + + return $html; + } + + protected function needsLabel() { + return false; + } +} -- cgit v1.2.3-54-g00ecf