Merge "Remove "include redirects" option from search"
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
index aea8f17..c73ee53 100644 (file)
@@ -60,11 +60,6 @@ class SpecialSearch extends SpecialPage {
         */
        protected $namespaces;
 
-       /**
-        * @var bool
-        */
-       protected $searchRedirects;
-
        /**
         * @var string
         */
@@ -159,9 +154,6 @@ class SpecialSearch extends SpecialPage {
                        }
                }
 
-               // Redirects defaults to true, but we don't know whether it was ticked of or just missing
-               $default = $request->getBool( 'profile' ) ? 0 : 1;
-               $this->searchRedirects = $request->getBool( 'redirs', $default ) ? 1 : 0;
                $this->didYouMeanHtml = ''; # html of did you mean... link
                $this->fulltext = $request->getVal( 'fulltext' );
                $this->profile = $profile;
@@ -179,6 +171,7 @@ class SpecialSearch extends SpecialPage {
                # If the string cannot be used to create a title
                if ( is_null( $t ) ) {
                        $this->showResults( $term );
+
                        return;
                }
                # If there's an exact or very near match, jump right there.
@@ -191,6 +184,7 @@ class SpecialSearch extends SpecialPage {
 
                if ( !is_null( $t ) ) {
                        $this->getOutput()->redirect( $t->getFullURL() );
+
                        return;
                }
                # No match, generate an edit URL
@@ -203,6 +197,7 @@ class SpecialSearch extends SpecialPage {
                        # If the feature is enabled, go straight to the edit page
                        if ( $wgGoToEdit ) {
                                $this->getOutput()->redirect( $t->getFullURL( array( 'action' => 'edit' ) ) );
+
                                return;
                        }
                }
@@ -219,8 +214,6 @@ class SpecialSearch extends SpecialPage {
                $search = $this->getSearchEngine();
                $search->setLimitOffset( $this->limit, $this->offset );
                $search->setNamespaces( $this->namespaces );
-               $search->showRedirects = $this->searchRedirects; // BC
-               $search->setFeatureData( 'list-redirects', $this->searchRedirects );
                $search->prefix = $this->mPrefix;
                $term = $search->transformSearchTerm( $term );
 
@@ -247,6 +240,7 @@ class SpecialSearch extends SpecialPage {
                                        Xml::closeElement( 'fieldset' )
                                );
                        }
+
                        return;
                }
 
@@ -328,6 +322,7 @@ class SpecialSearch extends SpecialPage {
                // Sometimes the search engine knows there are too many hits
                if ( $titleMatches instanceof SearchResultTooMany ) {
                        $out->wrapWikiMsg( "==$1==\n", 'toomanymatches' );
+
                        return;
                }
 
@@ -336,6 +331,7 @@ class SpecialSearch extends SpecialPage {
                        $out->addHTML( $this->formHeader( $term, 0, 0 ) );
                        $out->addHtml( $this->getProfileForm( $this->profile, $term ) );
                        $out->addHTML( '</form>' );
+
                        // Empty query -- straight view of search form
                        return;
                }
@@ -438,12 +434,14 @@ 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() === '' ||
-                               ( $titleMatches !== null && $titleMatches->searchContainedSyntax() ) ||
-                               ( $textMatches !== null && $textMatches->searchContainedSyntax() ) ) {
+               if ( is_null( $t ) || $t->getDBkey() === ''
+                       || ( $titleMatches !== null && $titleMatches->searchContainedSyntax() )
+                       || ( $textMatches !== null && $textMatches->searchContainedSyntax() )
+               ) {
                        // invalid title
                        // preserve the paragraph for margins etc...
                        $this->getOutput()->addHtml( '<p></p>' );
+
                        return;
                }
 
@@ -509,7 +507,6 @@ class SpecialSearch extends SpecialPage {
         */
        protected function powerSearchOptions() {
                $opt = array();
-               $opt['redirs'] = $this->searchRedirects ? 1 : 0;
                if ( $this->profile !== 'advanced' ) {
                        $opt['profile'] = $this->profile;
                } else {
@@ -517,6 +514,7 @@ class SpecialSearch extends SpecialPage {
                                $opt['ns' . $n] = 1;
                        }
                }
+
                return $opt + $this->extraParams;
        }
 
@@ -573,7 +571,7 @@ class SpecialSearch extends SpecialPage {
                $link_t = clone $t;
 
                wfRunHooks( 'ShowSearchHitTitle',
-                                       array( &$link_t, &$titleSnippet, $result, $terms, $this ) );
+                       array( &$link_t, &$titleSnippet, $result, $terms, $this ) );
 
                $link = Linker::linkKnown(
                        $link_t,
@@ -850,6 +848,7 @@ class SpecialSearch extends SpecialPage {
                }
 
                $out .= "<li>{$link} {$redirect}</li>\n";
+
                return $out;
        }
 
@@ -861,7 +860,6 @@ class SpecialSearch extends SpecialPage {
        protected function getProfileForm( $profile, $term ) {
                // Hidden stuff
                $opts = array();
-               $opts['redirs'] = $this->searchRedirects;
                $opts['profile'] = $this->profile;
 
                if ( $profile === 'advanced' ) {
@@ -869,6 +867,7 @@ class SpecialSearch extends SpecialPage {
                } else {
                        $form = '';
                        wfRunHooks( 'SpecialSearchProfileForm', array( $this, &$form, $profile, $term, $opts ) );
+
                        return $form;
                }
        }
@@ -930,24 +929,18 @@ class SpecialSearch extends SpecialPage {
 
                $showSections = array( 'namespaceTables' => $namespaceTables );
 
-               // Show redirects check only if backend supports it
-               if ( $this->getSearchEngine()->supports( 'list-redirects' ) ) {
-                       $showSections['redirects'] =
-                               Xml::checkLabel( $this->msg( 'powersearch-redir' )->text(), 'redirs', 'redirs', $this->searchRedirects );
-               }
-
                wfRunHooks( 'SpecialSearchPowerBox', array( &$showSections, $term, $opts ) );
 
                $hidden = '';
-               unset( $opts['redirs'] );
                foreach ( $opts as $key => $value ) {
                        $hidden .= Html::hidden( $key, $value );
                }
+
                // Return final output
                return Xml::openElement(
-                               'fieldset',
-                               array( 'id' => 'mw-searchoptions', 'style' => 'margin:0em;' )
-                       ) .
+                       'fieldset',
+                       array( 'id' => 'mw-searchoptions', 'style' => 'margin:0em;' )
+               ) .
                        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' ) ) .
@@ -1103,6 +1096,7 @@ class SpecialSearch extends SpecialPage {
                        $this->msg( 'searchbutton' )->text(),
                        array( 'class' => array( 'mw-ui-button', 'mw-ui-progressive' ) )
                ) . "\n";
+
                return $out . $this->didYouMeanHtml;
        }
 
@@ -1121,7 +1115,6 @@ class SpecialSearch extends SpecialPage {
                foreach ( $namespaces as $n ) {
                        $opt['ns' . $n] = 1;
                }
-               $opt['redirs'] = $this->searchRedirects;
 
                $stParams = array_merge(
                        array(
@@ -1154,6 +1147,7 @@ class SpecialSearch extends SpecialPage {
                if ( count( $p ) > 1 ) {
                        return $wgContLang->getNsIndex( $p[0] ) == NS_FILE;
                }
+
                return false;
        }
 
@@ -1171,6 +1165,7 @@ class SpecialSearch extends SpecialPage {
                if ( count( $p ) > 1 ) {
                        return $p[0] == $allkeyword;
                }
+
                return false;
        }
 
@@ -1184,6 +1179,7 @@ class SpecialSearch extends SpecialPage {
                        $this->searchEngine = $this->searchEngineType ?
                                SearchEngine::create( $this->searchEngineType ) : SearchEngine::create();
                }
+
                return $this->searchEngine;
        }