Localisation updates from https://translatewiki.net.
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
index c77c786..55be2c2 100644 (file)
@@ -63,7 +63,7 @@ class SpecialSearch extends SpecialPage {
        /**
         * @var string
         */
-       protected $didYouMeanHtml, $fulltext;
+       protected $fulltext;
 
        const NAMESPACES_CURRENT = 'sense';
 
@@ -165,7 +165,6 @@ class SpecialSearch extends SpecialPage {
                        }
                }
 
-               $this->didYouMeanHtml = ''; # html of did you mean... link
                $this->fulltext = $request->getVal( 'fulltext' );
                $this->profile = $profile;
        }
@@ -207,12 +206,12 @@ class SpecialSearch extends SpecialPage {
        public function showResults( $term ) {
                global $wgContLang;
 
-               $profile = new ProfileSection( __METHOD__ );
                $search = $this->getSearchEngine();
                $search->setLimitOffset( $this->limit, $this->offset );
                $search->setNamespaces( $this->namespaces );
                $search->prefix = $this->mPrefix;
                $term = $search->transformSearchTerm( $term );
+               $didYouMeanHtml = '';
 
                Hooks::run( 'SpecialSearchSetupEngine', array( $this, $this->profile, $search ) );
 
@@ -289,8 +288,11 @@ class SpecialSearch extends SpecialPage {
                                $stParams
                        );
 
-                       $this->didYouMeanHtml = '<div class="searchdidyoumean">'
-                               . $this->msg( 'search-suggest' )->rawParams( $suggestLink )->text() . '</div>';
+                       # html of did you mean... search suggestion link
+                       $didYouMeanHtml =
+                               Xml::openElement( 'div', array( 'class' => 'searchdidyoumean' ) ) .
+                               $this->msg( 'search-suggest' )->rawParams( $suggestLink )->text() .
+                               Xml::closeElement( 'div' );
                }
 
                if ( !Hooks::run( 'SpecialSearchResultsPrepend', array( $this, $out, $term ) ) ) {
@@ -303,7 +305,7 @@ class SpecialSearch extends SpecialPage {
                        Xml::openElement(
                                'form',
                                array(
-                                       'id' => ( $this->profile === 'advanced' ? 'powersearch' : 'search' ),
+                                       'id' => ( $this->isPowerSearch() ? 'powersearch' : 'search' ),
                                        'method' => 'get',
                                        'action' => wfScript(),
                                )
@@ -330,9 +332,10 @@ class SpecialSearch extends SpecialPage {
                        Xml::openElement( 'div', array( 'id' => 'mw-search-top-table' ) ) .
                        $this->shortDialog( $term, $num, $totalRes ) .
                        Xml::closeElement( 'div' ) .
+                       $this->searchProfileTabs( $term ) .
+                       $this->searchOptions( $term ) .
                        Xml::closeElement( 'form' ) .
-                       $this->didYouMeanHtml .
-                       $this->searchProfileTabs( $term )
+                       $didYouMeanHtml
                );
 
                $filePrefix = $wgContLang->getFormattedNsText( NS_FILE ) . ':';
@@ -459,8 +462,6 @@ class SpecialSearch extends SpecialPage {
         * @param string $term
         */
        protected function setupPage( $term ) {
-               # Should advanced UI be used?
-               $this->searchAdvanced = ( $this->profile === 'advanced' );
                $out = $this->getOutput();
                if ( strval( $term ) !== '' ) {
                        $out->setPageTitle( $this->msg( 'searchresults' ) );
@@ -473,6 +474,15 @@ class SpecialSearch extends SpecialPage {
                $out->addModules( 'mediawiki.special.search' );
        }
 
+       /**
+        * Return true if current search is a power (advanced) search
+        *
+        * @return bool
+        */
+       protected function isPowerSearch() {
+               return $this->profile === 'advanced';
+       }
+
        /**
         * Extract "power search" namespace settings from the request object,
         * returning a list of index numbers to search.
@@ -498,7 +508,7 @@ class SpecialSearch extends SpecialPage {
         */
        protected function powerSearchOptions() {
                $opt = array();
-               if ( $this->profile !== 'advanced' ) {
+               if ( !$this->isPowerSearch() ) {
                        $opt['profile'] = $this->profile;
                } else {
                        foreach ( $this->namespaces as $n ) {
@@ -553,7 +563,6 @@ class SpecialSearch extends SpecialPage {
        protected function showMatches( &$matches ) {
                global $wgContLang;
 
-               $profile = new ProfileSection( __METHOD__ );
                $terms = $wgContLang->convertForSearchResult( $matches->termMatches() );
 
                $out = "<ul class='mw-search-results'>\n";
@@ -579,7 +588,6 @@ class SpecialSearch extends SpecialPage {
         * @return string
         */
        protected function showHit( $result, $terms ) {
-               $profile = new ProfileSection( __METHOD__ );
 
                if ( $result->isBrokenTitle() ) {
                        return '';
@@ -738,7 +746,6 @@ class SpecialSearch extends SpecialPage {
         */
        protected function showInterwiki( $matches, $query ) {
                global $wgContLang;
-               $profile = new ProfileSection( __METHOD__ );
 
                $out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>" .
                        $this->msg( 'search-interwiki-caption' )->text() . "</div>\n";
@@ -789,7 +796,6 @@ class SpecialSearch extends SpecialPage {
         * @return string
         */
        protected function showInterwikiHit( $result, $lastInterwiki, $query, $customCaptions ) {
-               $profile = new ProfileSection( __METHOD__ );
 
                if ( $result->isBrokenTitle() ) {
                        return '';
@@ -1036,11 +1042,19 @@ class SpecialSearch extends SpecialPage {
                $out .= Xml::element( 'div', array( 'style' => 'clear:both' ), '', false );
                $out .= Xml::closeElement( 'div' );
 
-               // Hidden stuff
+               return $out;
+       }
+
+       /**
+        * @param string $term Search term
+        * @return string
+        */
+       protected function searchOptions( $term ) {
+               $out = '';
                $opts = array();
                $opts['profile'] = $this->profile;
 
-               if ( $this->profile === 'advanced' ) {
+               if ( $this->isPowerSearch() ) {
                        $out .= $this->powerSearchBox( $term, $opts );
                } else {
                        $form = '';
@@ -1062,9 +1076,9 @@ class SpecialSearch extends SpecialPage {
                $out .= Html::hidden( 'profile', $this->profile ) . "\n";
                // Term box
                $out .= Html::input( 'search', $term, 'search', array(
-                       'id' => $this->profile === 'advanced' ? 'powerSearchText' : 'searchText',
+                       'id' => $this->isPowerSearch() ? 'powerSearchText' : 'searchText',
                        'size' => '50',
-                       'autofocus',
+                       'autofocus' => trim( $term ) === '',
                        'class' => 'mw-ui-input mw-ui-input-inline',
                ) ) . "\n";
                $out .= Html::hidden( 'fulltext', 'Search' ) . "\n";