|
|
@ -2864,15 +2864,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
// http://stackoverflow.com/questions/4081372/highlight-keywords-in-a-paragraph
|
|
|
|
// http://stackoverflow.com/questions/4081372/highlight-keywords-in-a-paragraph
|
|
|
|
|
|
|
|
|
|
|
|
$also_query = '';
|
|
|
|
$elements = $xpath->query("//*/text()");
|
|
|
|
foreach(array(strtolower($word), strtoupper($word), ucfirst(strtolower($word))) as $word_cap) {
|
|
|
|
|
|
|
|
$also_query .= ' or contains(.,"'.$word_cap.'")' ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$elements = $xpath->query('//*[contains(.,"'.$word.'")' . $also_query . ']');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($elements as $element) {
|
|
|
|
|
|
|
|
foreach ($element->childNodes as $child) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($elements as $child) {
|
|
|
|
if (!$child instanceof DomText) continue;
|
|
|
|
if (!$child instanceof DomText) continue;
|
|
|
|
|
|
|
|
|
|
|
|
$fragment = $doc->createDocumentFragment();
|
|
|
|
$fragment = $doc->createDocumentFragment();
|
|
|
@ -2891,8 +2885,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($text)) $fragment->appendChild(new DomText($text));
|
|
|
|
if (!empty($text)) $fragment->appendChild(new DomText($text));
|
|
|
|
|
|
|
|
|
|
|
|
$element->replaceChild($fragment, $child);
|
|
|
|
$child->parentNode->replaceChild($fragment, $child);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|