Index: openacs-4/packages/ecommerce/tcl/ecds-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/tcl/ecds-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/ecommerce/tcl/ecds-procs.tcl 9 Aug 2008 07:11:51 -0000 1.1 +++ openacs-4/packages/ecommerce/tcl/ecds-procs.tcl 12 Aug 2008 11:58:37 -0000 1.2 @@ -859,13 +859,35 @@ ad_proc -private ecds_abbreviate { phrase + {max_length {}} } { - abbreviates a pretty title or phrase to first word + abbreviates a pretty title or phrase to first word, or to max_length characters if max_length is a number > 0 } { - regsub -all { .*$} $phrase {..} abbrev1 - regsub -all {\-.*$} $abbrev1 {..} abbrev - regsub -all {\,.*$} $abbrev {..} abbrev1 - return $abbrev1 + set suffix ".." + set suffix_len [string length $suffix] + + if { [ad_var_type_check_number_p $max_length] && $max_length > 0 } { + set phrase_len_limit [expr { $max_length - $suffix_len } ] + regsub -all -- { / } $phrase {/} phrase + if { [string length $phrase] > $max_length } { + set cat_end [expr { [string last " " [string range $phrase 0 $max_length] ] - 1 } ] + if { $cat_end < 0 } { + set cat_end $phrase_len_limit + } + set phrase [string range $phrase 0 $cat_end ] + append phrase $suffix + regsub {[^a-zA-Z0-9]+\.\.} $phrase $suffix phrase + } + regsub -all -- { } $phrase {\ } phrase + set abbrev_phrase $phrase + + } else { + regsub -all { .*$} $phrase $suffix abbrev1 + regsub -all {\-.*$} $abbrev1 $suffix abbrev + regsub -all {\,.*$} $abbrev $suffix abbrev1 + set abbrev_phrase $abbrev1 + } + return $abbrev_phrase } ad_proc -private ecds_thumbnail_dimensions {