diff options
author | spocky <spocky@ampache> | 2008-04-02 12:38:47 +0000 |
---|---|---|
committer | spocky <spocky@ampache> | 2008-04-02 12:38:47 +0000 |
commit | 2544f5b5629d36658f92d4d0ad111563c2442f1b (patch) | |
tree | 74f24fe5d8a40716dfad4f0e5017cce03dd3878b | |
parent | 3c36e58d5441dd5a6990fc24332e69d330edf766 (diff) | |
download | ampache-2544f5b5629d36658f92d4d0ad111563c2442f1b.tar.gz ampache-2544f5b5629d36658f92d4d0ad111563c2442f1b.tar.bz2 ampache-2544f5b5629d36658f92d4d0ad111563c2442f1b.zip |
changed rating display to use 1 digit rounded average, a little bit different than "half star rating" request (Ticket #156), but easily done and also more precise.
minor change to sidebar filter display.
-rw-r--r-- | lib/class/rating.class.php | 14 | ||||
-rw-r--r-- | templates/show_object_rating.inc.php | 4 | ||||
-rw-r--r-- | templates/show_object_rating_static.inc.php | 4 | ||||
-rw-r--r-- | templates/sidebar_browse.inc.php | 2 |
4 files changed, 14 insertions, 10 deletions
diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php index 14c13753..d844cea1 100644 --- a/lib/class/rating.class.php +++ b/lib/class/rating.class.php @@ -32,6 +32,7 @@ class Rating { /* Generated vars */ var $rating; // The average rating as set by all users + var $preciserating; // Rating rounded to 1 decimal /** * Constructor @@ -46,6 +47,7 @@ class Rating { // Check for the users rating if ($rating == $this->get_user($GLOBALS['user']->id)) { $this->rating = $rating; + $this->preciserating = $rating; } else { $this->get_average(); @@ -93,17 +95,19 @@ class Rating { } // while we're pulling results if ($total > 0) { - $average = floor($total/$i); - $this->rating = $average; + $average = round($total/$i, 1); } elseif ($i >= '1' AND $total == '0') { - $this->rating = '-1'; + $average = -1; } else { - $this->rating = '0'; + $average = 0; } - return $average; + $this->preciserating = $average; + $this->rating = floor($average); + + return $this->rating; } // get_average diff --git a/templates/show_object_rating.inc.php b/templates/show_object_rating.inc.php index e028b89f..82ae5047 100644 --- a/templates/show_object_rating.inc.php +++ b/templates/show_object_rating.inc.php @@ -27,7 +27,7 @@ $base_url = '?action=set_rating&rating_type=' . $rating->type . '&object_id=' . <ul> <?php // decide width of rating (5 stars -> 20% per star) - $width = $rating->rating*20; + $width = $rating->preciserating*20; if ($width < 0) $width = 0; //set the current rating background @@ -35,7 +35,7 @@ $base_url = '?action=set_rating&rating_type=' . $rating->type . '&object_id=' . if ($rating->rating <= 0) { echo "not rated yet </li>\n"; } - else echo "$rating->rating of 5</li>\n"; + else echo "$rating->preciserating of 5</li>\n"; for ($i=1; $i<6; $i++) { diff --git a/templates/show_object_rating_static.inc.php b/templates/show_object_rating_static.inc.php index 5fcd4f18..a8359f5b 100644 --- a/templates/show_object_rating_static.inc.php +++ b/templates/show_object_rating_static.inc.php @@ -27,7 +27,7 @@ $base_url = Config::get('ajax_url') . '?action=set_rating&rating_type=' . $r <ul> <?php // decide width of rating (5 stars -> 20% per star) - $width = $rating->rating*20; + $width = $rating->preciserating*20; if ($width < 0) $width = 0; //set the current rating background @@ -35,7 +35,7 @@ $base_url = Config::get('ajax_url') . '?action=set_rating&rating_type=' . $r if ($rating->rating <= 0) { echo "not rated yet </li>\n"; } - else echo "$rating->rating of 5</li>\n"; + else echo "$rating->preciserating of 5</li>\n"; for ($i=1; $i<6; $i++) { diff --git a/templates/sidebar_browse.inc.php b/templates/sidebar_browse.inc.php index 936e847c..7bef4348 100644 --- a/templates/sidebar_browse.inc.php +++ b/templates/sidebar_browse.inc.php @@ -43,8 +43,8 @@ $allowed_filters = Browse::get_allowed_filters(); <div class="sb3"> <?php if (in_array('alpha_match',$allowed_filters)) { ?> <form id="multi_alpha_filter_form" method="post" action="javascript:void(0);"> - <input type="textbox" id="multi_alpha_filter" name="multi_alpha_filter" value="<?php echo scrub_out($_REQUEST['alpha_match']); ?>" onKeyUp="DelayRun(this,'400','ajaxState','<?php echo Config::get('ajax_url'); ?>?page=browse&action=browse&key=alpha_match','multi_alpha_filter');"> <label id="multi_alpha_filterLabel" for="multi_alpha_filter"><?php echo _('Starts With'); ?></label> + <input type="textbox" id="multi_alpha_filter" name="multi_alpha_filter" value="<?php echo scrub_out($_REQUEST['alpha_match']); ?>" onKeyUp="DelayRun(this,'400','ajaxState','<?php echo Config::get('ajax_url'); ?>?page=browse&action=browse&key=alpha_match','multi_alpha_filter');"> </form> <?php } // end if alpha_match ?> <?php if (in_array('minimum_count',$allowed_filters)) { ?> |