/** @var SearchEngine Search engine */
protected $searchEngine;
- /** @var String Search engine type, if not default */
+ /** @var string Search engine type, if not default */
protected $searchEngineType;
- /** @var Array For links */
+ /** @var array For links */
protected $extraParams = array();
- /** @var String No idea, apparently used by some other classes */
+ /** @var string No idea, apparently used by some other classes */
protected $mPrefix;
/**
/**
* Entry point
*
- * @param string $par or null
+ * @param string $par
*/
public function execute( $par ) {
$this->setHeaders();
/**
* If an exact title match can be found, jump straight ahead to it.
*
- * @param $term String
+ * @param string $term
*/
public function goResult( $term ) {
$this->setupPage( $term );
# If there's an exact or very near match, jump right there.
$title = SearchEngine::getNearMatch( $term );
- if ( !wfRunHooks( 'SpecialSearchGo', array( &$title, &$term ) ) ) {
- # Hook requested termination
- return;
- }
-
if ( !is_null( $title ) ) {
$this->getOutput()->redirect( $title->getFullURL() );
}
/**
- * @param $term String
+ * @param string $term
*/
public function showResults( $term ) {
global $wgDisableTextSearch, $wgSearchForwardUrl, $wgContLang, $wgScript;
$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',
// 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() );
}
$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 ) ) ) {
$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 ) );
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 ) );
}
$out->addHtml( "</div>" );
- if ( $num || $this->offset ) {
+ if ( $prevnext ) {
$out->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
}
- wfRunHooks( 'SpecialSearchResultsAppend', array( $this, $out, $term ) );
}
/**
- * @param $title Title
+ * @param Title $title
* @param int $num The number of search results found
- * @param $titleMatches null|SearchResultSet results from title search
- * @param $textMatches null|SearchResultSet results from text search
+ * @param null|SearchResultSet $titleMatches Results from title search
+ * @param null|SearchResultSet $textMatches Results from text search
*/
protected function showCreateLink( $title, $num, $titleMatches, $textMatches ) {
// show direct page/create link if applicable
} 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
}
/**
- * @param $term string
+ * @param string $term
*/
protected function setupPage( $term ) {
# Should advanced UI be used?
* Extract "power search" namespace settings from the request object,
* returning a list of index numbers to search.
*
- * @param $request WebRequest
- * @return Array
+ * @param WebRequest $request
+ * @return array
*/
protected function powerSearch( &$request ) {
$arr = array();
/**
* Reconstruct the 'power search' options for links
*
- * @return Array
+ * @return array
*/
protected function powerSearchOptions() {
$opt = array();
/**
* Show whole set of results
*
- * @param $matches SearchResultSet
+ * @param SearchResultSet $matches
*
* @return string
*/
/**
* Format a single hit result
*
- * @param $result SearchResult
- * @param array $terms terms to highlight
+ * @param SearchResult $result
+ * @param array $terms Terms to highlight
*
* @return string
*/
$profile = new ProfileSection( __METHOD__ );
if ( $result->isBrokenTitle() ) {
- return "<!-- Broken link in search result -->\n";
+ return '';
}
$title = $result->getTitle();
// 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
// link to related articles if supported
$related = '';
if ( $result->hasRelated() ) {
- $st = SpecialPage::getTitleFor( 'Search' );
$stParams = array_merge(
$this->powerSearchOptions(),
array(
);
$related = ' -- ' . Linker::linkKnown(
- $st,
+ $this->getPageTitle(),
$this->msg( 'search-relatedarticle' )->text(),
array(),
$stParams
&$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";
}
/**
* Show results from other wikis
*
- * @param $matches SearchResultSet|array
- * @param $query String
+ * @param SearchResultSet|array $matches
+ * @param string $query
*
* @return string
*/
// 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
}
}
-
- // 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
/**
* Show single interwiki link
*
- * @param $result SearchResult
- * @param $lastInterwiki String
- * @param $query String
+ * @param SearchResult $result
+ * @param string $lastInterwiki
+ * @param string $query
* @param array $customCaptions iw prefix -> caption
*
* @return string
$profile = new ProfileSection( __METHOD__ );
if ( $result->isBrokenTitle() ) {
- return "<!-- Broken link in search result -->\n";
+ return '';
}
$title = $result->getTitle();
}
/**
- * @param $profile
- * @param $term
- * @return String
+ * @param string $profile
+ * @param string $term
+ * @return string
*/
protected function getProfileForm( $profile, $term ) {
// Hidden stuff
/**
* Generates the power search box at [[Special:Search]]
*
- * @param string $term search term
- * @param $opts array
- * @return String: HTML form
+ * @param string $term Search term
+ * @param array $opts
+ * @return string HTML form
*/
protected function powerSearchBox( $term, $opts ) {
global $wgContLang;
}
/**
- * @param $term
- * @param $resultsShown
- * @param $totalNum
+ * @param string $term
+ * @param int $resultsShown
+ * @param int $totalNum
* @return string
*/
protected function formHeader( $term, $resultsShown, $totalNum ) {
}
/**
- * @param $term string
+ * @param string $term
* @return string
*/
protected function shortDialog( $term ) {
/**
* Make a search link with some target namespaces
*
- * @param $term String
- * @param array $namespaces ignored
- * @param string $label link's text
- * @param string $tooltip link's tooltip
- * @param array $params query string parameters
- * @return String: HTML fragment
+ * @param string $term
+ * @param array $namespaces Ignored
+ * @param string $label Link's text
+ * @param string $tooltip Link's tooltip
+ * @param array $params Query string parameters
+ * @return string HTML fragment
*/
protected function makeSearchLink( $term, $namespaces, $label, $tooltip, $params = array() ) {
$opt = $params;
/**
* Check if query starts with image: prefix
*
- * @param string $term the string to check
- * @return Boolean
+ * @param string $term The string to check
+ * @return bool
*/
protected function startsWithImage( $term ) {
global $wgContLang;
/**
* Check if query starts with all: prefix
*
- * @param string $term the string to check
- * @return Boolean
+ * @param string $term The string to check
+ * @return bool
*/
protected function startsWithAll( $term ) {
* user navigates search results.
* @since 1.18
*
- * @param $key
- * @param $value
+ * @param string $key
+ * @param mixed $value
*/
public function setExtraParam( $key, $value ) {
$this->extraParams[$key] = $value;