From: Andreas K. <la...@us...> - 2002-12-27 10:19:55
|
Update of /cvsroot/pn-modules/PN_Shoutbox/html/modules/Shoutbox In directory sc8-pr-cvs1:/tmp/cvs-serv26218/PN_Shoutbox/html/modules/Shoutbox Modified Files: show.php Log Message: added check for long words Index: show.php =================================================================== RCS file: /cvsroot/pn-modules/PN_Shoutbox/html/modules/Shoutbox/show.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** show.php 22 Dec 2002 14:07:54 -0000 1.4 --- show.php 27 Dec 2002 10:19:52 -0000 1.5 *************** *** 16,20 **** // timeformat (see http://www.php.net/date) $timeformat = "j.n.y, H:i"; ! // smile definition $smiley[':green'] = "biggrin.gif"; --- 16,22 ---- // timeformat (see http://www.php.net/date) $timeformat = "j.n.y, H:i"; ! // maxwordlength for wrapping ! $maxwordlength = 15; ! // smile definition $smiley[':green'] = "biggrin.gif"; *************** *** 54,59 **** $oneline = explode("|",$shouts[$count]); if (count($oneline)!=0) { ! // convert links and mail-adresses ! $shouttext = make_clickable($oneline[1]); // convert smilies --- 56,65 ---- $oneline = explode("|",$shouts[$count]); if (count($oneline)!=0) { ! ! // remove slashes from shout ! $shouttext = stripslashes($oneline[1]); ! ! // convert links and mail-adresses in shout ! $shouttext = shoutbox_MakeClickable($shouttext); // convert smilies *************** *** 62,65 **** --- 68,75 ---- } + // wordwrapping + $shouttext = shoutbox_wordwrap($shouttext, $maxwordlength, "\n"); + //$shouttext = ereg_replace("([^ \/]{15})","\\1<wbr>",$shouttext); + // format the shout $line = "<B>$oneline[0]</B><BR />\n$shouttext<BR /><I>".date($timeformat,$oneline[2])."</I><HR>\n"; *************** *** 71,75 **** ! function make_clickable($text) { /** * Rewritten by Nathan Codding - Feb 6, 2001. --- 81,85 ---- ! function shoutbox_MakeClickable($text) { /** * Rewritten by Nathan Codding - Feb 6, 2001. *************** *** 111,113 **** --- 121,142 ---- } + function shoutbox_wordwrap($str, $cols, $cut){ + $len=strlen($str); + $tag=0; + for ($i=0;$i<$len;$i++) { + $chr = substr($str,$i,1); + if ($chr=="<") + $tag++; + elseif ($chr==">") + $tag--; + elseif (!$tag && $chr==" ") + $wordlen=0; + elseif (!$tag) + $wordlen++; + if (!$tag && !($wordlen%$cols)) + $chr .= $cut; + $result .= $chr; + } + return $result; + } ?> |