Now both empty search strings and 1 letter search strings works fine in

the glossary. Terms are hilighted properly (but 1 letter terms, because
it's a hilight limitation). Bug 4274.
(http://moodle.org/bugs/bug.php?op=show&bugid=4274)
This commit is contained in:
stronk7
2005-11-06 20:00:22 +00:00
parent 8bb94c53eb
commit f5d2ef9543
2 changed files with 7 additions and 11 deletions
+1 -3
View File
@@ -188,9 +188,7 @@
$searchterms = explode(" ",$hook);
foreach ($searchterms as $searchterm) {
if (strlen($searchterm) < 2) {
continue;
}
if ($conceptsearch) {
$conceptsearch .= " AND ";
}
+6 -8
View File
@@ -124,15 +124,9 @@
case 'search': /// looking for terms containing certain word(s)
$tab = GLOSSARY_STANDARD_VIEW;
$searchterms = trim(strip_tags($hook));
//Clean a bit the search string
$hook = trim(strip_tags($hook));
$searchterms = explode(' ', $searchterms); // Search for words independently
foreach ($searchterms as $key => $searchterm) {
if (strlen($searchterm) < 2) {
unset($searchterms[$key]);
}
}
$hook = trim(implode(' ', $searchterms));
break;
case 'entry': /// Looking for a certain entry id
@@ -369,6 +363,10 @@
} else {
$searchterms[$key] = preg_replace('/^\+/','',$searchterm);
}
//Avoid highlight of <2 len strings. It's a well known hilight limitation.
if (strlen($searchterm) < 2) {
unset($searchterms[$key]);
}
}
$strippedsearch = implode(' ', $searchterms); // Rebuild the string
$entry->highlight = $strippedsearch;