Last change
on this file since 24721 was
21542,
checked in by mistic100, 12 years ago
|
directly use Piwigo functions for email and url check (break compatibility < 2.5)
|
File size:
834 bytes
|
Line | |
---|
1 | <?php |
---|
2 | if (!defined('GUESTBOOK_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | function get_stars($score, $path) |
---|
5 | { |
---|
6 | if ($score === null) return null; |
---|
7 | |
---|
8 | $max = 5; |
---|
9 | $score = min(max($score, 0), $max); |
---|
10 | $floor = floor($score); |
---|
11 | |
---|
12 | $html = null; |
---|
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 | } |
---|
41 | |
---|
42 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.