Zend_Search_Lucene_Document_Html::_highlightNodeRecursive PHP Method

_highlightNodeRecursive() protected method

highlight words in content of the specified node
protected _highlightNodeRecursive ( DOMNode $contextNode, array $wordsToHighlight, callback $callback, array $params )
$contextNode DOMNode
$wordsToHighlight array
$callback callback Callback method, used to transform (highlighting) text.
$params array Array of additionall callback parameters (first non-optional parameter is a text to transform)
    protected function _highlightNodeRecursive(DOMNode $contextNode, $wordsToHighlight, $callback, $params)
    {
        $textNodes = [];
        if (!$contextNode->hasChildNodes()) {
            return;
        }
        foreach ($contextNode->childNodes as $childNode) {
            if ($childNode->nodeType == XML_TEXT_NODE) {
                // process node later to leave childNodes structure untouched
                $textNodes[] = $childNode;
            } else {
                // Process node if it's not a script node
                if ($childNode->nodeName != 'script') {
                    $this->_highlightNodeRecursive($childNode, $wordsToHighlight, $callback, $params);
                }
            }
        }
        foreach ($textNodes as $textNode) {
            $this->_highlightTextNode($textNode, $wordsToHighlight, $callback, $params);
        }
    }