PhpDig.net

PhpDig.net (http://www.phpdig.net/forum/index.php)
-   Mod Submissions (http://www.phpdig.net/forum/forumdisplay.php?f=24)
-   -   word snippet truncation fix (http://www.phpdig.net/forum/showthread.php?t=1998)

mohrt 05-05-2005 02:17 PM

word snippet truncation fix
 
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).' ... ';


All times are GMT -8. The time now is 02:56 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.