Bartosz Dziewoński has uploaded a new change for review. https://gerrit.wikimedia.org/r/227605
Change subject: HTMLForm: Move header formatting OOUI-specific code to OOUIHTMLForm ...................................................................... HTMLForm: Move header formatting OOUI-specific code to OOUIHTMLForm * Introduce a getter getHeaderText() and override it in OOUIHTMLForm. * While we're at it, also introduce getFooterText() (although right now we have no need to override this one). * Use both in HTMLForm where appropriate. Change-Id: I9a7234ed75b024f24e0a087c9c000bb2024b405f --- M includes/htmlform/HTMLForm.php M includes/htmlform/OOUIHTMLForm.php 2 files changed, 49 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/05/227605/1 diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 0678bdd..2be3144 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -713,6 +713,21 @@ } /** + * Get header text. + * + * @param string|null $section The section to get the header text for + * @since 1.26 + * @return string + */ + function getHeaderText( $section = null ) { + if ( is_null( $section ) ) { + return $this->mHeader; + } else { + return isset( $this->mSectionHeaders[$section] ) ? $this->mSectionHeaders[$section] : ''; + } + } + + /** * Add footer text, inside the form. * * @param string $msg Complete text of message to display @@ -750,6 +765,21 @@ } return $this; + } + + /** + * Get footer text. + * + * @param string|null $section The section to get the footer text for + * @since 1.26 + * @return string + */ + function getFooterText( $section = null ) { + if ( is_null( $section ) ) { + return $this->mFooter; + } else { + return isset( $this->mSectionFooters[$section] ) ? $this->mSectionFooters[$section] : ''; + } } /** @@ -873,12 +903,11 @@ $html = '' . $this->getErrors( $submitResult ) - // In OOUI forms, we handle mHeader elsewhere. FIXME This is horrible. - . ( $this->getDisplayFormat() === 'ooui' ? '' : $this->mHeader ) + . $this->getHeaderText() . $this->getBody() . $this->getHiddenFields() . $this->getButtons() - . $this->mFooter; + . $this->getFooterText(); $html = $this->wrapForm( $html ); @@ -1374,12 +1403,7 @@ $legend = $this->getLegend( $key ); - if ( isset( $this->mSectionHeaders[$key] ) ) { - $section = $this->mSectionHeaders[$key] . $section; - } - if ( isset( $this->mSectionFooters[$key] ) ) { - $section .= $this->mSectionFooters[$key]; - } + $section = $this->getHeaderText( $key ) . $section . $this->getFooterText( $key ); $attributes = array(); if ( $fieldsetIDPrefix ) { diff --git a/includes/htmlform/OOUIHTMLForm.php b/includes/htmlform/OOUIHTMLForm.php index ca8ca0f..3f12f1d 100644 --- a/includes/htmlform/OOUIHTMLForm.php +++ b/includes/htmlform/OOUIHTMLForm.php @@ -132,6 +132,22 @@ // TODO Write me! } + /** + * Get header text. + * + * @param string|null $section The section to get the header text for + * @since 1.26 + * @return string + */ + function getHeaderText( $section = null ) { + if ( is_null( $section ) ) { + // We handle $this->mHeader elsewhere, in getBody() + return ''; + } else { + return parent::getHeaderText( $section ); + } + } + function getBody() { $fieldset = parent::getBody(); // FIXME This only works for forms with no subsections -- To view, visit https://gerrit.wikimedia.org/r/227605 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9a7234ed75b024f24e0a087c9c000bb2024b405f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Bartosz Dziewoński <matma....@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits