Merge "Add missing return value"
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
index a4ab7a8..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' ) ) )
@@ -137,7 +144,7 @@ class SpecialSearch extends SpecialPage {
                if ( $profile === null ) {
                        // BC with old request format
                        $profile = 'advanced';
-                       foreach( $profiles as $key => $data ) {
+                       foreach ( $profiles as $key => $data ) {
                                if ( $nslist === $data['namespaces'] && $key !== 'advanced' ) {
                                        $profile = $key;
                                }
@@ -173,7 +180,7 @@ class SpecialSearch extends SpecialPage {
                # Try to go to page as entered.
                $t = Title::newFromText( $term );
                # If the string cannot be used to create a title
-               if( is_null( $t ) ) {
+               if ( is_null( $t ) ) {
                        $this->showResults( $term );
                        return;
                }
@@ -185,19 +192,19 @@ class SpecialSearch extends SpecialPage {
                        return;
                }
 
-               if( !is_null( $t ) ) {
+               if ( !is_null( $t ) ) {
                        $this->getOutput()->redirect( $t->getFullURL() );
                        return;
                }
                # No match, generate an edit URL
                $t = Title::newFromText( $term );
-               if( !is_null( $t ) ) {
+               if ( !is_null( $t ) ) {
                        global $wgGoToEdit;
                        wfRunHooks( 'SpecialSearchNogomatch', array( &$t ) );
                        wfDebugLog( 'nogomatch', $t->getText(), false );
 
                        # If the feature is enabled, go straight to the edit page
-                       if( $wgGoToEdit ) {
+                       if ( $wgGoToEdit ) {
                                $this->getOutput()->redirect( $t->getFullURL( array( 'action' => 'edit' ) ) );
                                return;
                        }
@@ -253,24 +260,24 @@ class SpecialSearch extends SpecialPage {
                $rewritten = $search->replacePrefixes( $term );
 
                $titleMatches = $search->searchTitle( $rewritten );
-               if( !( $titleMatches instanceof SearchResultTooMany ) ) {
+               if ( !( $titleMatches instanceof SearchResultTooMany ) ) {
                        $textMatches = $search->searchText( $rewritten );
                }
 
                $textStatus = null;
-               if( $textMatches instanceof Status ) {
+               if ( $textMatches instanceof Status ) {
                        $textStatus = $textMatches;
                        $textMatches = null;
                }
 
                // did you mean... suggestions
-               if( $textMatches && !$textStatus && $textMatches->hasSuggestion() ) {
+               if ( $textMatches && !$textStatus && $textMatches->hasSuggestion() ) {
                        $st = SpecialPage::getTitleFor( 'Search' );
 
                        # mirror Go/Search behavior of original request ..
                        $didYouMeanParams = array( 'search' => $textMatches->getSuggestionQuery() );
 
-                       if( $this->fulltext != null ) {
+                       if ( $this->fulltext != null ) {
                                $didYouMeanParams['fulltext'] = $this->fulltext;
                        }
 
@@ -281,7 +288,7 @@ class SpecialSearch extends SpecialPage {
 
                        $suggestionSnippet = $textMatches->getSuggestionSnippet();
 
-                       if( $suggestionSnippet == '' ) {
+                       if ( $suggestionSnippet == '' ) {
                                $suggestionSnippet = null;
                        }
 
@@ -313,24 +320,23 @@ 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
-               if( $titleMatches instanceof SearchResultTooMany ) {
+               if ( $titleMatches instanceof SearchResultTooMany ) {
                        $out->wrapWikiMsg( "==$1==\n", 'toomanymatches' );
                        wfProfileOut( __METHOD__ );
                        return;
                }
 
                $filePrefix = $wgContLang->getFormattedNsText( NS_FILE ) . ':';
-               if( trim( $term ) === '' || $filePrefix === trim( $term ) ) {
+               if ( trim( $term ) === '' || $filePrefix === trim( $term ) ) {
                        $out->addHTML( $this->formHeader( $term, 0, 0 ) );
                        $out->addHtml( $this->getProfileForm( $this->profile, $term ) );
                        $out->addHTML( '</form>' );
@@ -353,10 +359,12 @@ class SpecialSearch extends SpecialPage {
 
                // get total number of results if backend can calculate it
                $totalRes = 0;
-               if( $titleMatches && !is_null( $titleMatches->getTotalHits() ) )
+               if ( $titleMatches && !is_null( $titleMatches->getTotalHits() ) ) {
                        $totalRes += $titleMatches->getTotalHits();
-               if( $textMatches && !is_null( $textMatches->getTotalHits() ) )
+               }
+               if ( $textMatches && !is_null( $textMatches->getTotalHits() ) ) {
                        $totalRes += $textMatches->getTotalHits();
+               }
 
                // show number of results and current offset
                $out->addHTML( $this->formHeader( $term, $num, $totalRes ) );
@@ -366,7 +374,7 @@ class SpecialSearch extends SpecialPage {
                $out->addHtml( "<div class='searchresults'>" );
 
                // prev/next links
-               if( $num || $this->offset ) {
+               if ( $num || $this->offset ) {
                        // Show the create link ahead
                        $this->showCreateLink( $t );
                        $prevnext = $this->getLanguage()->viewPrevNext( $this->getTitle(), $this->offset, $this->limit,
@@ -380,34 +388,34 @@ class SpecialSearch extends SpecialPage {
                }
 
                $out->parserOptions()->setEditSection( false );
-               if( $titleMatches ) {
-                       if( $numTitleMatches > 0 ) {
+               if ( $titleMatches ) {
+                       if ( $numTitleMatches > 0 ) {
                                $out->wrapWikiMsg( "==$1==\n", 'titlematches' );
                                $out->addHTML( $this->showMatches( $titleMatches ) );
                        }
                        $titleMatches->free();
                }
-               if( $textMatches && !$textStatus ) {
+               if ( $textMatches && !$textStatus ) {
                        // output appropriate heading
-                       if( $numTextMatches > 0 && $numTitleMatches > 0 ) {
+                       if ( $numTextMatches > 0 && $numTitleMatches > 0 ) {
                                // if no title matches the heading is redundant
                                $out->wrapWikiMsg( "==$1==\n", 'textmatches' );
-                       } elseif( $totalRes == 0 ) {
+                       } 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() ) {
+                       if ( $textMatches->hasInterwikiResults() ) {
                                $out->addHTML( $this->showInterwiki( $textMatches->getInterwikiResults(), $term ) );
                        }
                        // show results
-                       if( $numTextMatches > 0 ) {
+                       if ( $numTextMatches > 0 ) {
                                $out->addHTML( $this->showMatches( $textMatches ) );
                        }
 
                        $textMatches->free();
                }
-               if( $num === 0 ) {
+               if ( $num === 0 ) {
                        if ( $textStatus ) {
                                $out->addHTML( '<div class="error">' .
                                        htmlspecialchars( $textStatus->getWikiText( 'search-error' ) ) . '</div>' );
@@ -419,7 +427,7 @@ class SpecialSearch extends SpecialPage {
                }
                $out->addHtml( "</div>" );
 
-               if( $num || $this->offset ) {
+               if ( $num || $this->offset ) {
                        $out->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
                }
                wfRunHooks( 'SpecialSearchResultsAppend', array( $this, $out, $term ) );
@@ -433,16 +441,16 @@ class SpecialSearch extends SpecialPage {
                // 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() === '' ) {
                        // invalid title
                        // preserve the paragraph for margins etc...
                        $this->getOutput()->addHtml( '<p></p>' );
                        return;
                }
 
-               if( $t->isKnown() ) {
+               if ( $t->isKnown() ) {
                        $messageName = 'searchmenu-exists';
-               } elseif( $t->userCan( 'create', $this->getUser() ) ) {
+               } elseif ( $t->userCan( 'create', $this->getUser() ) ) {
                        $messageName = 'searchmenu-new';
                } else {
                        $messageName = 'searchmenu-new-nocreate';
@@ -451,7 +459,7 @@ class SpecialSearch extends SpecialPage {
                wfRunHooks( 'SpecialSearchCreateLink', array( $t, &$params ) );
 
                // Extensions using the hook might still return an empty $messageName
-               if( $messageName ) {
+               if ( $messageName ) {
                        $this->getOutput()->wrapWikiMsg( "<p class=\"mw-search-createlink\">\n$1</p>", $params );
                } else {
                        // preserve the paragraph for margins etc...
@@ -464,9 +472,9 @@ class SpecialSearch extends SpecialPage {
         */
        protected function setupPage( $term ) {
                # Should advanced UI be used?
-               $this->searchAdvanced = ($this->profile === 'advanced');
+               $this->searchAdvanced = ( $this->profile === 'advanced' );
                $out = $this->getOutput();
-               if( strval( $term ) !== '' ) {
+               if ( strval( $term ) !== '' ) {
                        $out->setPageTitle( $this->msg( 'searchresults' ) );
                        $out->setHTMLTitle( $this->msg( 'pagetitle' )->rawParams(
                                $this->msg( 'searchresults-title' )->rawParams( $term )->text()
@@ -485,8 +493,8 @@ class SpecialSearch extends SpecialPage {
         */
        protected function powerSearch( &$request ) {
                $arr = array();
-               foreach( SearchEngine::searchableNamespaces() as $ns => $name ) {
-                       if( $request->getCheck( 'ns' . $ns ) ) {
+               foreach ( SearchEngine::searchableNamespaces() as $ns => $name ) {
+                       if ( $request->getCheck( 'ns' . $ns ) ) {
                                $arr[] = $ns;
                        }
                }
@@ -502,10 +510,10 @@ class SpecialSearch extends SpecialPage {
        protected function powerSearchOptions() {
                $opt = array();
                $opt['redirs'] = $this->searchRedirects ? 1 : 0;
-               if( $this->profile !== 'advanced' ) {
+               if ( $this->profile !== 'advanced' ) {
                        $opt['profile'] = $this->profile;
                } else {
-                       foreach( $this->namespaces as $n ) {
+                       foreach ( $this->namespaces as $n ) {
                                $opt['ns' . $n] = 1;
                        }
                }
@@ -527,12 +535,12 @@ class SpecialSearch extends SpecialPage {
 
                $out = "";
                $infoLine = $matches->getInfo();
-               if( !is_null( $infoLine ) ) {
+               if ( !is_null( $infoLine ) ) {
                        $out .= "\n<!-- {$infoLine} -->\n";
                }
                $out .= "<ul class='mw-search-results'>\n";
                $result = $matches->next();
-               while( $result ) {
+               while ( $result ) {
                        $out .= $this->showHit( $result, $terms );
                        $result = $matches->next();
                }
@@ -555,7 +563,7 @@ class SpecialSearch extends SpecialPage {
        protected function showHit( $result, $terms ) {
                wfProfileIn( __METHOD__ );
 
-               if( $result->isBrokenTitle() ) {
+               if ( $result->isBrokenTitle() ) {
                        wfProfileOut( __METHOD__ );
                        return "<!-- Broken link in search result -->\n";
                }
@@ -564,8 +572,9 @@ class SpecialSearch extends SpecialPage {
 
                $titleSnippet = $result->getTitleSnippet( $terms );
 
-               if( $titleSnippet == '' )
+               if ( $titleSnippet == '' ) {
                        $titleSnippet = null;
+               }
 
                $link_t = clone $t;
 
@@ -580,7 +589,7 @@ class SpecialSearch extends SpecialPage {
                //If page content is not readable, just return the title.
                //This is not quite safe, but better than showing excerpts from non-readable pages
                //Note that hiding the entry entirely would screw up paging.
-               if( !$t->userCan( 'read', $this->getUser() ) ) {
+               if ( !$t->userCan( 'read', $this->getUser() ) ) {
                        wfProfileOut( __METHOD__ );
                        return "<li>{$link}</li>\n";
                }
@@ -588,7 +597,7 @@ class SpecialSearch extends SpecialPage {
                // If the page doesn't *exist*... our search index is out of date.
                // The least confusing at this point is to drop the result.
                // You may get less results, but... oh well. :P
-               if( $result->isMissingRevision() ) {
+               if ( $result->isMissingRevision() ) {
                        wfProfileOut( __METHOD__ );
                        return "<!-- missing page " . htmlspecialchars( $t->getPrefixedText() ) . "-->\n";
                }
@@ -600,9 +609,10 @@ class SpecialSearch extends SpecialPage {
                $sectionText = $result->getSectionSnippet( $terms );
                $redirect = '';
 
-               if( !is_null( $redirectTitle ) ) {
-                       if( $redirectText == '' )
+               if ( !is_null( $redirectTitle ) ) {
+                       if ( $redirectText == '' ) {
                                $redirectText = null;
+                       }
 
                        $redirect = "<span class='searchalttitle'>" .
                                $this->msg( 'search-redirect' )->rawParams(
@@ -612,9 +622,10 @@ class SpecialSearch extends SpecialPage {
 
                $section = '';
 
-               if( !is_null( $sectionTitle ) ) {
-                       if( $sectionText == '' )
+               if ( !is_null( $sectionTitle ) ) {
+                       if ( $sectionText == '' ) {
                                $sectionText = null;
+                       }
 
                        $section = "<span class='searchalttitle'>" .
                                $this->msg( 'search-section' )->rawParams(
@@ -628,7 +639,7 @@ class SpecialSearch extends SpecialPage {
                $lang = $this->getLanguage();
 
                // format score
-               if( is_null( $result->getScore() ) ) {
+               if ( is_null( $result->getScore() ) ) {
                        // Search engine doesn't report scoring info
                        $score = '';
                } else {
@@ -644,7 +655,7 @@ class SpecialSearch extends SpecialPage {
                $size = $this->msg( 'search-result-size', $lang->formatSize( $byteSize ) )
                        ->numParams( $wordCount )->escaped();
 
-               if( $t->getNamespace() == NS_CATEGORY ) {
+               if ( $t->getNamespace() == NS_CATEGORY ) {
                        $cat = Category::newFromTitle( $t );
                        $size = $this->msg( 'search-result-category-size' )
                                ->numParams( $cat->getPageCount(), $cat->getSubcatCount(), $cat->getFileCount() )
@@ -655,7 +666,7 @@ class SpecialSearch extends SpecialPage {
 
                // link to related articles if supported
                $related = '';
-               if( $result->hasRelated() ) {
+               if ( $result->hasRelated() ) {
                        $st = SpecialPage::getTitleFor( 'Search' );
                        $stParams = array_merge(
                                $this->powerSearchOptions(),
@@ -675,11 +686,11 @@ class SpecialSearch extends SpecialPage {
                }
 
                // Include a thumbnail for media files...
-               if( $t->getNamespace() == NS_FILE ) {
+               if ( $t->getNamespace() == NS_FILE ) {
                        $img = wfFindFile( $t );
-                       if( $img ) {
+                       if ( $img ) {
                                $thumb = $img->transform( array( 'width' => 120, 'height' => 120 ) );
-                               if( $thumb ) {
+                               if ( $thumb ) {
                                        $desc = $this->msg( 'parentheses' )->rawParams( $img->getShortDesc() )->escaped();
                                        wfProfileOut( __METHOD__ );
                                        // Float doesn't seem to interact well with the bullets.
@@ -705,7 +716,7 @@ class SpecialSearch extends SpecialPage {
 
                $html = null;
 
-               if ( wfRunHooks( 'ShowSearchHit', array (
+               if ( wfRunHooks( 'ShowSearchHit', array(
                        $this, $result, $terms,
                        &$link, &$redirect, &$section, &$extract,
                        &$score, &$size, &$date, &$related,
@@ -728,28 +739,28 @@ 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() );
 
-               $out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>".
+               $out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>" .
                        $this->msg( 'search-interwiki-caption' )->text() . "</div>\n";
                $out .= "<ul class='mw-search-iwresults'>\n";
 
                // work out custom project captions
                $customCaptions = array();
                $customLines = explode( "\n", $this->msg( 'search-interwiki-custom' )->text() ); // format per line <iwprefix>:<caption>
-               foreach( $customLines as $line ) {
+               foreach ( $customLines as $line ) {
                        $parts = explode( ":", $line, 2 );
-                       if( count( $parts ) == 2 ) { // validate line
+                       if ( count( $parts ) == 2 ) { // validate line
                                $customCaptions[$parts[0]] = $parts[1];
                        }
                }
 
                $prev = null;
                $result = $matches->next();
-               while( $result ) {
+               while ( $result ) {
                        $out .= $this->showInterwikiHit( $result, $prev, $terms, $query, $customCaptions );
                        $prev = $result->getInterwikiPrefix();
                        $result = $matches->next();
@@ -774,10 +785,10 @@ class SpecialSearch extends SpecialPage {
         *
         * @return string
         */
-       protected function showInterwikiHit( $result, $lastInterwiki, $terms, $query, $customCaptions) {
+       protected function showInterwikiHit( $result, $lastInterwiki, $terms, $query, $customCaptions ) {
                wfProfileIn( __METHOD__ );
 
-               if( $result->isBrokenTitle() ) {
+               if ( $result->isBrokenTitle() ) {
                        wfProfileOut( __METHOD__ );
                        return "<!-- Broken link in search result -->\n";
                }
@@ -786,8 +797,9 @@ class SpecialSearch extends SpecialPage {
 
                $titleSnippet = $result->getTitleSnippet( $terms );
 
-               if( $titleSnippet == '' )
+               if ( $titleSnippet == '' ) {
                        $titleSnippet = null;
+               }
 
                $link = Linker::linkKnown(
                        $t,
@@ -798,9 +810,10 @@ class SpecialSearch extends SpecialPage {
                $redirectTitle = $result->getRedirectTitle();
                $redirectText = $result->getRedirectSnippet( $terms );
                $redirect = '';
-               if( !is_null( $redirectTitle ) ) {
-                       if( $redirectText == '' )
+               if ( !is_null( $redirectTitle ) ) {
+                       if ( $redirectText == '' ) {
                                $redirectText = null;
+                       }
 
                        $redirect = "<span class='searchalttitle'>" .
                                $this->msg( 'search-redirect' )->rawParams(
@@ -810,8 +823,8 @@ class SpecialSearch extends SpecialPage {
 
                $out = "";
                // display project name
-               if( is_null( $lastInterwiki ) || $lastInterwiki != $t->getInterwiki() ) {
-                       if( array_key_exists( $t->getInterwiki(), $customCaptions ) ) {
+               if ( is_null( $lastInterwiki ) || $lastInterwiki != $t->getInterwiki() ) {
+                       if ( array_key_exists( $t->getInterwiki(), $customCaptions ) ) {
                                // captions from 'search-interwiki-custom'
                                $caption = $customCaptions[$t->getInterwiki()];
                        } else {
@@ -868,17 +881,21 @@ 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 ) {
+               foreach ( SearchEngine::searchableNamespaces() as $namespace => $name ) {
                        $subject = MWNamespace::getSubject( $namespace );
-                       if( !array_key_exists( $subject, $rows ) ) {
+                       if ( !array_key_exists( $subject, $rows ) ) {
                                $rows[$subject] = "";
                        }
-                       $name = str_replace( '_', ' ', $name );
-                       if( $name == '' ) {
+
+                       $name = $wgContLang->getConverter()->convertNamespace( $namespace );
+                       if ( $name == '' ) {
                                $name = $this->msg( 'blanknamespace' )->text();
                        }
+
                        $rows[$subject] .=
                                Xml::openElement(
                                        'td', array( 'style' => 'white-space: nowrap' )
@@ -891,27 +908,30 @@ class SpecialSearch extends SpecialPage {
                                ) .
                                Xml::closeElement( 'td' );
                }
+
                $rows = array_values( $rows );
                $numRows = count( $rows );
 
                // Lays out namespaces in multiple floating two-column tables so they'll
                // be arranged nicely while still accommodating different screen widths
                $namespaceTables = '';
-               for( $i = 0; $i < $numRows; $i += 4 ) {
+               for ( $i = 0; $i < $numRows; $i += 4 ) {
                        $namespaceTables .= Xml::openElement(
                                'table',
                                array( 'cellpadding' => 0, 'cellspacing' => 0 )
                        );
-                       for( $j = $i; $j < $i + 4 && $j < $numRows; $j++ ) {
+
+                       for ( $j = $i; $j < $i + 4 && $j < $numRows; $j++ ) {
                                $namespaceTables .= Xml::tags( 'tr', null, $rows[$j] );
                        }
+
                        $namespaceTables .= Xml::closeElement( 'table' );
                }
 
                $showSections = array( 'namespaceTables' => $namespaceTables );
 
                // Show redirects check only if backend supports it
-               if( $this->getSearchEngine()->supports( 'list-redirects' ) ) {
+               if ( $this->getSearchEngine()->supports( 'list-redirects' ) ) {
                        $showSections['redirects'] =
                                Xml::checkLabel( $this->msg( 'powersearch-redir' )->text(), 'redirs', 'redirs', $this->searchRedirects );
                }
@@ -920,7 +940,7 @@ class SpecialSearch extends SpecialPage {
 
                $hidden = '';
                unset( $opts['redirs'] );
-               foreach( $opts as $key => $value ) {
+               foreach ( $opts as $key => $value ) {
                        $hidden .= Html::hidden( $key, $value );
                }
                // Return final output
@@ -980,8 +1000,10 @@ class SpecialSearch extends SpecialPage {
 
                wfRunHooks( 'SpecialSearchProfiles', array( &$profiles ) );
 
-               foreach( $profiles as &$data ) {
-                       if ( !is_array( $data['namespaces'] ) ) continue;
+               foreach ( $profiles as &$data ) {
+                       if ( !is_array( $data['namespaces'] ) ) {
+                               continue;
+                       }
                        sort( $data['namespaces'] );
                }
 
@@ -998,7 +1020,7 @@ class SpecialSearch extends SpecialPage {
                $out = Xml::openElement( 'div', array( 'class' => 'mw-search-formheader' ) );
 
                $bareterm = $term;
-               if( $this->startsWithImage( $term ) ) {
+               if ( $this->startsWithImage( $term ) ) {
                        // Deletes prefixes
                        $bareterm = substr( $term, strpos( $term, ':' ) + 1 );
                }
@@ -1073,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;
        }
 
@@ -1092,7 +1118,7 @@ class SpecialSearch extends SpecialPage {
         */
        protected function makeSearchLink( $term, $namespaces, $label, $tooltip, $params = array() ) {
                $opt = $params;
-               foreach( $namespaces as $n ) {
+               foreach ( $namespaces as $n ) {
                        $opt['ns' . $n] = 1;
                }
                $opt['redirs'] = $this->searchRedirects;
@@ -1125,7 +1151,7 @@ class SpecialSearch extends SpecialPage {
                global $wgContLang;
 
                $p = explode( ':', $term );
-               if( count( $p ) > 1 ) {
+               if ( count( $p ) > 1 ) {
                        return $wgContLang->getNsIndex( $p[0] ) == NS_FILE;
                }
                return false;
@@ -1142,7 +1168,7 @@ class SpecialSearch extends SpecialPage {
                $allkeyword = $this->msg( 'searchall' )->inContentLanguage()->text();
 
                $p = explode( ':', $term );
-               if( count( $p ) > 1 ) {
+               if ( count( $p ) > 1 ) {
                        return $p[0] == $allkeyword;
                }
                return false;
@@ -1155,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;
        }
@@ -1174,6 +1201,6 @@ class SpecialSearch extends SpecialPage {
        }
 
        protected function getGroupName() {
-               return 'redirects';
+               return 'pages';
        }
 }