highlight() public method

Highlight text with specified color
public highlight ( string | array $words, string $colour = '#66ffff' ) : string
$words string | array
$colour string
return string
コード例 #1
0
ファイル: Default.php プロジェクト: realfluid/umbaugh
    /**
     * Highlight specified words
     *
     * @param string|array $words  Words to highlight. They could be organized using the array or string.
     */
    public function highlight($words)
    {
    	$color = $this->_highlightColors[$this->_currentColorIndex];
    	$this->_currentColorIndex = ($this->_currentColorIndex + 1) % count($this->_highlightColors);

    	$this->_doc->highlight($words, $color);
    }
コード例 #2
0
 /**
  * Highlight query terms
  *
  * @param integer &$colorIndex
  * @param Zend_Search_Lucene_Document_Html $doc
  */
 public function highlightMatchesDOM(Zend_Search_Lucene_Document_Html $doc, &$colorIndex)
 {
     $words = array();
     if ($this->_signs === null) {
         foreach ($this->_terms as $term) {
             $words[] = $term->text;
         }
     } else {
         foreach ($this->_signs as $id => $sign) {
             if ($sign !== false) {
                 $words[] = $this->_terms[$id]->text;
             }
         }
     }
     $doc->highlight($words, $this->_getHighlightColor($colorIndex));
 }
コード例 #3
0
ファイル: Term.php プロジェクト: jorgenils/zend-framework
 /**
  * Highlight query terms
  *
  * @param integer &$colorIndex
  * @param Zend_Search_Lucene_Document_Html $doc
  */
 public function highlightMatchesDOM(Zend_Search_Lucene_Document_Html $doc, &$colorIndex)
 {
     $doc->highlight($this->_term->text, $this->_getHighlightColor($colorIndex));
 }
コード例 #4
0
ファイル: Range.php プロジェクト: ookwudili/chisimba
 /**
  * Highlight query terms
  *
  * @param integer &$colorIndex
  * @param Zend_Search_Lucene_Document_Html $doc
  */
 public function highlightMatchesDOM(Zend_Search_Lucene_Document_Html $doc, &$colorIndex)
 {
     $words = array();
     foreach ($this->_matches as $term) {
         $words[] = $term->text;
     }
     $doc->highlight($words, $this->_getHighlightColor($colorIndex));
 }
コード例 #5
0
ファイル: Range.php プロジェクト: ismaelmelus/home
 /**
  * Highlight query terms
  *
  * @param integer &$colorIndex
  * @param Zend_Search_Lucene_Document_Html $doc
  */
 public function highlightMatchesDOM(Zend_Search_Lucene_Document_Html $doc, &$colorIndex)
 {
     /** @todo implementation */
     $words = array();
     $matchExpression = '/^' . str_replace(array('\\?', '\\*'), array('.', '.*'), preg_quote($this->_pattern->text, '/')) . '$/';
     if (@preg_match('/\\pL/u', 'a') == 1) {
         // PCRE unicode support is turned on
         // add Unicode modifier to the match expression
         $matchExpression .= 'u';
     }
     $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($doc->getFieldUtf8Value('body'), 'UTF-8');
     foreach ($tokens as $token) {
         if (preg_match($matchExpression, $token->getTermText()) === 1) {
             $words[] = $token->getTermText();
         }
     }
     $doc->highlight($words, $this->_getHighlightColor($colorIndex));
 }