* (bug 2815) Search results for media files now use thumb instead of text extract
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 11 Mar 2008 18:32:35 +0000 (18:32 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 11 Mar 2008 18:32:35 +0000 (18:32 +0000)
RELEASE-NOTES
includes/SpecialSearch.php

index 146ec55..3a1e67d 100644 (file)
@@ -40,6 +40,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   redirects to the redirect table
 * Add links to page and file deletion forms to edit predefined delete reasons 
 * (bug 13269) Added MediaWiki:Uploadfooter to the bottom of Special:Upload
+* (bug 2815) Search results for media files now use thumb instead of text extract
 
 === Bug fixes in 1.13 ===
 
index dcbbb90..c8e6cd4 100644 (file)
@@ -344,7 +344,42 @@ class SpecialSearch {
                if (!$t->userCanRead()) {
                        return "<li>{$link}</li>\n";
                }
+               
+               $extract = $size = '';
+               // Include a thumbnail for media files...
+               if( $t->getNamespace() == NS_IMAGE ) {
+                       $img = wfFindFile( $t );
+                       if( $img ) {
+                               $thumb = $img->getThumbnail( 120, 120 );
+                               if( $thumb ) {
+                                       $extract = '<table>' .
+                                               '<tr>' .
+                                               '<td width="120" align="center">' .
+                                               $sk->makeKnownLinkObj( $t, $thumb->toHtml() ) .
+                                               '</td>' .
+                                               '<td>' .
+                                               $link .
+                                               '<br />' .
+                                               $img->getLongDesc() .
+                                               '</td>' .
+                                               '</tr>' .
+                                               '</table>';
+                                       wfProfileOut( $fname );
+                                       return "<li><div>{$extract}</div></li>\n";
+                               }
+                       }
+               }
+
+               $extract = $this->extractText( $t, $terms, $contextlines, $contextchars );
+               wfProfileOut( $fname );
+               return "<li>{$link} {$extract}</li>\n";
 
+       }
+       
+       private function extractText( $t, $terms, $contextlines, $contextchars ) {
+               global $wgLang, $wgContLang;
+               $fname = __METHOD__;
+       
                $revision = Revision::newFromTitle( $t );
                $text = $revision->getText();
                $size = wfMsgExt( 'nbytes', array( 'parsemag', 'escape'),
@@ -357,7 +392,7 @@ class SpecialSearch {
 
                $lineno = 0;
 
-               $extract = '';
+               $extract = "($size)";
                wfProfileIn( "$fname-extract" );
                foreach ( $lines as $line ) {
                        if ( 0 == $contextlines ) {
@@ -387,8 +422,8 @@ class SpecialSearch {
                        $extract .= "<br /><small>{$lineno}: {$line}</small>\n";
                }
                wfProfileOut( "$fname-extract" );
-               wfProfileOut( $fname );
-               return "<li>{$link} ({$size}){$extract}</li>\n";
+               
+               return $extract;
        }
 
        function powerSearchBox( $term ) {