Index: openacs-4/packages/ams/tcl/ams-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ams/tcl/ams-procs-postgresql.xql,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/ams/tcl/ams-procs-postgresql.xql 18 May 2005 17:11:48 -0000 1.8
+++ openacs-4/packages/ams/tcl/ams-procs-postgresql.xql 27 May 2005 09:46:49 -0000 1.9
@@ -1,87 +1,107 @@
-
-
-
-
-
- select acs_attribute__create_attribute (
- :object_type,
- :attribute_name,
- :datatype,
- :pretty_name,
- :pretty_plural,
- :table_name,
- :column_name,
- :default_value,
- :min_n_values,
- :max_n_values,
- :sort_order,
- :storage,
- :static_p
- )
-
-
-
-
-
- select attribute_id
- from acs_attributes
- where object_type = :object_type
- and attribute_name = :attribute_name
-
-
-
-
-
- select ams_attribute_value__save (
- :object_id,
- :attribute_id,
- :value_id
- )
-
-
-
-
-
- select alam.attribute_id,
- alam.required_p,
- alam.section_heading,
- aa.attribute_name,
- aa.pretty_name,
- aa.widget
- from ams_list_attribute_map alam,
- ams_attributes aa
- where alam.attribute_id = aa.attribute_id
- and alam.list_id = :list_id
- order by alam.sort_order
-
-
-
-
-
- select alam.attribute_id,
- alam.required_p,
- alam.section_heading,
- aa.attribute_name,
- aa.pretty_name,
- aa.widget
- from ams_list_attribute_map alam,
- ams_attributes aa
- where alam.attribute_id = aa.attribute_id
- and alam.list_id = :list_id
- order by alam.sort_order
-
-
-
-
-
- select aav.*, aa.attribute_name, aa.widget, aa.pretty_name,
- ams_attribute_value__value(aav.attribute_id,aav.value_id) as value
- from ams_attribute_values aav,
- ams_attributes aa
- where aav.object_id = :object_id
- and aav.attribute_id = aa.attribute_id
- and aa.attribute_id in ( select attribute_id from ams_list_attribute_map where list_id = :list_id )
-
-
-
-
+
+
+
+
+
+ select acs_attribute__create_attribute (
+ :object_type,
+ :attribute_name,
+ :datatype,
+ :pretty_name,
+ :pretty_plural,
+ :table_name,
+ :column_name,
+ :default_value,
+ :min_n_values,
+ :max_n_values,
+ :sort_order,
+ :storage,
+ :static_p
+ )
+
+
+
+
+
+ select attribute_id
+ from acs_attributes
+ where object_type = :object_type
+ and attribute_name = :attribute_name
+
+
+
+
+
+ select ams_attribute_value__save (
+ :object_id,
+ :attribute_id,
+ :value_id
+ )
+
+
+
+
+
+ select alam.attribute_id,
+ alam.required_p,
+ alam.section_heading,
+ aa.attribute_name,
+ aa.pretty_name,
+ aa.widget
+ from ams_list_attribute_map alam,
+ ams_attributes aa
+ where alam.attribute_id = aa.attribute_id
+ and alam.list_id = :list_id
+ order by alam.sort_order
+
+
+
+
+
+ select alam.attribute_id,
+ alam.required_p,
+ alam.section_heading,
+ aa.attribute_name,
+ aa.pretty_name,
+ aa.widget
+ from ams_list_attribute_map alam,
+ ams_attributes aa
+ where alam.attribute_id = aa.attribute_id
+ and alam.list_id = :list_id
+ order by alam.sort_order
+
+
+
+
+
+ select aav.*, aa.attribute_name, aa.widget, aa.pretty_name,
+ ams_attribute_value__value(aav.attribute_id,aav.value_id) as value
+ from ams_attribute_values aav,
+ ams_attributes aa
+ where aav.object_id = :object_id
+ and aav.attribute_id = aa.attribute_id
+ and aa.attribute_id in ( select attribute_id from ams_list_attribute_map where list_id = :list_id )
+
+
+
+
+
+ select alam.attribute_id,
+ alam.section_heading,
+ aa.attribute_name,
+ aa.pretty_name,
+ aa.widget,
+ av.value
+ from ams_list_attribute_map alam,
+ ams_attributes aa left join (
+ select ams_attribute_values.attribute_id,
+ ams_attribute_value__value(ams_attribute_values.attribute_id,ams_attribute_values.value_id) as value
+ from ams_attribute_values
+ where ams_attribute_values.object_id = :object_id ) av on ( aa.attribute_id = av.attribute_id )
+ where alam.attribute_id = aa.attribute_id
+ and alam.list_id = :list_id
+ order by alam.sort_order
+
+
+
+
Index: openacs-4/packages/ams/tcl/ams-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ams/tcl/ams-procs.tcl,v
diff -u -r1.9 -r1.10
--- openacs-4/packages/ams/tcl/ams-procs.tcl 21 May 2005 20:59:03 -0000 1.9
+++ openacs-4/packages/ams/tcl/ams-procs.tcl 27 May 2005 09:46:49 -0000 1.10
@@ -280,10 +280,37 @@
this code populates ad_form values
} {
set list_id [ams::list::get_list_id -package_key $package_key -object_type $object_type -list_name $list_name]
- db_transaction {
- db_foreach select_values {} {
-# ns_log notice "$widget $attribute_name $value"
- ams::widget -widget $widget -request "form_set_value" -attribute_name $attribute_name -pretty_name $pretty_name -form_name $form_name -attribute_id $attribute_id -value $value
- }
+ db_foreach select_values {} {
+ ams::widget -widget $widget -request "form_set_value" -attribute_name $attribute_name -pretty_name $pretty_name -form_name $form_name -attribute_id $attribute_id -value $value
}
}
+
+ad_proc -public ams::values {
+ -package_key:required
+ -object_type:required
+ -list_name:required
+ -object_id:required
+ {-format "text"}
+} {
+ this returns a list with the first element as the pretty_attribute name and the second the value
+} {
+ if { $format != "html" } {
+ set format "text"
+ }
+ set list_id [ams::list::get_list_id -package_key $package_key -object_type $object_type -list_name $list_name]
+ if { [exists_and_not_null list_id] } {
+ set values [list]
+ set heading ""
+ db_foreach select_values {} {
+ if { [exists_and_not_null section_heading] } {
+ set heading $section_heading
+ }
+ if { [exists_and_not_null value] } {
+ lappend values $heading $attribute_name $pretty_name [ams::widget -widget $widget -request "value_${format}" -attribute_name $attribute_name -attribute_id $attribute_id -value $value]
+ }
+ }
+ return $values
+ } else {
+ return [list]
+ }
+}
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.1 -r1.2
--- openacs-4/packages/ams/tcl/ams-widget-procs.tcl 18 May 2005 17:11:48 -0000 1.1
+++ openacs-4/packages/ams/tcl/ams-widget-procs.tcl 27 May 2005 09:46:49 -0000 1.2
@@ -57,6 +57,20 @@
set options {}
}
}
+ value_text - value_html {
+ if { [exists_and_not_null value] } {
+ if { [::ams::widget_has_options_p -widget $widget] } {
+ set output [list]
+ foreach option [::ams::widget_options -attribute_id $attribute_id] {
+ if { [lsearch $value [lindex $option 1]] >= 0 } {
+ lappend output [lindex $option 0]
+ }
+ }
+ set value [join $output "/n"]
+ }
+ }
+ set options {}
+ }
default {
set options {}
}
@@ -89,7 +103,7 @@
regsub {::ams::widget::} $widget {} widget
lappend widgets [list [::ams::widget -widget $widget -request "widget_name"] $widget]
}
- }
+ }
return $widgets
}
@@ -197,10 +211,12 @@
-postal_type [template::util::address::get_property postal_type $value]]
}
value_text {
- return ${value}
+ foreach {delivery_address municipality region postal_code country_code additional_text postal_type} $value {}
+ return [ad_html_to_text -showtags -no_format [template::util::address::html_view $delivery_address $municipality $region $postal_code $country_code $additional_text $postal_type]]
}
value_html {
- return [ad_html_text_convert -from "text/plain" -to "text/html" ${value}]
+ foreach {delivery_address municipality region postal_code country_code additional_text postal_type} $value {}
+ return [template::util::address::html_view $delivery_address $municipality $region $postal_code $country_code $additional_text $postal_type]
}
csv_value {
# not yet implemented
@@ -277,10 +293,12 @@
-phone_type_id [template::util::telecom_number::get_property phone_type_id $value]]
}
value_text {
- return ${value}
+ foreach {itu_id national_number area_city_code subscriber_number extension sms_enabled_p best_contact_time location phone_type_id} $value {}
+ return [ad_html_to_text -showtags -no_format [template::util::telecom_number::html_view $itu_id $national_number $area_city_code $subscriber_number $extension $sms_enabled_p $best_contact_time $location $phone_type_id]]
}
value_html {
- return [ad_html_text_convert -from "text/plain" -to "text/html" ${value}]
+ foreach {itu_id national_number area_city_code subscriber_number extension sms_enabled_p best_contact_time location phone_type_id} $value {}
+ return [template::util::telecom_number::html_view $itu_id $national_number $area_city_code $subscriber_number $extension $sms_enabled_p $best_contact_time $location $phone_type_id]
}
csv_value {
# not yet implemented
@@ -352,10 +370,10 @@
return [ams::util::time_save -time [template::util::date::get_property ansi $value]]
}
value_text {
- return ${value}
+ return [lc_time_fmt $value %q]
}
value_html {
- return [ad_html_text_convert -from "text/plain" -to "text/html" ${value}]
+ return [ad_html_text_convert -from "text/plain" -to "text/html" [lc_time_fmt $value %q]]
}
csv_value {
# not yet implemented