As suggested to me by email: very active members of a wiki community can end up recei...
[lhc/web/wiklou.git] / includes / specials / SpecialMIMEsearch.php
index c9e8898..aefe7bf 100644 (file)
@@ -41,7 +41,7 @@ class MIMEsearchPage extends QueryPage {
        function linkParameters() {
                return array( 'mime' => "{$this->major}/{$this->minor}" );
        }
-       
+
        public function getQueryInfo() {
                return array(
                        'tables' => array( 'image' ),
@@ -57,11 +57,11 @@ class MIMEsearchPage extends QueryPage {
                                        'img_minor_mime' => $this->minor )
                );
        }
-       
+
        function execute( $par ) {
                global $wgRequest, $wgOut;
                $mime = $par ? $par : $wgRequest->getText( 'mime' );
-               
+
                $this->setHeaders();
                $this->outputHeader();
                $wgOut->addHTML(
@@ -75,13 +75,14 @@ class MIMEsearchPage extends QueryPage {
                        Xml::closeElement( 'form' )
                );
 
-               list( $this->major, $this->minor ) = self::parseMIME( $mime );
-               if ( $this->major == '' || $this->minor == '' || !self::isValidType( $this->major ) ) {
+               list( $this->major, $this->minor ) = File::splitMime( $mime );
+               if ( $this->major == '' || $this->minor == '' || $this->minor == 'unknown' ||
+                       !self::isValidType( $this->major ) ) {
                        return;
                }
                parent::execute( $par );
        }
-               
+
 
        function formatResult( $skin, $result ) {
                global $wgContLang, $wgLang;
@@ -105,21 +106,11 @@ class MIMEsearchPage extends QueryPage {
 
                return "($download) $plink . . $dimensions . . $bytes . . $user . . $time";
        }
-       
-       protected static function parseMIME( $str ) {
-               // searched for an invalid MIME type.
-               if( strpos( $str, '/' ) === false ) {
-                       return array( '', '' );
-               }
 
-               list( $major, $minor ) = explode( '/', $str, 2 );
-
-               return array(
-                       ltrim( $major, ' ' ),
-                       rtrim( $minor, ' ' )
-               );
-       }
-       
+       /**
+        * @param $type string
+        * @return bool
+        */
        protected static function isValidType( $type ) {
                // From maintenance/tables.sql => img_major_mime
                $types = array(