Don't bother showing prev/next links navigation when there's few results
authorChad Horohoe <chadh@wikimedia.org>
Wed, 30 Apr 2014 23:16:02 +0000 (16:16 -0700)
committerChad Horohoe <chadh@wikimedia.org>
Wed, 30 Apr 2014 23:19:32 +0000 (16:19 -0700)
Started working on bug 48466 bug we'll need a new message for viewprevnext
that doesn't have parens when there's no need. Saw this along the way and
it was easier.

Change-Id: If3d3503a1b7ebd6c8adad42725f53314733e72cf

includes/specials/SpecialSearch.php

index 0c4252e..6eee861 100644 (file)
@@ -360,14 +360,16 @@ class SpecialSearch extends SpecialPage {
                $out->addHtml( "<div class='searchresults'>" );
 
                // prev/next links
+               $prevnext = null;
                if ( $num || $this->offset ) {
                        // Show the create link ahead
                        $this->showCreateLink( $title, $num, $titleMatches, $textMatches );
-                       $prevnext = $this->getLanguage()->viewPrevNext( $this->getPageTitle(), $this->offset, $this->limit,
-                               $this->powerSearchOptions() + array( 'search' => $term ),
-                               max( $titleMatchesNum, $textMatchesNum ) < $this->limit
-                       );
-                       //$out->addHTML( "<p class='mw-search-pager-top'>{$prevnext}</p>\n" );
+                       if ( $totalRes > $this->limit || $this->offset ) {
+                               $prevnext = $this->getLanguage()->viewPrevNext( $this->getPageTitle(), $this->offset, $this->limit,
+                                       $this->powerSearchOptions() + array( 'search' => $term ),
+                                       max( $titleMatchesNum, $textMatchesNum ) < $this->limit
+                               );
+                       }
                        wfRunHooks( 'SpecialSearchResults', array( $term, &$titleMatches, &$textMatches ) );
                } else {
                        wfRunHooks( 'SpecialSearchNoResults', array( $term ) );
@@ -386,10 +388,8 @@ class SpecialSearch extends SpecialPage {
                        if ( $numTextMatches > 0 && $numTitleMatches > 0 ) {
                                // if no title matches the heading is redundant
                                $out->wrapWikiMsg( "==$1==\n", 'textmatches' );
-                       } elseif ( $totalRes == 0 ) {
-                               # Don't show the 'no text matches' if we received title matches
-                               # $out->wrapWikiMsg( "==$1==\n", 'notextmatches' );
                        }
+
                        // show interwiki results if any
                        if ( $textMatches->hasInterwikiResults() ) {
                                $out->addHTML( $this->showInterwiki( $textMatches->getInterwikiResults(), $term ) );
@@ -413,7 +413,7 @@ class SpecialSearch extends SpecialPage {
                }
                $out->addHtml( "</div>" );
 
-               if ( $num || $this->offset ) {
+               if ( $prevnext ) {
                        $out->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
                }
        }