PDA

View Full Version : word snippet truncation fix


mohrt
05-05-2005, 02:17 PM
I didn't like the way phpdig truncates words in the search snippets, so I removed the begin/end words (which are possible truncated)

here is the patch:

diff search_function.php.bak search_function.php
555c555,562
< $extract .= ' ...'.phpdigHighlight($reg_strings,$extract_content).'... ';
---
> // remove first (possibly truncated) word
> if(($first_space = strpos($extract_content, ' ')) !== false)
> $extract_content = substr($extract_content, $first_space + 1);
> // remove last (possibly truncated) word
> if(($last_space = strrpos($extract_content, ' ')) !== false)
> $extract_content = substr($extract_content, 0, $last_space);
>
> $extract .= ' ... '.phpdigHighlight($reg_strings,$extract_content).' ... ';