Fix double output of mimesearch-summary
authorBrian Wolff <bawolff+wn@gmail.com>
Mon, 9 Jun 2014 05:27:04 +0000 (02:27 -0300)
committerBrian Wolff <bawolff+wn@gmail.com>
Sun, 14 Sep 2014 23:35:32 +0000 (20:35 -0300)
The execute method was calling a outputHeader(), and then calling
it's parent implementation which was also calling outputHeader()
causing double output.

Refactor class to use $this->getPageHeader() to output menus
before result list, as that appears to be what that method is
for.

Change-Id: Ic0a79cb73136e636f96e33859dadb384eca38255

includes/specials/SpecialMIMEsearch.php

index 5bd69e0..60225ea 100644 (file)
@@ -28,7 +28,7 @@
  * @ingroup SpecialPage
  */
 class MIMEsearchPage extends QueryPage {
-       protected $major, $minor;
+       protected $major, $minor, $mime;
 
        function __construct( $name = 'MIMEsearch' ) {
                parent::__construct( $name );
@@ -105,32 +105,36 @@ class MIMEsearchPage extends QueryPage {
                return array();
        }
 
-       function execute( $par ) {
-               $mime = $par ? $par : $this->getRequest()->getText( 'mime' );
-               $mime = trim( $mime );
+       /**
+        * Return HTML to put just before the results.
+        */
+       function getPageHeader() {
 
-               $this->setHeaders();
-               $this->outputHeader();
-               $this->getOutput()->addHTML(
-                       Xml::openElement(
+               return Xml::openElement(
                                'form',
                                array( 'id' => 'specialmimesearch', 'method' => 'get', 'action' => wfScript() )
                        ) .
-                               Xml::openElement( 'fieldset' ) .
-                               Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() ) .
-                               Xml::element( 'legend', null, $this->msg( 'mimesearch' )->text() ) .
-                               Xml::inputLabel( $this->msg( 'mimetype' )->text(), 'mime', 'mime', 20, $mime ) .
-                               ' ' .
-                               Xml::submitButton( $this->msg( 'ilsubmit' )->text() ) .
-                               Xml::closeElement( 'fieldset' ) .
-                               Xml::closeElement( 'form' )
-               );
+                       Xml::openElement( 'fieldset' ) .
+                       Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() ) .
+                       Xml::element( 'legend', null, $this->msg( 'mimesearch' )->text() ) .
+                       Xml::inputLabel( $this->msg( 'mimetype' )->text(), 'mime', 'mime', 20, $this->mime ) .
+                       ' ' .
+                       Xml::submitButton( $this->msg( 'ilsubmit' )->text() ) .
+                                       Xml::closeElement( 'fieldset' ) .
+                                       Xml::closeElement( 'form' );
+       }
 
-               list( $this->major, $this->minor ) = File::splitMime( $mime );
+       function execute( $par ) {
+               $this->mime = $par ? $par : $this->getRequest()->getText( 'mime' );
+               $this->mime = trim( $this->mime );
+               list( $this->major, $this->minor ) = File::splitMime( $this->mime );
 
                if ( $this->major == '' || $this->minor == '' || $this->minor == 'unknown' ||
                        !self::isValidType( $this->major )
                ) {
+                       $this->setHeaders();
+                       $this->outputHeader();
+                       $this->getOutput()->addHTML( $this->getPageHeader() );
                        return;
                }