Esempio n. 1
0
 /**
  * @param array $terms Terms to highlight
  * @return string Highlighted text snippet, null (and not '') if not supported
  */
 function getTextSnippet($terms)
 {
     global $wgAdvancedSearchHighlighting;
     $this->initText();
     // TODO: make highliter take a content object. Make ContentHandler a factory for SearchHighliter.
     list($contextlines, $contextchars) = $this->searchEngine->userHighlightPrefs();
     $h = new SearchHighlighter();
     if (count($terms) > 0) {
         if ($wgAdvancedSearchHighlighting) {
             return $h->highlightText($this->mText, $terms, $contextlines, $contextchars);
         } else {
             return $h->highlightSimple($this->mText, $terms, $contextlines, $contextchars);
         }
     } else {
         return $h->highlightNone($this->mText, $contextlines, $contextchars);
     }
 }
Esempio n. 2
0
 /**
  * @param $terms Array: terms to highlight
  * @return String: highlighted text snippet, null (and not '') if not supported
  */
 function getTextSnippet($terms)
 {
     global $wgUser, $wgAdvancedSearchHighlighting;
     $this->initText();
     list($contextlines, $contextchars) = SearchEngine::userHighlightPrefs($wgUser);
     $h = new SearchHighlighter();
     if ($wgAdvancedSearchHighlighting) {
         return $h->highlightText($this->mText, $terms, $contextlines, $contextchars);
     } else {
         return $h->highlightSimple($this->mText, $terms, $contextlines, $contextchars);
     }
 }