From fd214fdcb78a8e5a23462b9206f35f707bb19ba7 Mon Sep 17 00:00:00 2001 From: Paul Arthur Date: Wed, 23 Jan 2013 11:32:24 -0500 Subject: Mess around with ratings Drop the public variables from the rating class; everyone should use the getters. Add the ability for themes and applications to distinguish between a user's actual rating and the global average rating; in the web interface the average shows up if a user hasn't rated something but at least one other user has. --- templates/show_object_rating.inc.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'templates') diff --git a/templates/show_object_rating.inc.php b/templates/show_object_rating.inc.php index 8fa40fac..0feefd4d 100644 --- a/templates/show_object_rating.inc.php +++ b/templates/show_object_rating.inc.php @@ -29,31 +29,38 @@ /* Create some variables we are going to need */ $web_path = Config::get('web_path'); $base_url = '?action=set_rating&rating_type=' . $rating->type . '&object_id=' . $rating->id; +$othering = false; +$rate = $rating->get_user_rating(); +if (!$rate) { + $rate = $rating->get_average_rating(); + $othering = true; +} ?> -
+
    20% per star) - $width = $rating->preciserating*20; + $width = $rate * 20; if ($width < 0) $width = 0; //set the current rating background - echo "
  • " . T_('Current rating: '); - if ($rating->rating <= 0) { + echo '
  • '; + echo T_('Current rating: '); + if ($rate <= 0) { echo T_('not rated yet') . "
  • \n"; } - else printf(T_('%s of 5'), $rating->preciserating); echo "\n"; + else printf(T_('%s of 5'), $rate); echo "\n"; - for ($i=1; $i<6; $i++) + for ($i = 1; $i < 6; $i++) { ?>
  • - id,'','star'.$i); ?> + id, '', 'star' . $i); ?>
- id,'','star0'); ?> + id, '', 'star0'); ?>
-- cgit