From c5d569c6af96fb147a8fa151f34c86690c748e57 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sun, 19 Jun 2005 14:44:58 +0000 Subject: [PATCH] Now + and - search terms are properly highlighted under glossary searches. This was broken recently solving some non-iso problems. --- mod/glossary/view.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mod/glossary/view.php b/mod/glossary/view.php index 7d087f5b6ad..66d5dd60a2d 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -353,7 +353,18 @@ /// highlight the term if necessary if ($mode == 'search') { - $entry->highlight = $hook; + //We have to strip any word starting by + and take out words starting by - + //to make highlight works properly + $searchterms = explode(' ', $hook); // Search for words independently + foreach ($searchterms as $key => $searchterm) { + if (preg_match('/^\-/',$searchterm)) { + unset($searchterms[$key]); + } else { + $searchterms[$key] = preg_replace('/^\+/','',$searchterm); + } + } + $strippedsearch = implode(' ', $searchterms); // Rebuild the string + $entry->highlight = $strippedsearch; } /// and finally print the entry.