Don't highlight search terms inside url
darcs-hash:20080720033401-533db-05bf2c9ebe988ebda6a295447a958af66571a088.gz
This commit is contained in:
parent
a1515e5411
commit
58ae93a621
@ -139,8 +139,15 @@ class NoticesearchAction extends SearchAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function highlight($text, $terms) {
|
function highlight($text, $terms) {
|
||||||
|
/* Highligh serach terms */
|
||||||
$pattern = '/('.implode('|',array_map('htmlspecialchars', $terms)).')/i';
|
$pattern = '/('.implode('|',array_map('htmlspecialchars', $terms)).')/i';
|
||||||
$result = preg_replace($pattern, '<strong>\\1</strong>', $text);
|
$result = preg_replace($pattern, '<strong>\\1</strong>', $text);
|
||||||
|
|
||||||
|
/* Remove highlighting from inside links, loop incase multiple highlights in links */
|
||||||
|
$pattern = '/(href="[^"]*)<strong>('.implode('|',array_map('htmlspecialchars', $terms)).')<\/strong>([^"]*")/iU';
|
||||||
|
do {
|
||||||
|
$result = preg_replace($pattern, '\\1\\2\\3', $result, -1, $count);
|
||||||
|
} while ($count);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user