From f711861dcf07fcfba0162b71da8537a9ce8cf51d Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 11 Mar 2008 18:32:35 +0000 Subject: [PATCH] * (bug 2815) Search results for media files now use thumb instead of text extract --- RELEASE-NOTES | 1 + includes/SpecialSearch.php | 41 +++++++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 146ec558fe..3a1e67dadb 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/SpecialSearch.php b/includes/SpecialSearch.php index dcbbb903b9..c8e6cd4744 100644 --- a/includes/SpecialSearch.php +++ b/includes/SpecialSearch.php @@ -344,7 +344,42 @@ class SpecialSearch { if (!$t->userCanRead()) { return "
  • {$link}
  • \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 = '' . + '' . + '' . + '' . + '' . + '
    ' . + $sk->makeKnownLinkObj( $t, $thumb->toHtml() ) . + '' . + $link . + '
    ' . + $img->getLongDesc() . + '
    '; + wfProfileOut( $fname ); + return "
  • {$extract}
  • \n"; + } + } + } + + $extract = $this->extractText( $t, $terms, $contextlines, $contextchars ); + wfProfileOut( $fname ); + return "
  • {$link} {$extract}
  • \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 .= "
    {$lineno}: {$line}\n"; } wfProfileOut( "$fname-extract" ); - wfProfileOut( $fname ); - return "
  • {$link} ({$size}){$extract}
  • \n"; + + return $extract; } function powerSearchBox( $term ) { -- 2.20.1