summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorwltb <[email protected]>2013-08-01 13:05:03 +0200
committerwltb <[email protected]>2013-08-01 13:05:03 +0200
commit28f92d28d87558945739c13ce31c3247a4e3369f (patch)
tree6f56f647a3dc0e83377c53066f4597b4553273fe /include
parent615a6cac60b145a26b5b0c1fd41993c502030756 (diff)
Highlighting search results: Added heuristic approach for common capitalizations, fixed indentions
Diffstat (limited to 'include')
-rw-r--r--include/functions.php10
1 files changed, 7 insertions, 3 deletions
diff --git a/include/functions.php b/include/functions.php
index 3aaccbb19..ea31a40cc 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -2864,15 +2864,19 @@
// http://stackoverflow.com/questions/4081372/highlight-keywords-in-a-paragraph
- $elements = $xpath->query('//*[contains(.,"'.$word.'")]');
+ $also_query = '';
+ 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) {
if (!$child instanceof DomText) continue;
- $fragment = $doc->createDocumentFragment();
- $text = $child->textContent;
+ $fragment = $doc->createDocumentFragment();
+ $text = $child->textContent;
$stubs = array();
while (($pos = mb_stripos($text, $word)) !== false) {