From 20b93f792214970a964355d69358b2436a451a0e Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Tue, 25 Jan 2011 20:56:56 +0000 Subject: [PATCH] HTMLForm: All section headers and footers. Added an optional second $section parameter to addHeaderText and addFooterText. --- includes/HTMLForm.php | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index 2e7e3999bd..7277908f90 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -92,6 +92,8 @@ class HTMLForm { protected $mPre = ''; protected $mHeader = ''; protected $mFooter = ''; + protected $mSectionHeaders = array(); + protected $mSectionFooters = array(); protected $mPost = ''; protected $mId; @@ -309,13 +311,31 @@ class HTMLForm { * Add header text, inside the form. * @param $msg String complete text of message to display */ - function addHeaderText( $msg ) { $this->mHeader .= $msg; } + function addHeaderText( $msg, $section = null ) { + if ( is_null( $section ) ) { + $this->mHeader .= $msg; + } else { + if ( !isset( $this->mSectionHeaders[$section] ) ) { + $this->mSectionHeaders[$section] = ''; + } + $this->mSectionHeaders[$section] .= $msg; + } + } /** * Add footer text, inside the form. * @param $msg String complete text of message to display */ - function addFooterText( $msg ) { $this->mFooter .= $msg; } + function addFooterText( $msg, $section = null ) { + if ( is_null( $section ) ) { + $this->mFooter .= $msg; + } else { + if ( !isset( $this->mSectionFooters[$section] ) ) { + $this->mSectionFooters[$section] = ''; + } + $this->mSectionFooters[$section] .= $msg; + } + } /** * Add text to the end of the display. @@ -633,7 +653,13 @@ class HTMLForm { } elseif ( is_array( $value ) ) { $section = $this->displaySection( $value, $key ); $legend = wfMsg( "{$this->mMessagePrefix}-$key" ); - $subsectionHtml .= Xml::fieldset( $legend, $section ) . "\n"; + if ( isset( $this->mSectionHeaders[$key] ) ) { + $section = $this->mSectionHeaders[$key] . $section; + } + if ( isset( $this->mSectionFooters[$key] ) ) { + $section .= $this->mSectionFooters[$key]; + } + $subsectionHtml .= Xml::fieldset( $legend, $section ) . "\n"; } } -- 2.20.1