From 21b5b133ab1196d6177a2df5b5b543c5ec56aab8 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Mon, 9 Jun 2014 02:27:04 -0300 Subject: [PATCH] Fix double output of mimesearch-summary 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 | 40 ++++++++++++++----------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/includes/specials/SpecialMIMEsearch.php b/includes/specials/SpecialMIMEsearch.php index 5bd69e01a8..60225ea509 100644 --- a/includes/specials/SpecialMIMEsearch.php +++ b/includes/specials/SpecialMIMEsearch.php @@ -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; } -- 2.20.1