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


PHP SearchResult::getTitle方法代码示例

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


在下文中一共展示了SearchResult::getTitle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: augmentResult

 /**
  * Returns extra data for specific result and store it in SearchResult object.
  * @param SearchResult $result
  * @return array|null List of data as name => value or null if none present.
  */
 public function augmentResult(SearchResult $result)
 {
     $id = $result->getTitle()->getArticleID();
     if (!$id || !isset($this->extraData[$id])) {
         return null;
     }
     $result->setExtensionData($this->extraData[$id]);
     return $this->extraData[$id];
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:14,代码来源:SearchResultSet.php

示例3: showHit

 /**
  * Format a single hit result
  * @param SearchResult $result
  * @param string $terms partial regexp for highlighting terms
  */
 function showHit($result, $terms)
 {
     $fname = 'SpecialSearch::showHit';
     wfProfileIn($fname);
     global $wgUser, $wgContLang;
     $t = $result->getTitle();
     if (is_null($t)) {
         wfProfileOut($fname);
         return "<!-- Broken link in search result -->\n";
     }
     $sk =& $wgUser->getSkin();
     $contextlines = $wgUser->getOption('contextlines');
     if ('' == $contextlines) {
         $contextlines = 5;
     }
     $contextchars = $wgUser->getOption('contextchars');
     if ('' == $contextchars) {
         $contextchars = 50;
     }
     $link = $sk->makeKnownLinkObj($t);
     $revision = Revision::newFromTitle($t);
     $text = $revision->getText();
     $size = wfMsg('nbytes', strlen($text));
     $lines = explode("\n", $text);
     $max = IntVal($contextchars) + 1;
     $pat1 = "/(.*)({$terms})(.{0,{$max}})/i";
     $lineno = 0;
     $extract = '';
     wfProfileIn("{$fname}-extract");
     foreach ($lines as $line) {
         if (0 == $contextlines) {
             break;
         }
         ++$lineno;
         if (!preg_match($pat1, $line, $m)) {
             continue;
         }
         --$contextlines;
         $pre = $wgContLang->truncate($m[1], -$contextchars, '...');
         if (count($m) < 3) {
             $post = '';
         } else {
             $post = $wgContLang->truncate($m[3], $contextchars, '...');
         }
         $found = $m[2];
         $line = htmlspecialchars($pre . $found . $post);
         $pat2 = '/(' . $terms . ")/i";
         $line = preg_replace($pat2, "<span class='searchmatch'>\\1</span>", $line);
         $extract .= "<br /><small>{$lineno}: {$line}</small>\n";
     }
     wfProfileOut("{$fname}-extract");
     wfProfileOut($fname);
     return "<li>{$link} ({$size}){$extract}</li>\n";
 }
开发者ID:BackupTheBerlios,项目名称:blahtex,代码行数:59,代码来源:SpecialSearch.php

示例4: 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

示例5: showHit

 /**
  * Format a single hit result
  * @param SearchResult $result
  * @param string $terms partial regexp for highlighting terms
  */
 function showHit($result, $terms)
 {
     $fname = 'SpecialSearch::showHit';
     wfProfileIn($fname);
     global $wgUser, $wgContLang, $wgLang;
     $t = $result->getTitle();
     if (is_null($t)) {
         wfProfileOut($fname);
         return "<!-- Broken link in search result -->\n";
     }
     $sk = $wgUser->getSkin();
     $contextlines = $wgUser->getOption('contextlines', 5);
     $contextchars = $wgUser->getOption('contextchars', 50);
     $link = $sk->makeKnownLinkObj($t);
     //If page content is not readable, just return the title.
     //This is not quite safe, but better than showing excerpts from non-readable pages
     //Note that hiding the entry entirely would screw up paging.
     if (!$t->userCanRead()) {
         return "<li>{$link}</li>\n";
     }
     $revision = Revision::newFromTitle($t);
     $text = $revision->getText();
     $size = wfMsgExt('nbytes', array('parsemag', 'escape'), $wgLang->formatNum(strlen($text)));
     $lines = explode("\n", $text);
     $max = intval($contextchars) + 1;
     $pat1 = "/(.*)({$terms})(.{0,{$max}})/i";
     $lineno = 0;
     $extract = '';
     wfProfileIn("{$fname}-extract");
     foreach ($lines as $line) {
         if (0 == $contextlines) {
             break;
         }
         ++$lineno;
         $m = array();
         if (!preg_match($pat1, $line, $m)) {
             continue;
         }
         --$contextlines;
         $pre = $wgContLang->truncate($m[1], -$contextchars, '...');
         if (count($m) < 3) {
             $post = '';
         } else {
             $post = $wgContLang->truncate($m[3], $contextchars, '...');
         }
         $found = $m[2];
         $line = htmlspecialchars($pre . $found . $post);
         $pat2 = '/(' . $terms . ")/i";
         $line = preg_replace($pat2, "<span class='searchmatch'>\\1</span>", $line);
         $extract .= "<br /><small>{$lineno}: {$line}</small>\n";
     }
     wfProfileOut("{$fname}-extract");
     wfProfileOut($fname);
     return "<li>{$link} ({$size}){$extract}</li>\n";
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:60,代码来源:SpecialSearch.php


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