當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SearchResult::getRedirectSnippet方法代碼示例

本文整理匯總了PHP中SearchResult::getRedirectSnippet方法的典型用法代碼示例。如果您正苦於以下問題:PHP SearchResult::getRedirectSnippet方法的具體用法?PHP SearchResult::getRedirectSnippet怎麽用?PHP SearchResult::getRedirectSnippet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SearchResult的用法示例。


在下文中一共展示了SearchResult::getRedirectSnippet方法的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;
 }
開發者ID:BackupTheBerlios,項目名稱:swahili-dict,代碼行數:54,代碼來源:SpecialSearch.php

示例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;
 }
開發者ID:D66Ha,項目名稱:mediawiki,代碼行數:51,代碼來源:SpecialSearch.php


注:本文中的SearchResult::getRedirectSnippet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。