本文整理汇总了PHP中SearchResult::getTitleSnippet方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchResult::getTitleSnippet方法的具体用法?PHP SearchResult::getTitleSnippet怎么用?PHP SearchResult::getTitleSnippet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchResult
的用法示例。
在下文中一共展示了SearchResult::getTitleSnippet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showInterwikiHit
/**
* Show single interwiki link
*
* @param SearchResult $result
* @param string $lastInterwiki
* @param array $terms
* @param string $query
* @param array $customCaptions iw prefix -> caption
*/
protected function showInterwikiHit($result, $lastInterwiki, $terms, $query, $customCaptions)
{
wfProfileIn(__METHOD__);
global $wgContLang, $wgLang;
if ($result->isBrokenTitle()) {
wfProfileOut(__METHOD__);
return "<!-- Broken link in search result -->\n";
}
$t = $result->getTitle();
$titleSnippet = $result->getTitleSnippet($terms);
if ($titleSnippet == '') {
$titleSnippet = null;
}
$link = $this->sk->linkKnown($t, $titleSnippet);
// format redirect if any
$redirectTitle = $result->getRedirectTitle();
$redirectText = $result->getRedirectSnippet($terms);
$redirect = '';
if (!is_null($redirectTitle)) {
if ($redirectText == '') {
$redirectText = null;
}
$redirect = "<span class='searchalttitle'>" . wfMsg('search-redirect', $this->sk->linkKnown($redirectTitle, $redirectText)) . "</span>";
}
$out = "";
// display project name
if (is_null($lastInterwiki) || $lastInterwiki != $t->getInterwiki()) {
if (key_exists($t->getInterwiki(), $customCaptions)) {
// captions from 'search-interwiki-custom'
$caption = $customCaptions[$t->getInterwiki()];
} else {
// default is to show the hostname of the other wiki which might suck
// if there are many wikis on one hostname
$parsed = parse_url($t->getFullURL());
$caption = wfMsg('search-interwiki-default', $parsed['host']);
}
// "more results" link (special page stuff could be localized, but we might not know target lang)
$searchTitle = Title::newFromText($t->getInterwiki() . ":Special:Search");
$searchLink = $this->sk->linkKnown($searchTitle, wfMsg('search-interwiki-more'), array(), array('search' => $query, 'fulltext' => 'Search'));
$out .= "</ul><div class='mw-search-interwiki-project'><span class='mw-search-interwiki-more'>\n\t\t\t\t{$searchLink}</span>{$caption}</div>\n<ul>";
}
$out .= "<li>{$link} {$redirect}</li>\n";
wfProfileOut(__METHOD__);
return $out;
}
示例2: showInterwikiHit
/**
* Show single interwiki link
*
* @param SearchResult $result
* @param string $lastInterwiki
* @param string $query
* @param array $customCaptions Interwiki prefix -> caption
*
* @return string
*/
protected function showInterwikiHit($result, $lastInterwiki, $query, $customCaptions)
{
if ($result->isBrokenTitle()) {
return '';
}
$title = $result->getTitle();
$titleSnippet = $result->getTitleSnippet();
if ($titleSnippet == '') {
$titleSnippet = null;
}
$link = Linker::linkKnown($title, $titleSnippet);
// format redirect if any
$redirectTitle = $result->getRedirectTitle();
$redirectText = $result->getRedirectSnippet();
$redirect = '';
if (!is_null($redirectTitle)) {
if ($redirectText == '') {
$redirectText = null;
}
$redirect = "<span class='searchalttitle'>" . $this->msg('search-redirect')->rawParams(Linker::linkKnown($redirectTitle, $redirectText))->text() . "</span>";
}
$out = "";
// display project name
if (is_null($lastInterwiki) || $lastInterwiki != $title->getInterwiki()) {
if (array_key_exists($title->getInterwiki(), $customCaptions)) {
// captions from 'search-interwiki-custom'
$caption = $customCaptions[$title->getInterwiki()];
} else {
// default is to show the hostname of the other wiki which might suck
// if there are many wikis on one hostname
$parsed = wfParseUrl($title->getFullURL());
$caption = $this->msg('search-interwiki-default', $parsed['host'])->text();
}
// "more results" link (special page stuff could be localized, but we might not know target lang)
$searchTitle = Title::newFromText($title->getInterwiki() . ":Special:Search");
$searchLink = Linker::linkKnown($searchTitle, $this->msg('search-interwiki-more')->text(), array(), array('search' => $query, 'fulltext' => 'Search'));
$out .= "</ul><div class='mw-search-interwiki-project'><span class='mw-search-interwiki-more'>\n\t\t\t\t{$searchLink}</span>{$caption}</div>\n<ul>";
}
$out .= "<li>{$link} {$redirect}</li>\n";
return $out;
}