Merge "Make update.php file executable"
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
index 61bb1cd..2713a5f 100644 (file)
@@ -226,7 +226,11 @@ class SpecialSearch extends SpecialPage {
                                $out->addHTML(
                                        Xml::openElement( 'fieldset' ) .
                                        Xml::element( 'legend', null, $this->msg( 'search-external' )->text() ) .
-                                       Xml::element( 'p', array( 'class' => 'mw-searchdisabled' ), $this->msg( 'searchdisabled' )->text() ) .
+                                       Xml::element(
+                                               'p',
+                                               array( 'class' => 'mw-searchdisabled' ),
+                                               $this->msg( 'searchdisabled' )->text()
+                                       ) .
                                        $this->msg( 'googlesearch' )->rawParams(
                                                htmlspecialchars( $term ),
                                                'UTF-8',
@@ -259,8 +263,6 @@ class SpecialSearch extends SpecialPage {
 
                // did you mean... suggestions
                if ( $showSuggestion && $textMatches && !$textStatus && $textMatches->hasSuggestion() ) {
-                       $st = SpecialPage::getTitleFor( 'Search' );
-
                        # mirror Go/Search behavior of original request ..
                        $didYouMeanParams = array( 'search' => $textMatches->getSuggestionQuery() );
 
@@ -280,13 +282,14 @@ class SpecialSearch extends SpecialPage {
                        }
 
                        $suggestLink = Linker::linkKnown(
-                               $st,
+                               $this->getPageTitle(),
                                $suggestionSnippet,
                                array(),
                                $stParams
                        );
 
-                       $this->didYouMeanHtml = '<div class="searchdidyoumean">' . $this->msg( 'search-suggest' )->rawParams( $suggestLink )->text() . '</div>';
+                       $this->didYouMeanHtml = '<div class="searchdidyoumean">'
+                               . $this->msg( 'search-suggest' )->rawParams( $suggestLink )->text() . '</div>';
                }
 
                if ( !wfRunHooks( 'SpecialSearchResultsPrepend', array( $this, $out, $term ) ) ) {
@@ -360,14 +363,19 @@ class SpecialSearch extends SpecialPage {
                $out->addHtml( "<div class='searchresults'>" );
 
                // prev/next links
+               $prevnext = null;
                if ( $num || $this->offset ) {
                        // Show the create link ahead
                        $this->showCreateLink( $title, $num, $titleMatches, $textMatches );
-                       $prevnext = $this->getLanguage()->viewPrevNext( $this->getPageTitle(), $this->offset, $this->limit,
-                               $this->powerSearchOptions() + array( 'search' => $term ),
-                               max( $titleMatchesNum, $textMatchesNum ) < $this->limit
-                       );
-                       //$out->addHTML( "<p class='mw-search-pager-top'>{$prevnext}</p>\n" );
+                       if ( $totalRes > $this->limit || $this->offset ) {
+                               $prevnext = $this->getLanguage()->viewPrevNext(
+                                       $this->getPageTitle(),
+                                       $this->offset,
+                                       $this->limit,
+                                       $this->powerSearchOptions() + array( 'search' => $term ),
+                                       max( $titleMatchesNum, $textMatchesNum ) < $this->limit
+                               );
+                       }
                        wfRunHooks( 'SpecialSearchResults', array( $term, &$titleMatches, &$textMatches ) );
                } else {
                        wfRunHooks( 'SpecialSearchNoResults', array( $term ) );
@@ -386,10 +394,8 @@ class SpecialSearch extends SpecialPage {
                        if ( $numTextMatches > 0 && $numTitleMatches > 0 ) {
                                // if no title matches the heading is redundant
                                $out->wrapWikiMsg( "==$1==\n", 'textmatches' );
-                       } 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() ) {
                                $out->addHTML( $this->showInterwiki( $textMatches->getInterwikiResults(), $term ) );
@@ -413,7 +419,7 @@ class SpecialSearch extends SpecialPage {
                }
                $out->addHtml( "</div>" );
 
-               if ( $num || $this->offset ) {
+               if ( $prevnext ) {
                        $out->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
                }
        }
@@ -446,7 +452,11 @@ class SpecialSearch extends SpecialPage {
                } else {
                        $messageName = 'searchmenu-new-nocreate';
                }
-               $params = array( $messageName, wfEscapeWikiText( $title->getPrefixedText() ), Message::numParam( $num ) );
+               $params = array(
+                       $messageName,
+                       wfEscapeWikiText( $title->getPrefixedText() ),
+                       Message::numParam( $num )
+               );
                wfRunHooks( 'SpecialSearchCreateLink', array( $title, &$params ) );
 
                // Extensions using the hook might still return an empty $messageName
@@ -551,7 +561,7 @@ class SpecialSearch extends SpecialPage {
                $profile = new ProfileSection( __METHOD__ );
 
                if ( $result->isBrokenTitle() ) {
-                       return "<!-- Broken link in search result -->\n";
+                       return '';
                }
 
                $title = $result->getTitle();
@@ -583,7 +593,7 @@ class SpecialSearch extends SpecialPage {
                // The least confusing at this point is to drop the result.
                // You may get less results, but... oh well. :P
                if ( $result->isMissingRevision() ) {
-                       return "<!-- missing page " . htmlspecialchars( $title->getPrefixedText() ) . "-->\n";
+                       return '';
                }
 
                // format redirects / relevant sections
@@ -651,7 +661,6 @@ class SpecialSearch extends SpecialPage {
                // link to related articles if supported
                $related = '';
                if ( $result->hasRelated() ) {
-                       $st = SpecialPage::getTitleFor( 'Search' );
                        $stParams = array_merge(
                                $this->powerSearchOptions(),
                                array(
@@ -662,7 +671,7 @@ class SpecialSearch extends SpecialPage {
                        );
 
                        $related = ' -- ' . Linker::linkKnown(
-                               $st,
+                               $this->getPageTitle(),
                                $this->msg( 'search-relatedarticle' )->text(),
                                array(),
                                $stParams
@@ -711,7 +720,8 @@ class SpecialSearch extends SpecialPage {
                        &$score, &$size, &$date, &$related,
                        &$html
                ) ) ) {
-                       $html = "<li><div class='mw-search-result-heading'>{$link} {$redirect} {$section} {$fileMatch}</div> {$extract}\n" .
+                       $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>" .
                                "</li>\n";
                }
@@ -737,7 +747,8 @@ class SpecialSearch extends SpecialPage {
 
                // work out custom project captions
                $customCaptions = array();
-               $customLines = explode( "\n", $this->msg( 'search-interwiki-custom' )->text() ); // format per line <iwprefix>:<caption>
+               // format per line <iwprefix>:<caption>
+               $customLines = explode( "\n", $this->msg( 'search-interwiki-custom' )->text() );
                foreach ( $customLines as $line ) {
                        $parts = explode( ":", $line, 2 );
                        if ( count( $parts ) == 2 ) { // validate line
@@ -759,8 +770,7 @@ class SpecialSearch extends SpecialPage {
                        }
                }
 
-
-               // TODO: should support paging in a non-confusing way (not sure how though, maybe via ajax)..
+               // @todo Should support paging in a non-confusing way (not sure how though, maybe via ajax)..
                $out .= "</ul></div>\n";
 
                // convert the whole thing to desired language variant
@@ -783,7 +793,7 @@ class SpecialSearch extends SpecialPage {
                $profile = new ProfileSection( __METHOD__ );
 
                if ( $result->isBrokenTitle() ) {
-                       return "<!-- Broken link in search result -->\n";
+                       return '';
                }
 
                $title = $result->getTitle();