Index: openacs-4/packages/ratings/tcl/rating-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ratings/tcl/rating-procs.tcl,v
diff -u -r1.4.2.5 -r1.4.2.6
--- openacs-4/packages/ratings/tcl/rating-procs.tcl 1 Aug 2005 21:16:56 -0000 1.4.2.5
+++ openacs-4/packages/ratings/tcl/rating-procs.tcl 1 Aug 2005 21:44:34 -0000 1.4.2.6
@@ -338,18 +338,7 @@
} else {
append output ">"
}
- set range_div [expr $i / 5]
- if { ![string equal $range_div 0] } {
- for { set j 0 } { $j < [expr $i / 5] } { incr j } {
- append output "[ratings::icon::html_fragment -icon_key stars -rating 5]"
- }
- set mod_range [expr $i % 5]
- if { ![string equal $mod_range 0] } {
- append output "[ratings::icon::html_fragment -icon_key stars -rating $mod_range]
"
- }
- } else {
- append output "[ratings::icon::html_fragment -icon_key stars -rating $i]
"
- }
+ append output "[ratings::icon::html_fragment -icon_key stars -rating $i]
"
}
append output "
"
append output "
| "
@@ -387,20 +376,7 @@
db_1row get_dimension_info { }
for { set i $range_low } { $i <= $range_high } { incr i } {
- set range_div [expr $i / 5]
- if { ![string equal $range_div 0] } {
- append element "{{"
- for { set j 0 } { $j < [expr $i / 5] } { incr j } {
- append element "[ratings::icon::html_fragment -icon_key stars -rating 5]"
- }
- set mod_range [expr $i % 5]
- if { ![string equal $mod_range 0] } {
- append element "[ratings::icon::html_fragment -icon_key stars -rating $mod_range]"
- }
- append element "} $i } "
- } else {
- append element "{{[ratings::icon::html_fragment -icon_key stars -rating $i]} $i } "
- }
+ append element "{{[ratings::icon::get_icon -icon_key stars -rating $i]} $i } "
}
# This Close the options
append element "}} "
@@ -476,6 +452,32 @@
return [db_string get_average_rating " "]
}
+ad_proc -public ratings::icon::get_icon {
+ {-dimension_key ""}
+ {-icon_key {}}
+ -rating
+} {
+ Returns any number of icons using the ratings::icon::html_fragment proc.
+
+ @param icon_key One of the following stars, lstarts or wp
+ @param rating rate number
+ @param dimension_key The name of the dimension
+} {
+ set icons ""
+ set range_div [expr $rating / 5]
+ if { ![string equal $range_div 0] } {
+ for { set j 0 } { $j < [expr $rating / 5] } { incr j } {
+ append icons "[ratings::icon::html_fragment -dimension_key $dimension_key -icon_key stars -rating 5]"
+ }
+ set mod_range [expr $rating % 5]
+ if { ![string equal $mod_range 0] } {
+ append icons "[ratings::icon::html_fragment -dimension_key $dimension_key -icon_key stars -rating $mod_range]"
+ }
+ } else {
+ append icons "[ratings::icon::html_fragment -dimension_key $dimension_key -icon_key stars -rating $rating]"
+ }
+ return $icons
+}
ad_proc -public ratings::get_rating {
-object_id:required
Index: openacs-4/packages/ratings/www/all-ratings.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ratings/www/Attic/all-ratings.tcl,v
diff -u -r1.1.2.1 -r1.1.2.2
--- openacs-4/packages/ratings/www/all-ratings.tcl 29 Jul 2005 23:09:10 -0000 1.1.2.1
+++ openacs-4/packages/ratings/www/all-ratings.tcl 1 Aug 2005 21:44:34 -0000 1.1.2.2
@@ -111,7 +111,7 @@
and o2.object_id = r.object_id
and r.dimension_id = rd.dimension_id
[template::list::orderby_clause -orderby -name "ratings"]" {
- set rating_img [ratings::icon::html_fragment -rating $rating]
+ set rating_img [ratings::icon::get_icon -rating $rating]
set user_url [acs_community_member_url -user_id $user_id]
set user_ratings_url [export_vars -base ratings [list [list owner_id $user_id]]]
set object_ratings_url [export_vars -base ratings {object_id}]