Merge "SpecialSearch: Fix overlap between results info and search bar"
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
index 4f8cabd..7a870c0 100644 (file)
@@ -114,7 +114,7 @@ class SpecialSearch extends SpecialPage {
         */
        public function load() {
                $request = $this->getRequest();
-               list( $this->limit, $this->offset ) = $request->getLimitOffset( 20 );
+               list( $this->limit, $this->offset ) = $request->getLimitOffset( 20, '' );
                $this->mPrefix = $request->getVal( 'prefix', '' );
 
                $user = $this->getUser();
@@ -207,8 +207,7 @@ class SpecialSearch extends SpecialPage {
 
                $profile = new ProfileSection( __METHOD__ );
                $search = $this->getSearchEngine();
-               // Request an extra result to determine whether a "next page" link is useful
-               $search->setLimitOffset( $this->limit + 1, $this->offset );
+               $search->setLimitOffset( $this->limit, $this->offset );
                $search->setNamespaces( $this->namespaces );
                $this->saveNamespaces();
                $search->prefix = $this->mPrefix;
@@ -352,7 +351,7 @@ class SpecialSearch extends SpecialPage {
                                        $this->offset,
                                        $this->limit,
                                        $this->powerSearchOptions() + array( 'search' => $term ),
-                                       max( $titleMatchesNum, $textMatchesNum ) <= $this->limit
+                                       $this->limit + $this->offset >= $totalRes
                                );
                        }
                        wfRunHooks( 'SpecialSearchResults', array( $term, &$titleMatches, &$textMatches ) );
@@ -512,7 +511,11 @@ class SpecialSearch extends SpecialPage {
 
                if ( $user->isLoggedIn() &&
                        !is_null( $request->getVal( 'nsRemember' ) ) &&
-                       $user->matchEditToken( $request->getVal( 'nsToken' ) )
+                       $user->matchEditToken(
+                               $request->getVal( 'nsToken' ),
+                               'searchnamespace',
+                               $request
+                       )
                ) {
                        // Reset namespace preferences: namespaces are not searched
                        // when they're not mentioned in the URL parameters.
@@ -547,11 +550,9 @@ class SpecialSearch extends SpecialPage {
 
                $out = "<ul class='mw-search-results'>\n";
                $result = $matches->next();
-               $count = 0;
-               while ( $result && $count < $this->limit ) {
+               while ( $result ) {
                        $out .= $this->showHit( $result, $terms );
                        $result = $matches->next();
-                       $count++;
                }
                $out .= "</ul>\n";
 
@@ -936,7 +937,13 @@ class SpecialSearch extends SpecialPage {
                $remember = '';
                $user = $this->getUser();
                if ( $user->isLoggedIn() ) {
-                       $remember .= Html::hidden( 'nsToken', $user->getEditToken() ) .
+                       $remember .= Html::hidden(
+                               'nsToken',
+                               $user->getEditToken(
+                                       'searchnamespace',
+                                       $this->getRequest()
+                               )
+                       ) .
                        Xml::checkLabel(
                                wfMessage( 'powersearch-remember' )->text(),
                                'nsRemember',
@@ -1094,7 +1101,8 @@ class SpecialSearch extends SpecialPage {
                                ->params( wfEscapeWikiText( $term ) )
                                ->numParams( $resultsShown )
                                ->parse();
-                       $out .= Xml::tags( 'div', array( 'class' => 'results-info' ), $top );
+                       $out .= Xml::tags( 'div', array( 'class' => 'results-info' ), $top ) .
+                               Xml::element( 'div', array( 'style' => 'clear:both' ) );
                }
 
                return $out . $this->didYouMeanHtml;