Limit searches at 500 per page
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
index 3d23884..98ae6f5 100644 (file)
@@ -37,7 +37,6 @@ class SpecialSearch extends SpecialPage {
         * null|string
         */
        protected $profile;
-       function getProfile() { return $this->profile; }
 
        /// Search engine
        protected $searchEngine;
@@ -60,7 +59,6 @@ class SpecialSearch extends SpecialPage {
         * @var array
         */
        protected $namespaces;
-       function getNamespaces() { return $this->namespaces; }
 
        /**
         * @var bool
@@ -89,7 +87,7 @@ class SpecialSearch extends SpecialPage {
                $out = $this->getOutput();
                $out->allowClickjacking();
                $out->addModuleStyles( array(
-                       'mediawiki.special', 'mediawiki.special.search', 'mediawiki.ui'
+                       'mediawiki.special', 'mediawiki.special.search', 'mediawiki.ui', 'mediawiki.ui.button'
                ) );
 
                // Strip underscores from title parameter; most of the time we'll want
@@ -122,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();
@@ -255,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 );
@@ -271,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 ..
@@ -377,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
                        );
@@ -478,7 +478,7 @@ class SpecialSearch extends SpecialPage {
                if ( strval( $term ) !== '' ) {
                        $out->setPageTitle( $this->msg( 'searchresults' ) );
                        $out->setHTMLTitle( $this->msg( 'pagetitle' )
-                               ->rawParams( $this->msg( 'searchresults-title' )->rawParams( $term ) )
+                               ->rawParams( $this->msg( 'searchresults-title' )->rawParams( $term )->text() )
                                ->inContentLanguage()->text()
                        );
                }
@@ -1091,7 +1091,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(
@@ -1136,7 +1136,7 @@ class SpecialSearch extends SpecialPage {
                return Xml::element(
                        'a',
                        array(
-                               'href' => $this->getTitle()->getLocalURL( $stParams ),
+                               'href' => $this->getPageTitle()->getLocalURL( $stParams ),
                                'title' => $tooltip
                        ),
                        $label
@@ -1189,6 +1189,22 @@ class SpecialSearch extends SpecialPage {
                return $this->searchEngine;
        }
 
+       /**
+        * Current search profile.
+        * @return null|string
+        */
+       function getProfile() {
+               return $this->profile;
+       }
+
+       /**
+        * Current namespaces.
+        * @return array
+        */
+       function getNamespaces() {
+               return $this->namespaces;
+       }
+
        /**
         * Users of hook SpecialSearchSetupEngine can use this to
         * add more params to links to not lose selection when