HTMLForm: All section headers and footers. Added an optional second $section paramete...
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Tue, 25 Jan 2011 20:56:56 +0000 (20:56 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Tue, 25 Jan 2011 20:56:56 +0000 (20:56 +0000)
includes/HTMLForm.php

index 2e7e399..7277908 100644 (file)
@@ -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";                                   
                        }
                }