X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fhtmlform%2FHTMLForm.php;h=c810f68d0030b6c5ed64021526440672237d6241;hb=dd107dda969ac77b86a89b0e98fcf85352c6035d;hp=33346948e288f1dfdaf3010d69d7f9a4cd9fc374;hpb=d7dd7fbf986638510ecfa3d5f1f4c13a6642465f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 33346948e2..c810f68d00 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -50,6 +50,7 @@ * 'default' -- default value when the form is displayed * 'id' -- HTML id attribute * 'cssclass' -- CSS class + * 'csshelpclass' -- CSS class used to style help text * 'options' -- associative array mapping labels to values. * Some field types support multi-level arrays. * 'options-messages' -- associative array mapping message keys to values. @@ -106,6 +107,7 @@ class HTMLForm extends ContextSource { 'select' => 'HTMLSelectField', 'radio' => 'HTMLRadioField', 'multiselect' => 'HTMLMultiSelectField', + 'limitselect' => 'HTMLSelectLimitField', 'check' => 'HTMLCheckField', 'toggle' => 'HTMLCheckField', 'int' => 'HTMLIntField', @@ -118,6 +120,7 @@ class HTMLForm extends ContextSource { 'edittools' => 'HTMLEditTools', 'checkmatrix' => 'HTMLCheckMatrix', 'cloner' => 'HTMLFormFieldCloner', + 'autocompleteselect' => 'HTMLAutoCompleteSelectField', // HTMLTextField will output the correct type="" attribute automagically. // There are about four zillion other HTML5 input types, like range, but // we don't use those at the moment, so no point in adding all of them. @@ -298,7 +301,11 @@ class HTMLForm extends ContextSource { * @return string */ public function getDisplayFormat() { - return $this->displayFormat; + $format = $this->displayFormat; + if ( !$this->getConfig()->get( 'HTMLFormAllowTableFormat' ) && $format === 'table' ) { + $format = 'div'; + } + return $format; } /** @@ -351,7 +358,7 @@ class HTMLForm extends ContextSource { * @param array $descriptor Input Descriptor, as described above * * @throws MWException - * @return HTMLFormField subclass + * @return HTMLFormField Instance of a subclass of HTMLFormField */ public static function loadInputFromParameters( $fieldname, $descriptor ) { $class = self::getClassFromDescriptor( $fieldname, $descriptor ); @@ -621,7 +628,7 @@ class HTMLForm extends ContextSource { /** * Add footer text, inside the form. * - * @param string $msg complete text of message to display + * @param string $msg Complete text of message to display * @param string|null $section The section to add the footer text to * * @return HTMLForm $this for chaining calls (since 1.20) @@ -740,8 +747,8 @@ class HTMLForm extends ContextSource { * Only useful when the method is "post". * * @since 1.24 - * @param string|array Salt to use - * @return HTMLForm $this for chaining calls + * @param string|array $salt Salt to use + * @return HTMLForm $this For chaining calls */ public function setTokenSalt( $salt ) { $this->mTokenSalt = $salt; @@ -759,7 +766,7 @@ class HTMLForm extends ContextSource { * * @param bool|string|array|Status $submitResult Output from HTMLForm::trySubmit() * - * @return Nothing, should be last call + * @return void Nothing, should be last call */ function displayForm( $submitResult ) { $this->getOutput()->addHTML( $this->getHTML( $submitResult ) ); @@ -838,8 +845,6 @@ class HTMLForm extends ContextSource { * @return string HTML. */ function getHiddenFields() { - global $wgArticlePath; - $html = ''; if ( $this->getMethod() == 'post' ) { $html .= Html::hidden( @@ -850,7 +855,8 @@ class HTMLForm extends ContextSource { $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n"; } - if ( strpos( $wgArticlePath, '?' ) !== false && $this->getMethod() == 'get' ) { + $articlePath = $this->getConfig()->get( 'ArticlePath' ); + if ( strpos( $articlePath, '?' ) !== false && $this->getMethod() == 'get' ) { $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n"; } @@ -868,6 +874,7 @@ class HTMLForm extends ContextSource { */ function getButtons() { $buttons = ''; + $useMediaWikiUIEverywhere = $this->getConfig()->get( 'UseMediaWikiUIEverywhere' ); if ( $this->mShowSubmit ) { $attribs = array(); @@ -886,15 +893,17 @@ class HTMLForm extends ContextSource { $attribs['class'] = array( 'mw-htmlform-submit' ); + if ( $this->isVForm() || $useMediaWikiUIEverywhere ) { + array_push( $attribs['class'], 'mw-ui-button', 'mw-ui-constructive' ); + } + if ( $this->isVForm() ) { // mw-ui-block is necessary because the buttons aren't necessarily in an // immediate child div of the vform. // @todo Let client specify if the primary submit button is progressive or destructive array_push( $attribs['class'], - 'mw-ui-button', 'mw-ui-big', - 'mw-ui-constructive', 'mw-ui-block' ); } @@ -927,6 +936,17 @@ class HTMLForm extends ContextSource { $attrs['id'] = $button['id']; } + if ( $this->isVForm() || $useMediaWikiUIEverywhere ) { + if ( isset( $attrs['class'] ) ) { + $attrs['class'] .= ' mw-ui-button'; + } else { + $attrs['class'] = 'mw-ui-button'; + } + if ( $this->isVForm() ) { + $attrs['class'] .= ' mw-ui-big mw-ui-block'; + } + } + $buttons .= Html::element( 'input', $attrs ) . "\n"; } @@ -979,7 +999,7 @@ class HTMLForm extends ContextSource { /** * Format a stack of error messages into a single HTML string * - * @param array $errors of message keys/values + * @param array $errors Array of message keys/values * * @return string HTML, a "