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
This commit is contained in:
parent
40abd65b24
commit
0a6803e1e5
2 changed files with 44 additions and 9 deletions
|
|
@ -710,6 +710,21 @@ class HTMLForm extends ContextSource {
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
|
@ -750,6 +765,21 @@ class HTMLForm extends ContextSource {
|
|||
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] : '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add text to the end of the display.
|
||||
*
|
||||
|
|
@ -871,12 +901,11 @@ class HTMLForm extends ContextSource {
|
|||
|
||||
$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 );
|
||||
|
||||
|
|
@ -1372,12 +1401,9 @@ class HTMLForm extends ContextSource {
|
|||
|
||||
$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 ) {
|
||||
|
|
|
|||
|
|
@ -133,6 +133,15 @@ class OOUIHTMLForm extends HTMLForm {
|
|||
return '';
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue