/** * Show results from other wikis * * @param SearchResultSet $matches */ protected function showInterwiki(&$matches, $query) { global $wgContLang; wfProfileIn(__METHOD__); $terms = $wgContLang->convertForSearchResult($matches->termMatches()); $out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>" . wfMsg('search-interwiki-caption') . "</div>\n"; $off = $this->offset + 1; $out .= "<ul class='mw-search-iwresults'>\n"; // work out custom project captions $customCaptions = array(); $customLines = explode("\n", wfMsg('search-interwiki-custom')); // format per line <iwprefix>:<caption> foreach ($customLines as $line) { $parts = explode(":", $line, 2); if (count($parts) == 2) { // validate line $customCaptions[$parts[0]] = $parts[1]; } } $prev = null; while ($result = $matches->next()) { $out .= $this->showInterwikiHit($result, $prev, $terms, $query, $customCaptions); $prev = $result->getInterwikiPrefix(); } // 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 $out = $wgContLang->convert($out); wfProfileOut(__METHOD__); return $out; }
/** * Show whole set of results * * @param SearchResultSet $matches * @param string $interwiki Interwiki name * * @return string */ protected function showMatches(&$matches, $interwiki = null) { global $wgContLang; $terms = $wgContLang->convertForSearchResult($matches->termMatches()); $out = ''; $result = $matches->next(); $pos = $this->offset; if ($result && $interwiki) { $out .= $this->interwikiHeader($interwiki, $result); } $out .= "<ul class='mw-search-results'>\n"; while ($result) { $out .= $this->showHit($result, $terms, ++$pos); $result = $matches->next(); } $out .= "</ul>\n"; // convert the whole thing to desired language variant $out = $wgContLang->convert($out); return $out; }
/** * Show whole set of results * * @param SearchResultSet $matches * * @return string */ protected function showMatches(&$matches) { global $wgContLang; $profile = new ProfileSection(__METHOD__); $terms = $wgContLang->convertForSearchResult($matches->termMatches()); $out = "<ul class='mw-search-results'>\n"; $result = $matches->next(); while ($result) { $out .= $this->showHit($result, $terms); $result = $matches->next(); } $out .= "</ul>\n"; // convert the whole thing to desired language variant $out = $wgContLang->convert($out); return $out; }
/** * @param SearchResultSet $matches * @param string $terms partial regexp for highlighting terms */ function showMatches(&$matches) { $fname = 'SpecialSearch::showMatches'; wfProfileIn($fname); global $wgContLang; $tm = $wgContLang->convertForSearchResult($matches->termMatches()); $terms = implode('|', $tm); global $wgOut; $off = $this->offset + 1; $out = "<ol start='{$off}'>\n"; while ($result = $matches->next()) { $out .= $this->showHit($result, $terms); } $out .= "</ol>\n"; // convert the whole thing to desired language variant global $wgContLang; $out = $wgContLang->convert($out); wfProfileOut($fname); return $out; }