Merge "Use Xml::element instead of Html::element for empty elements"
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
index 423b875..71cd9ba 100644 (file)
@@ -186,12 +186,11 @@ class SpecialSearch extends SpecialPage {
                # No match, generate an edit URL
                $title = Title::newFromText( $term );
                if ( !is_null( $title ) ) {
-                       global $wgGoToEdit;
                        wfRunHooks( 'SpecialSearchNogomatch', array( &$title ) );
                        wfDebugLog( 'nogomatch', $title->getFullText(), 'private' );
 
                        # If the feature is enabled, go straight to the edit page
-                       if ( $wgGoToEdit ) {
+                       if ( $this->getConfig()->get( 'GoToEdit' ) ) {
                                $this->getOutput()->redirect( $title->getFullURL( array( 'action' => 'edit' ) ) );
 
                                return;
@@ -204,7 +203,7 @@ class SpecialSearch extends SpecialPage {
         * @param string $term
         */
        public function showResults( $term ) {
-               global $wgDisableTextSearch, $wgSearchForwardUrl, $wgContLang, $wgScript;
+               global $wgContLang;
 
                $profile = new ProfileSection( __METHOD__ );
                $search = $this->getSearchEngine();
@@ -220,9 +219,10 @@ class SpecialSearch extends SpecialPage {
 
                $out = $this->getOutput();
 
-               if ( $wgDisableTextSearch ) {
-                       if ( $wgSearchForwardUrl ) {
-                               $url = str_replace( '$1', urlencode( $term ), $wgSearchForwardUrl );
+               if ( $this->getConfig()->get( 'DisableTextSearch' ) ) {
+                       $searchFowardUrl = $this->getConfig()->get( 'SearchForwardUrl' );
+                       if ( $searchFowardUrl ) {
+                               $url = str_replace( '$1', urlencode( $term ), $searchFowardUrl );
                                $out->redirect( $url );
                        } else {
                                $out->addHTML(
@@ -304,7 +304,7 @@ class SpecialSearch extends SpecialPage {
                                array(
                                        'id' => ( $this->profile === 'advanced' ? 'powersearch' : 'search' ),
                                        'method' => 'get',
-                                       'action' => $wgScript
+                                       'action' => wfScript(),
                                )
                        )
                );
@@ -347,6 +347,9 @@ class SpecialSearch extends SpecialPage {
                        // Show the create link ahead
                        $this->showCreateLink( $title, $num, $titleMatches, $textMatches );
                        if ( $totalRes > $this->limit || $this->offset ) {
+                               if ( $this->searchEngineType !== null ) {
+                                       $this->setExtraParam( 'srbackend', $this->searchEngineType );
+                               }
                                $prevnext = $this->getLanguage()->viewPrevNext(
                                        $this->getPageTitle(),
                                        $this->offset,
@@ -648,16 +651,6 @@ class SpecialSearch extends SpecialPage {
 
                $lang = $this->getLanguage();
 
-               // format score
-               if ( is_null( $result->getScore() ) ) {
-                       // Search engine doesn't report scoring info
-                       $score = '';
-               } else {
-                       $percent = sprintf( '%2.1f', $result->getScore() * 100 );
-                       $score = $this->msg( 'search-result-score' )->numParams( $percent )->text()
-                               . ' - ';
-               }
-
                // format description
                $byteSize = $result->getByteSize();
                $wordCount = $result->getWordCount();
@@ -719,7 +712,7 @@ class SpecialSearch extends SpecialPage {
                                                '<td style="vertical-align: top;">' .
                                                "{$link} {$redirect} {$section} {$fileMatch}" .
                                                $extract .
-                                               "<div class='mw-search-result-data'>{$score}{$desc} - {$date}{$related}</div>" .
+                                               "<div class='mw-search-result-data'>{$desc} - {$date}{$related}</div>" .
                                                '</td>' .
                                                '</tr>' .
                                                '</table>' .
@@ -730,6 +723,7 @@ class SpecialSearch extends SpecialPage {
 
                $html = null;
 
+               $score = '';
                if ( wfRunHooks( 'ShowSearchHit', array(
                        $this, $result, $terms,
                        &$link, &$redirect, &$section, &$extract,
@@ -738,7 +732,7 @@ class SpecialSearch extends SpecialPage {
                ) ) ) {
                        $html = "<li><div class='mw-search-result-heading'>" .
                                "{$link} {$redirect} {$section} {$fileMatch}</div> {$extract}\n" .
-                               "<div class='mw-search-result-data'>{$score}{$size} - {$date}{$related}</div>" .
+                               "<div class='mw-search-result-data'>{$size} - {$date}{$related}</div>" .
                                "</li>\n";
                }
 
@@ -957,7 +951,7 @@ class SpecialSearch extends SpecialPage {
                return Xml::openElement( 'fieldset', array( 'id' => 'mw-searchoptions' ) ) .
                        Xml::element( 'legend', null, $this->msg( 'powersearch-legend' )->text() ) .
                        Xml::tags( 'h4', null, $this->msg( 'powersearch-ns' )->parse() ) .
-                       Html::element( 'div', array( 'id' => 'mw-search-togglebox' ) ) .
+                       Xml::element( 'div', array( 'id' => 'mw-search-togglebox' ), '', false ) .
                        Xml::element( 'div', array( 'class' => 'divider' ), '', false ) .
                        implode( Xml::element( 'div', array( 'class' => 'divider' ), '', false ), $showSections ) .
                        $hidden .
@@ -1074,6 +1068,8 @@ class SpecialSearch extends SpecialPage {
 
        /**
         * @param string $term
+        * @param int $resultsShown
+        * @param int $totalNum
         * @return string
         */
        protected function shortDialog( $term, $resultsShown, $totalNum ) {