Merge "Revert "Limit searches at 500 per page""
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
index e4ca057..9fdc749 100644 (file)
@@ -199,7 +199,7 @@ class SpecialSearch extends SpecialPage {
                if ( !is_null( $t ) ) {
                        global $wgGoToEdit;
                        wfRunHooks( 'SpecialSearchNogomatch', array( &$t ) );
-                       wfDebugLog( 'nogomatch', $t->getText(), false );
+                       wfDebugLog( 'nogomatch', $t->getText(), 'private' );
 
                        # If the feature is enabled, go straight to the edit page
                        if ( $wgGoToEdit ) {
@@ -376,7 +376,7 @@ class SpecialSearch extends SpecialPage {
                // prev/next links
                if ( $num || $this->offset ) {
                        // Show the create link ahead
-                       $this->showCreateLink( $t, $num );
+                       $this->showCreateLink( $t, $num, $titleMatches, $textMatches );
                        $prevnext = $this->getLanguage()->viewPrevNext( $this->getPageTitle(), $this->offset, $this->limit,
                                $this->powerSearchOptions() + array( 'search' => $term ),
                                max( $titleMatchesNum, $textMatchesNum ) < $this->limit
@@ -422,7 +422,7 @@ class SpecialSearch extends SpecialPage {
                        } else {
                                $out->wrapWikiMsg( "<p class=\"mw-search-nonefound\">\n$1</p>",
                                        array( 'search-nonefound', wfEscapeWikiText( $term ) ) );
-                               $this->showCreateLink( $t, $num );
+                               $this->showCreateLink( $t, $num, $titleMatches, $textMatches );
                        }
                }
                $out->addHtml( "</div>" );
@@ -437,12 +437,16 @@ class SpecialSearch extends SpecialPage {
        /**
         * @param $t Title
         * @param int $num The number of search results found
+        * @param $titleMatches null|SearchResultSet results from title search
+        * @param $textMatches null|SearchResultSet results from text search
         */
-       protected function showCreateLink( $t, $num ) {
+       protected function showCreateLink( $t, $num, $titleMatches, $textMatches ) {
                // show direct page/create link if applicable
 
                // Check DBkey !== '' in case of fragment link only.
-               if ( is_null( $t ) || $t->getDBkey() === '' ) {
+               if ( is_null( $t ) || $t->getDBkey() === '' ||
+                               ( $titleMatches !== null && $titleMatches->searchContainedSyntax() ) ||
+                               ( $textMatches !== null && $textMatches->searchContainedSyntax() ) ) {
                        // invalid title
                        // preserve the paragraph for margins etc...
                        $this->getOutput()->addHtml( '<p></p>' );
@@ -687,9 +691,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 ) {
@@ -705,7 +715,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>' .
@@ -724,7 +734,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";
                }
@@ -1103,7 +1113,7 @@ class SpecialSearch extends SpecialPage {
                $out .= Html::hidden( 'fulltext', 'Search' ) . "\n";
                $out .= Xml::submitButton(
                        $this->msg( 'searchbutton' )->text(),
-                       array( 'class' => array( 'mw-ui-button', 'mw-ui-primary' ) )
+                       array( 'class' => array( 'mw-ui-button', 'mw-ui-progressive' ) )
                ) . "\n";
                return $out . $this->didYouMeanHtml;
        }