Merge "+Test for Status->CleanParams with a callback"
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
index 36ccaf8..18e777a 100644 (file)
@@ -120,7 +120,7 @@ class SpecialSearch extends SpecialPage {
         */
        public function load() {
                $request = $this->getRequest();
-               list( $this->limit, $this->offset ) = $request->getLimitOffset( 20, 'searchlimit' );
+               list( $this->limit, $this->offset ) = $request->getLimitOffset( 20, '', 500 );
                $this->mPrefix = $request->getVal( 'prefix', '' );
 
                $user = $this->getUser();
@@ -253,6 +253,8 @@ class SpecialSearch extends SpecialPage {
                }
 
                $t = Title::newFromText( $term );
+               $showSuggestion = $t === null || !$t->isKnown();
+               $search->setShowSuggestion( $showSuggestion );
 
                // fetch search results
                $rewritten = $search->replacePrefixes( $term );
@@ -269,7 +271,7 @@ class SpecialSearch extends SpecialPage {
                }
 
                // did you mean... suggestions
-               if ( $textMatches && !$textStatus && $textMatches->hasSuggestion() ) {
+               if ( $showSuggestion && $textMatches && !$textStatus && $textMatches->hasSuggestion() ) {
                        $st = SpecialPage::getTitleFor( 'Search' );
 
                        # mirror Go/Search behavior of original request ..
@@ -375,7 +377,7 @@ class SpecialSearch extends SpecialPage {
                if ( $num || $this->offset ) {
                        // Show the create link ahead
                        $this->showCreateLink( $t, $num );
-                       $prevnext = $this->getLanguage()->viewPrevNext( $this->getTitle(), $this->offset, $this->limit,
+                       $prevnext = $this->getLanguage()->viewPrevNext( $this->getPageTitle(), $this->offset, $this->limit,
                                $this->powerSearchOptions() + array( 'search' => $term ),
                                max( $titleMatchesNum, $textMatchesNum ) < $this->limit
                        );
@@ -685,9 +687,15 @@ class SpecialSearch extends SpecialPage {
                        );
                }
 
+               $fileMatch = '';
                // Include a thumbnail for media files...
                if ( $t->getNamespace() == NS_FILE ) {
-                       $img = wfFindFile( $t );
+                       $img = $result->getFile();
+                       $img = $img ?: wfFindFile( $t );
+                       if ( $result->isFileMatch() ) {
+                               $fileMatch = "<span class='searchalttitle'>" .
+                                       $this->msg( 'search-file-match' )->escaped() . "</span>";
+                       }
                        if ( $img ) {
                                $thumb = $img->transform( array( 'width' => 120, 'height' => 120 ) );
                                if ( $thumb ) {
@@ -703,7 +711,7 @@ class SpecialSearch extends SpecialPage {
                                                $thumb->toHtml( array( 'desc-link' => true ) ) .
                                                '</td>' .
                                                '<td style="vertical-align: top;">' .
-                                               $link .
+                                               "{$link} {$fileMatch}" .
                                                $extract .
                                                "<div class='mw-search-result-data'>{$score}{$desc} - {$date}{$related}</div>" .
                                                '</td>' .
@@ -722,7 +730,7 @@ class SpecialSearch extends SpecialPage {
                        &$score, &$size, &$date, &$related,
                        &$html
                ) ) ) {
-                       $html = "<li><div class='mw-search-result-heading'>{$link} {$redirect} {$section}</div> {$extract}\n" .
+                       $html = "<li><div class='mw-search-result-heading'>{$link} {$redirect} {$section} {$fileMatch}</div> {$extract}\n" .
                                "<div class='mw-search-result-data'>{$score}{$size} - {$date}{$related}</div>" .
                                "</li>\n";
                }
@@ -1089,7 +1097,7 @@ class SpecialSearch extends SpecialPage {
         * @return string
         */
        protected function shortDialog( $term ) {
-               $out = Html::hidden( 'title', $this->getTitle()->getPrefixedText() );
+               $out = Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() );
                $out .= Html::hidden( 'profile', $this->profile ) . "\n";
                // Term box
                $out .= Html::input( 'search', $term, 'search', array(
@@ -1134,7 +1142,7 @@ class SpecialSearch extends SpecialPage {
                return Xml::element(
                        'a',
                        array(
-                               'href' => $this->getTitle()->getLocalURL( $stParams ),
+                               'href' => $this->getPageTitle()->getLocalURL( $stParams ),
                                'title' => $tooltip
                        ),
                        $label