From c1f9b1f7b1b77776192048005dcc66dcf3df2bfb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 27 Dec 2014 15:41:37 +0100 Subject: Update to MediaWiki 1.24.1 --- includes/specials/SpecialMIMEsearch.php | 58 +++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 24 deletions(-) (limited to 'includes/specials/SpecialMIMEsearch.php') diff --git a/includes/specials/SpecialMIMEsearch.php b/includes/specials/SpecialMIMEsearch.php index 3eeae310..60225ea5 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 ); @@ -51,6 +51,11 @@ class MIMEsearchPage extends QueryPage { } public function getQueryInfo() { + $minorType = array(); + if ( $this->minor !== '*' ) { + // Allow wildcard searching + $minorType['img_minor_mime'] = $this->minor; + } $qi = array( 'tables' => array( 'image' ), 'fields' => array( @@ -67,7 +72,6 @@ class MIMEsearchPage extends QueryPage { ), 'conds' => array( 'img_major_mime' => $this->major, - 'img_minor_mime' => $this->minor, // This is in order to trigger using // the img_media_mime index in "range" mode. 'img_media_type' => array( @@ -82,8 +86,9 @@ class MIMEsearchPage extends QueryPage { MEDIATYPE_EXECUTABLE, MEDIATYPE_ARCHIVE, ), - ), + ) + $minorType, ); + return $qi; } @@ -94,38 +99,42 @@ class MIMEsearchPage extends QueryPage { * that this report gives results in a logical order). As an aditional * note, mysql seems to by default order things by img_name ASC, which * is what we ideally want, so everything works out fine anyhow. + * @return array */ function getOrderFields() { return array(); } - function execute( $par ) { - global $wgScript; - - $mime = $par ? $par : $this->getRequest()->getText( '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' => $wgScript ) + array( 'id' => 'specialmimesearch', 'method' => 'get', 'action' => wfScript() ) ) . - Xml::openElement( 'fieldset' ) . - Html::hidden( 'title', $this->getTitle()->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; } @@ -165,7 +174,7 @@ class MIMEsearchPage extends QueryPage { } /** - * @param $type string + * @param string $type * @return bool */ protected static function isValidType( $type ) { @@ -179,7 +188,8 @@ class MIMEsearchPage extends QueryPage { 'video', 'message', 'model', - 'multipart' + 'multipart', + 'chemical' ); return in_array( $type, $types ); -- cgit v1.2.2