当前位置: 首页>>代码示例>>PHP>>正文


PHP SearchResult::getRedirectTitle方法代码示例

本文整理汇总了PHP中SearchResult::getRedirectTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchResult::getRedirectTitle方法的具体用法?PHP SearchResult::getRedirectTitle怎么用?PHP SearchResult::getRedirectTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SearchResult的用法示例。


在下文中一共展示了SearchResult::getRedirectTitle方法的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::getRedirectTitle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。