Index: openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl 4 Sep 2002 13:32:17 -0000 1.7 +++ openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl 8 Sep 2002 17:58:58 -0000 1.8 @@ -1269,9 +1269,46 @@ } +##### +# +# Truncate +# +##### +ad_proc string_truncate { + {-len 200} + {-format html} + string +} { + Truncates a string to len characters (defaults to the + parameter TruncateDescriptionLength), adding an ellipsis (...) if the + string was truncated. If format is html (default), any open + HTML tags are closed. Otherwise, it's converted to text using + ad_html_to_text. + @param len The lenght to truncate to. Defaults to parameter TruncateDescriptionLength. + @param format html or text. + @param string The string to truncate. + @return The truncated string, with HTML tags cloosed or + converted to text, depending on format. + @author Lars Pind (lars@pinds.com) + @creation-date September 8, 2002 +} { + if { [string length $string] > $len } { + set string "[string range $string 0 $len]..." + } + + if { [string equal $format "html"] } { + set string [util_close_html_tags $string] + } else { + set string [ad_html_to_text -- $string] + } + return $string +} + + + #################### # # Legacy stuff