This code needs some cleaning

Highlighting is odd if several search terms appear near each other.
AjaxSearch extracts a context of 200 words around the first occurence of each search term which is cool. However, if n search terms occur next to each other 1..n will be highlighted in the first extract. 2..n will be highlightet in the second. 3..n will be highlight in the third and so on until only the n-th term is highlightet in the last extract.
The following fix will make it highlight only the relevant word in each extract.
In snippet-ajaxSearch-tpl.php line 518
Replace:
[tt]
$summary .= PrepareSearchContent( $text, $length=200, $searchTerm );
$summary = preg_replace( ’/’ . preg_quote( $searchTerm, ’/’ ) . ’/i’, ’<span class="ajaxSearch_highlight ajaxSearch_highlight’.$count.’">\0</span>’, $summary );
[/tt]
with: *** EDIT See updated fix below ***
[tt]
$toAdd = PrepareSearchContent( $text, $length=200, $searchTerm ) . ’ ’;
$summary .= preg_replace( ’/’ . preg_quote( $searchTerm, ’/’ ) . ’/i’, ’<span class="ajaxSearch_highlight ajaxSearch_highlight’.$count.’">\0</span>’, $toAdd );
[/tt]
AjaxSearch still behaves odd when using ’useAllWords=false’, returning n extracts for n search terms even if fewer terms match with the extracts for terms that didn’t match (naturally) containing no highligts. Will post a fix for that later.