Index: openacs-4/packages/ams/tcl/ams-widget-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/tcl/ams-widget-procs.tcl,v diff -u -r1.19 -r1.20 --- openacs-4/packages/ams/tcl/ams-widget-procs.tcl 4 Jan 2006 09:48:25 -0000 1.19 +++ openacs-4/packages/ams/tcl/ams-widget-procs.tcl 31 Jan 2006 00:23:54 -0000 1.20 @@ -788,13 +788,7 @@ @see ams::widget } { - # We save this value to use in the display - set org_value $value - - # We escape all characters, since you can't use a string that has "{" "}" "[" "]" as a list - regsub -all {[\]\[\{\}\"\\$]} $value {\\&} value - set value_format [lindex $value 0] - set value [lrange $value 1 end] + set value [ams::util::text_value -value $value] switch $request { ad_form_widget { if { [string is true $optional_p] } { @@ -827,15 +821,11 @@ return [ams::util::text_save -text $value -text_format "text/plain"] } value_text { - # We return the original string here without the format part otherwise it will return scaped characters - set value [string range $org_value [expr [string length $value_format] + 1] [string length $org_value]] return ${value} } value_html { - # We return the original string here without the format part otherwise it will return scaped characters - set value [string range $org_value [expr [string length $value_format] + 1] [string length $org_value]] -# return [ad_html_text_convert -from "text/plain" -to "text/html" -- ${value}] - return $value + return [ad_html_text_convert -from "text/plain" -to "text/html" -- ${value}] +# return $value } csv_value { # not yet implemented @@ -872,13 +862,7 @@ @see ams::widget } { - # We save this value to use in the display - set org_value $value - - # We escape all characters, since you can't use a string that has "{" "}" "[" "]" as a list - regsub -all {[\]\[\{\}\"\\$]} $value {\\&} value - set value_format [lindex $value 0] - set value [lrange $value 1 end] + set value [ams::util::text_value -value $value] switch $request { ad_form_widget { if { [string is true $optional_p] } { @@ -911,15 +895,10 @@ return [ams::util::text_save -text $value -text_format "text/plain"] } value_text { - # We return the original string here without the format part otherwise it will return scaped characters - set value [string range $org_value [expr [string length $value_format] + 1] [string length $org_value]] return ${value} } value_html { - # We return the original string here without the format part otherwise it will return scaped characters - set value [string range $org_value [expr [string length $value_format] + 1] [string length $org_value]] -# return [ad_html_text_convert -from "text/plain" -to "text/html" -- ${value}] - return ${value} + return [ad_html_text_convert -from "text/plain" -to "text/html" -- ${value}] } csv_value { # not yet implemented @@ -956,8 +935,8 @@ @see ams::widget } { - set value_format [lindex $value 0] - set value [lrange $value 1 end] + set value_format [ams::util::text_format -value $value] + set value [ams::util::text_value -value $value] switch $request { ad_form_widget { if { [string is true $optional_p] } { @@ -992,11 +971,10 @@ -text_format [template::util::richtext::get_property format $value]] } value_text { - return ${value} + return [ad_html_text_convert -from $value_format -to "text/plain" -- ${value}] } value_html { -# return [ad_html_text_convert -from "text/plain" -to "text/html" -- ${value}] - return ${value} + return [ad_html_text_convert -from $value_format -to "text/html" -- ${value}] } csv_value { # not yet implemented @@ -1033,8 +1011,7 @@ @see ams::widget } { - set value_format [lindex $value 0] - set value [lrange $value 1 end] + set value [ams::util::text_value -value $value] switch $request { ad_form_widget { if { [string is true $optional_p] } { @@ -1107,8 +1084,7 @@ @see ams::widget } { - set value_format [lindex $value 0] - set value [lrange $value 1 end] + set value [ams::util::text_value -value $value] switch $request { ad_form_widget { if { [string is true $optional_p] } { @@ -1178,6 +1154,31 @@ } } +ad_proc -private ams::util::text_value { + -value:required +} { + return the value part of a text value +} { + if { [empty_string_p $value] } { + return "" + } else { + regexp -all "^\{(.*?)\} (.*)$" $value match format value + return $value + }} + +ad_proc -private ams::util::text_format { + -value:required +} { + return a the text part of a text value +} { + if { [empty_string_p $value] } { + return "" + } else { + regexp -all "^\{(.*?)\} (.*)$" $value match format value + return $format + } +} + ad_proc -private ams::util::time_save { -time:required } { @@ -1534,4 +1535,4 @@ ams::attribute::value_save -object_id $object_id -attribute_id $attribute_id -value_id $value_id ns_log Notice "AMS MC:: $object_id - $attribute_id - $value_id" } -} \ No newline at end of file +}