Last change
on this file since 28250 was
26065,
checked in by mistic100, 11 years ago
|
update for Piwigo 2.6 + code clean
|
File size:
824 bytes
|
Line | |
---|
1 | <?php |
---|
2 | defined('GUESTBOOK_PATH') or die('Hacking attempt!'); |
---|
3 | |
---|
4 | function get_stars($score, $path) |
---|
5 | { |
---|
6 | if (!isset($score)) return null; |
---|
7 | |
---|
8 | $max = 5; |
---|
9 | $score = min(max($score, 0), $max); |
---|
10 | $floor = floor($score); |
---|
11 | |
---|
12 | $html = ''; |
---|
13 | for ($i=1; $i<=$floor; $i++) |
---|
14 | { |
---|
15 | $html.= '<img alt="'.$i.'" src="'.$path.'star-on.png">'; |
---|
16 | } |
---|
17 | |
---|
18 | if ($score != $max) |
---|
19 | { |
---|
20 | if ($score-$floor <= .25) |
---|
21 | { |
---|
22 | $html.= '<img alt="'.($floor+1).'" src="'.$path.'star-off.png">'; |
---|
23 | } |
---|
24 | else if ($score-$floor <= .75) |
---|
25 | { |
---|
26 | $html.= '<img alt="'.($floor+1).'" src="'.$path.'star-half.png">'; |
---|
27 | } |
---|
28 | else |
---|
29 | { |
---|
30 | $html.= '<img alt="'.($floor+1).'" src="'.$path.'star-on.png">'; |
---|
31 | } |
---|
32 | |
---|
33 | for ($i=$floor+2; $i<=$max; $i++) |
---|
34 | { |
---|
35 | $html.= '<img alt="'.$i.'" src="'.$path.'star-off.png">'; |
---|
36 | } |
---|
37 | } |
---|
38 | |
---|
39 | return $html; |
---|
40 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.