Merge "Add missing return value"
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
index 94995db..dd32656 100644 (file)
@@ -42,6 +42,9 @@ class SpecialSearch extends SpecialPage {
        /// Search engine
        protected $searchEngine;
 
+       /// Search engine type, if not default
+       protected $searchEngineType;
+
        /// For links
        protected $extraParams = array();
 
@@ -85,7 +88,9 @@ class SpecialSearch extends SpecialPage {
                $this->outputHeader();
                $out = $this->getOutput();
                $out->allowClickjacking();
-               $out->addModuleStyles( 'mediawiki.special' );
+               $out->addModuleStyles( array(
+                       'mediawiki.special', 'mediawiki.special.search', 'mediawiki.ui'
+               ) );
 
                // Strip underscores from title parameter; most of the time we'll want
                // text form here. But don't strip underscores from actual text params!
@@ -98,6 +103,8 @@ class SpecialSearch extends SpecialPage {
 
                $this->load();
 
+               $this->searchEngineType = $request->getVal( 'srbackend' );
+
                if ( $request->getVal( 'fulltext' )
                        || !is_null( $request->getVal( 'offset' ) )
                        || !is_null( $request->getVal( 'searchx' ) ) )
@@ -313,13 +320,12 @@ class SpecialSearch extends SpecialPage {
                        )
                );
                $out->addHtml(
-                       Xml::openElement( 'table', array( 'id' => 'mw-search-top-table', 'cellpadding' => 0, 'cellspacing' => 0 ) ) .
-                       Xml::openElement( 'tr' ) .
-                       Xml::openElement( 'td' ) . "\n" .
+                       # This is an awful awful ID name. It's not a table, but we
+                       # named it poorly from when this was a table so now we're
+                       # stuck with it
+                       Xml::openElement( 'div', array( 'id' => 'mw-search-top-table' ) ) .
                        $this->shortDialog( $term ) .
-                       Xml::closeElement( 'td' ) .
-                       Xml::closeElement( 'tr' ) .
-                       Xml::closeElement( 'table' )
+                       Xml::closeElement( 'div' )
                );
 
                // Sometimes the search engine knows there are too many hits
@@ -733,7 +739,7 @@ class SpecialSearch extends SpecialPage {
         *
         * @return string
         */
-       protected function showInterwiki( &$matches, $query ) {
+       protected function showInterwiki( $matches, $query ) {
                global $wgContLang;
                wfProfileIn( __METHOD__ );
                $terms = $wgContLang->convertForSearchResult( $matches->termMatches() );
@@ -875,6 +881,8 @@ class SpecialSearch extends SpecialPage {
         * @return String: HTML form
         */
        protected function powerSearchBox( $term, $opts ) {
+               global $wgContLang;
+
                // Groups namespaces into rows according to subject
                $rows = array();
                foreach ( SearchEngine::searchableNamespaces() as $namespace => $name ) {
@@ -882,10 +890,12 @@ class SpecialSearch extends SpecialPage {
                        if ( !array_key_exists( $subject, $rows ) ) {
                                $rows[$subject] = "";
                        }
-                       $name = str_replace( '_', ' ', $name );
+
+                       $name = $wgContLang->getConverter()->convertNamespace( $namespace );
                        if ( $name == '' ) {
                                $name = $this->msg( 'blanknamespace' )->text();
                        }
+
                        $rows[$subject] .=
                                Xml::openElement(
                                        'td', array( 'style' => 'white-space: nowrap' )
@@ -898,6 +908,7 @@ class SpecialSearch extends SpecialPage {
                                ) .
                                Xml::closeElement( 'td' );
                }
+
                $rows = array_values( $rows );
                $numRows = count( $rows );
 
@@ -909,9 +920,11 @@ class SpecialSearch extends SpecialPage {
                                'table',
                                array( 'cellpadding' => 0, 'cellspacing' => 0 )
                        );
+
                        for ( $j = $i; $j < $i + 4 && $j < $numRows; $j++ ) {
                                $namespaceTables .= Xml::tags( 'tr', null, $rows[$j] );
                        }
+
                        $namespaceTables .= Xml::closeElement( 'table' );
                }
 
@@ -1082,10 +1095,14 @@ class SpecialSearch extends SpecialPage {
                $out .= Html::input( 'search', $term, 'search', array(
                        'id' => $this->profile === 'advanced' ? 'powerSearchText' : 'searchText',
                        'size' => '50',
-                       'autofocus'
+                       'autofocus',
+                       'class' => 'mw-ui-input',
                ) ) . "\n";
                $out .= Html::hidden( 'fulltext', 'Search' ) . "\n";
-               $out .= Xml::submitButton( $this->msg( 'searchbutton' )->text() ) . "\n";
+               $out .= Xml::submitButton(
+                       $this->msg( 'searchbutton' )->text(),
+                       array( 'class' => array( 'mw-ui-button', 'mw-ui-primary' ) )
+               ) . "\n";
                return $out . $this->didYouMeanHtml;
        }
 
@@ -1164,7 +1181,8 @@ class SpecialSearch extends SpecialPage {
         */
        public function getSearchEngine() {
                if ( $this->searchEngine === null ) {
-                       $this->searchEngine = SearchEngine::create();
+                       $this->searchEngine = $this->searchEngineType ?
+                               SearchEngine::create( $this->searchEngineType ) : SearchEngine::create();
                }
                return $this->searchEngine;
        }
@@ -1183,6 +1201,6 @@ class SpecialSearch extends SpecialPage {
        }
 
        protected function getGroupName() {
-               return 'redirects';
+               return 'pages';
        }
 }