From: <par...@us...> - 2009-05-20 17:10:26
|
Update of /cvsroot/phpicalendar/phpicalendar/functions/init In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3322/functions/init Modified Files: sanitize.php Log Message: Force makeTitle() to limit the amount of text put into a title Index: sanitize.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/init/sanitize.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sanitize.php 20 May 2009 16:44:20 -0000 1.3 --- sanitize.php 20 May 2009 17:10:10 -0000 1.4 *************** *** 34,37 **** --- 34,54 ---- + /** + * Truncate a string to a specific number of words + */ + function chopToWordCount($string, $count) { + $wc = str_word_count($string); + if ($wc > $count) { + $words = str_word_count($string, 2); + $last_word = array_slice($words, $count, 1, true); + $pos = key($last_word); + $string = substr($string, 0, $pos); + } + return $string; + } + + /** + * Strip "dangerous" HTML to make it safe to print to web browsers + */ function sanitizeForWeb($string) { $string = preg_replace('/<br\s*\/?>/', "\n", $string); |