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


PHP PMF_Utils::setHighlightedString方法代码示例

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


在下文中一共展示了PMF_Utils::setHighlightedString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renderSearchResult

 /**
  * Renders the result page for the main search page
  *
  * @param PMF_Search_Resultset $resultSet   PMF_Search_Resultset object
  * @param integer              $currentPage Current page number
  *
  * @return string
  */
 public function renderSearchResult(PMF_Search_Resultset $resultSet, $currentPage)
 {
     $html = '';
     $confPerPage = $this->_config->get('records.numberOfRecordsPerPage');
     $numOfResults = $resultSet->getNumberOfResults();
     $totalPages = ceil($numOfResults / $confPerPage);
     $lastPage = $currentPage * $confPerPage;
     $firstPage = $lastPage - $confPerPage;
     if ($lastPage > $numOfResults) {
         $lastPage = $numOfResults;
     }
     if (0 < $numOfResults) {
         $html .= sprintf("<p>%s</p>\n", $this->plurals->GetMsg('plmsgSearchAmount', $numOfResults));
         if (1 < $totalPages) {
             $html .= sprintf("<p><strong>%s%d %s %s</strong></p>\n", $this->translation['msgPage'], $currentPage, $this->translation['msgVoteFrom'], $this->plurals->GetMsg('plmsgPagesTotal', $totalPages));
         }
         $html .= "<ul class=\"phpmyfaq-search-results\">\n";
         $counter = $displayedCounter = 0;
         foreach ($resultSet->getResultset() as $result) {
             if ($displayedCounter >= $confPerPage) {
                 break;
             }
             $counter++;
             if ($counter <= $firstPage) {
                 continue;
             }
             $displayedCounter++;
             // Set language for current category to fetch the correct category name
             $this->Category->setLanguage($result->lang);
             $categoryInfo = $this->Category->getCategoriesFromArticle($result->id);
             $question = PMF_Utils::chopString($result->question, 15);
             $answerPreview = PMF_Utils::chopString(strip_tags($result->answer), 25);
             $searchterm = str_replace(array('^', '.', '?', '*', '+', '{', '}', '(', ')', '[', ']', '"'), '', $this->searchterm);
             $searchterm = preg_quote($searchterm, '/');
             $searchItems = explode(' ', $searchterm);
             if (PMF_String::strlen($searchItems[0]) > 1) {
                 foreach ($searchItems as $item) {
                     if (PMF_String::strlen($item) > 2) {
                         $question = PMF_Utils::setHighlightedString($question, $item);
                         $answerPreview = PMF_Utils::setHighlightedString($answerPreview, $item);
                     }
                 }
             }
             // Build the link to the faq record
             $currentUrl = sprintf('%s?%saction=artikel&amp;cat=%d&amp;id=%d&amp;artlang=%s&amp;highlight=%s', PMF_Link::getSystemRelativeUri(), $this->sessionId, $result->category_id, $result->id, $result->lang, urlencode($searchterm));
             $oLink = new PMF_Link($currentUrl, $this->_config);
             $oLink->text = $question;
             $oLink->itemTitle = $oLink->tooltip = $result->question;
             $html .= "<li>";
             $html .= sprintf("<strong>%s</strong>: %s<br />", $categoryInfo[0]['name'], $oLink->toHtmlAnchor());
             $html .= sprintf("<small class=\"searchpreview\"><strong>%s</strong> %s...</small>\n", $this->translation['msgSearchContent'], $answerPreview);
             $html .= "</li>";
         }
         $html .= "</ul>\n";
         if (1 < $totalPages) {
             $html .= $this->pagination->render();
         }
     } else {
         $html = $this->translation['err_noArticles'];
     }
     return $html;
 }
开发者ID:kapljr,项目名称:Jay-Kaplan-Farmingdale-BCS-Projects,代码行数:70,代码来源:Search.php

示例2: sprintf

$answer = $oGlossary->insertItemsIntoContent($faq->faqRecord['content']);
// Set the path of the current category
$categoryName = $category->getPath($currentCategory, ' &raquo; ', true);
$changeLanguagePath = PMF_Link::getSystemRelativeUri() . sprintf('?%saction=artikel&amp;cat=%d&amp;id=%d&amp;artlang=%s', $sids, $currentCategory, $faq->faqRecord['id'], $LANGCODE);
$oLink = new PMF_Link($changeLanguagePath);
$oLink->itemTitle = $faq->getRecordTitle($faq->faqRecord['id'], false);
$changeLanguagePath = $oLink->toString();
$highlight = PMF_Filter::filterInput(INPUT_GET, 'highlight', FILTER_SANITIZE_STRIPPED);
if (!is_null($highlight) && $highlight != "/" && $highlight != "<" && $highlight != ">" && PMF_String::strlen($highlight) > 3) {
    $highlight = str_replace("'", "´", $highlight);
    $highlight = str_replace(array('^', '.', '?', '*', '+', '{', '}', '(', ')', '[', ']'), '', $highlight);
    $highlight = preg_quote($highlight, '/');
    $searchItems = explode(' ', $highlight);
    foreach ($searchItems as $item) {
        $question = PMF_Utils::setHighlightedString($question, $item);
        $answer = PMF_Utils::setHighlightedString($answer, $item);
    }
}
// Hack: Apply the new SEO schema to those HTML anchors to
//       other faq records (Internal Links) added with WYSIWYG Editor:
//         href="index.php?action=artikel&cat=NNN&id=MMM&artlang=XYZ"
// Search for href attribute links
$oLnk->resetPool();
$oLnk->parse_string($answer);
$fixedContent = str_replace('href="#', sprintf('href="index.php?action=artikel&amp;lang=%s&amp;cat=%d&amp;id=%d&amp;artlang=%s#', $LANGCODE, $currentCategory, $faq->faqRecord['id'], $LANGCODE), $answer);
$oLnk->resetPool();
$oLnk->parse_string($fixedContent);
// Search for href attributes only
$linkArray = $oLnk->getUrlpool();
if (isset($linkArray['href'])) {
    foreach (array_unique($linkArray['href']) as $_url) {
开发者ID:atlcurling,项目名称:tkt,代码行数:31,代码来源:artikel.php

示例3: sprintf

$thema = $oGlossary->insertItemsIntoContent($thema);
// Set the path of the current category
$categoryName = $categoryLayout->renderBreadcrumb($categoryPath);
$changeLanguagePath = PMF_Link::getSystemRelativeUri() . sprintf('?%saction=artikel&amp;cat=%d&amp;id=%d&amp;artlang=%s', $sids, $currentCategory, $faq->faqRecord['id'], $LANGCODE);
$oLink = new PMF_Link($changeLanguagePath);
$oLink->itemTitle = $faq->getRecordTitle($faq->faqRecord['id'], false);
$changeLanguagePath = $oLink->toString();
$highlight = PMF_Filter::filterInput(INPUT_GET, 'highlight', FILTER_SANITIZE_STRIPPED);
if (!is_null($highlight) && $highlight != "/" && $highlight != "<" && $highlight != ">" && PMF_String::strlen($highlight) > 3) {
    $highlight = str_replace("'", "´", $highlight);
    $highlight = str_replace(array('^', '.', '?', '*', '+', '{', '}', '(', ')', '[', ']'), '', $highlight);
    $highlight = preg_quote($highlight, '/');
    $searchItems = explode(' ', $highlight);
    foreach ($searchItems as $item) {
        $thema = PMF_Utils::setHighlightedString($thema, $item);
        $content = PMF_Utils::setHighlightedString($content, $item);
    }
}
// Hack: Apply the new SEO schema to those HTML anchors to
//       other faq records (Internal Links) added with WYSIWYG Editor:
//         href="index.php?action=artikel&cat=NNN&id=MMM&artlang=XYZ"
// Search for href attribute links
$oLnk->resetPool();
$oLnk->parse_string($content);
$fixedContent = str_replace('href="#', sprintf('href="index.php?action=artikel&amp;lang=%s&amp;cat=%d&amp;id=%d&amp;artlang=%s#', $LANGCODE, $currentCategory, $faq->faqRecord['id'], $LANGCODE), $content);
$oLnk->resetPool();
$oLnk->parse_string($fixedContent);
// Search for href attributes only
$linkArray = $oLnk->getUrlpool();
if (isset($linkArray['href'])) {
    foreach (array_unique($linkArray['href']) as $_url) {
开发者ID:rybal06,项目名称:phpMyFAQ,代码行数:31,代码来源:artikel.php

示例4: renderSearchResult

 /**
  * Renders the result page for the main search page
  * 
  * @param PMF_Search_Resultset $resultSet   PMF_Search_Resultset object
  * @param integer              $currentPage Current page number
  * 
  * @return string
  */
 public function renderSearchResult(PMF_Search_Resultset $resultSet, $currentPage)
 {
     $html = '';
     $confPerPage = PMF_Configuration::getInstance()->get('main.numberOfRecordsPerPage');
     $numOfResults = $resultSet->getNumberOfResults();
     $totalPages = ceil($numOfResults / $confPerPage);
     $lastPage = $currentPage * $confPerPage;
     $firstPage = $lastPage - $confPerPage;
     if ($lastPage > $numOfResults) {
         $lastPage = $numOfResults;
     }
     if (0 < $numOfResults) {
         $html .= sprintf("<p>%s</p>\n", $this->plurals->GetMsg('plmsgSearchAmount', $numOfResults));
         if (1 < $totalPages) {
             $html .= sprintf("<p><strong>%s%d %s %s</strong></p>\n", $this->translation['msgPage'], $currentPage, $this->translation['msgVoteFrom'], $this->plurals->GetMsg('plmsgPagesTotal', $totalPages));
         }
         $html .= "<ul class=\"phpmyfaq_ul\">\n";
         foreach ($resultSet->getResultset() as $result) {
             $categoryName = $this->categoryLayout->renderBreadcrumb(array($result->category_id));
             $question = PMF_Utils::chopString($result->question, 15);
             $answerPreview = PMF_Utils::chopString(strip_tags($result->answer), 25);
             $searchterm = str_replace(array('^', '.', '?', '*', '+', '{', '}', '(', ')', '[', ']', '"'), '', $this->searchterm);
             $searchterm = preg_quote($searchterm, '/');
             $searchItems = explode(' ', $searchterm);
             if (PMF_String::strlen($searchItems[0]) > 1) {
                 foreach ($searchItems as $item) {
                     if (PMF_String::strlen($item) > 2) {
                         $question = PMF_Utils::setHighlightedString($question, $item);
                         $answerPreview = PMF_Utils::setHighlightedString($answerPreview, $item);
                     }
                 }
             }
             // Build the link to the faq record
             $currentUrl = sprintf('%s?%saction=artikel&amp;cat=%d&amp;id=%d&amp;artlang=%s&amp;highlight=%s', PMF_Link::getSystemRelativeUri(), $this->sessionId, $result->category_id, $result->id, $result->lang, urlencode($searchterm));
             $oLink = new PMF_Link($currentUrl);
             $oLink->text = $oLink->itemTitle = $oLink->tooltip = $result->question;
             $html .= sprintf("<li><strong>%s</strong>: %s<br /><div class=\"searchpreview\"><strong>%s</strong> %s...</div><br /></li>\n", $categoryName, $oLink->toHtmlAnchor(), $this->translation['msgSearchContent'], $answerPreview);
         }
         $html .= "</ul>\n";
         if (1 > $totalPages) {
             $html .= $this->pagination->render();
         }
     } else {
         $html = $this->translation['err_noArticles'];
     }
     return $html;
 }
开发者ID:jr-ewing,项目名称:phpMyFAQ,代码行数:55,代码来源:Search.php


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