diff options
Diffstat (limited to 'includes/specials/SpecialMIMEsearch.php')
-rw-r--r-- | includes/specials/SpecialMIMEsearch.php | 97 |
1 files changed, 74 insertions, 23 deletions
diff --git a/includes/specials/SpecialMIMEsearch.php b/includes/specials/SpecialMIMEsearch.php index c5a109d4..3eeae310 100644 --- a/includes/specials/SpecialMIMEsearch.php +++ b/includes/specials/SpecialMIMEsearch.php @@ -35,7 +35,7 @@ class MIMEsearchPage extends QueryPage { } function isExpensive() { - return true; + return false; } function isSyndicated() { @@ -51,19 +51,52 @@ class MIMEsearchPage extends QueryPage { } public function getQueryInfo() { - return array( + $qi = array( 'tables' => array( 'image' ), - 'fields' => array( 'namespace' => NS_FILE, - 'title' => 'img_name', - 'value' => 'img_major_mime', - 'img_size', - 'img_width', - 'img_height', - 'img_user_text', - 'img_timestamp' ), - 'conds' => array( 'img_major_mime' => $this->major, - 'img_minor_mime' => $this->minor ) + 'fields' => array( + 'namespace' => NS_FILE, + 'title' => 'img_name', + // Still have a value field just in case, + // but it isn't actually used for sorting. + 'value' => 'img_name', + 'img_size', + 'img_width', + 'img_height', + 'img_user_text', + 'img_timestamp' + ), + '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( + MEDIATYPE_BITMAP, + MEDIATYPE_DRAWING, + MEDIATYPE_AUDIO, + MEDIATYPE_VIDEO, + MEDIATYPE_MULTIMEDIA, + MEDIATYPE_UNKNOWN, + MEDIATYPE_OFFICE, + MEDIATYPE_TEXT, + MEDIATYPE_EXECUTABLE, + MEDIATYPE_ARCHIVE, + ), + ), ); + return $qi; + } + + /** + * The index is on (img_media_type, img_major_mime, img_minor_mime) + * which unfortunately doesn't have img_name at the end for sorting. + * So tell db to sort it however it wishes (Its not super important + * 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. + */ + function getOrderFields() { + return array(); } function execute( $par ) { @@ -74,24 +107,36 @@ class MIMEsearchPage extends QueryPage { $this->setHeaders(); $this->outputHeader(); $this->getOutput()->addHTML( - Xml::openElement( 'form', array( 'id' => 'specialmimesearch', 'method' => 'get', 'action' => $wgScript ) ) . - 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( + 'form', + array( 'id' => 'specialmimesearch', 'method' => 'get', 'action' => $wgScript ) + ) . + 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' ) ); list( $this->major, $this->minor ) = File::splitMime( $mime ); + if ( $this->major == '' || $this->minor == '' || $this->minor == 'unknown' || - !self::isValidType( $this->major ) ) { + !self::isValidType( $this->major ) + ) { return; } + parent::execute( $par ); } + /** + * @param Skin $skin + * @param object $result Result row + * @return string + */ function formatResult( $skin, $result ) { global $wgContLang; @@ -108,8 +153,13 @@ class MIMEsearchPage extends QueryPage { $bytes = htmlspecialchars( $lang->formatSize( $result->img_size ) ); $dimensions = $this->msg( 'widthheight' )->numParams( $result->img_width, $result->img_height )->escaped(); - $user = Linker::link( Title::makeTitle( NS_USER, $result->img_user_text ), htmlspecialchars( $result->img_user_text ) ); - $time = htmlspecialchars( $lang->userTimeAndDate( $result->img_timestamp, $this->getUser() ) ); + $user = Linker::link( + Title::makeTitle( NS_USER, $result->img_user_text ), + htmlspecialchars( $result->img_user_text ) + ); + + $time = $lang->userTimeAndDate( $result->img_timestamp, $this->getUser() ); + $time = htmlspecialchars( $time ); return "$download $plink . . $dimensions . . $bytes . . $user . . $time"; } @@ -131,6 +181,7 @@ class MIMEsearchPage extends QueryPage { 'model', 'multipart' ); + return in_array( $type, $types ); } |