summaryrefslogtreecommitdiffstats
path: root/templates/show_object_rating.inc.php
blob: 831b6b406019ff7f7947a37a3d218607ba6ce2e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/*
 Copyright 2001 - 2006 Ampache.org
 All Rights Reserved

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/
if ($type != 'song') { 
	echo "<strong>" . _("Rating") . ":</strong>";
}

/* Create some variables we are going to need */
$web_path = conf('web_path');
$base_url = $web_path . '/ratings.php?action=set_rating&amp;mode=' . conf('flash') . '&amp;rating_type=' . $rating->type . '&amp;object_id=' . $rating->id . '&amp;username=' . $GLOBALS['user']->username;
$score = '0';

/* count up to 6 */
while ($score < 6) { 
	/* Handle the "Not rated" possibility */
	if ($score == '0' AND $rating->rating == '-1') { 
		echo "<img src=\"" . $web_path . "/images/ratings/x.gif\" border=\"0\" alt=\"" . get_rating_name($score) . "\" />\n";
		$found_on = true;
	}
	elseif ($score == '0' AND $rating->rating == '0') { 
		echo "<img src=\"" . $web_path . "/images/ratings/x_off.gif\" border=\"0\" alt=\"" . get_rating_name($score) . "\" />\n";
		$found_on = true;
	}
	elseif ($score == '0') { 
		echo "<a href=\"" . $base_url . "&amp;rating=$score\">\n\t";
		echo "<img src=\"" . $web_path . "/images/ratings/x_off.gif\" border=\"0\" alt=\"" . get_rating_name($score) . "\" />\n";
		echo "</a>";
	}
	elseif ($score == $rating->rating) { 
		echo "<img src=\"" . $web_path . "/images/ratings/star.gif\" border=\"0\" alt=\"" . get_rating_name($score) . "\" />\n";
		$found_on = true;
	}
	elseif (!$found_on) { 
		echo "<a href=\"" . $base_url . "&amp;rating=$score\">\n\t<img src=\"" . $web_path . "/images/ratings/star.gif\" border=\"0\" alt=\"" . get_rating_name($score) . "\" />\n</a>\n";
	}
	else { 
		echo "<a href=\"" . $base_url . "&amp;rating=$score\">\n\t<img src=\"" . $web_path . "/images/ratings/star_off.gif\" border=\"0\" alt=\"" . get_rating_name($score) . "\" />\n</a>\n";
	}
	/* Next! */
	$score++;
} // end while
?>