1 | <?php |
---|
2 | require_once("class.graph.php"); |
---|
3 | require_once("globals.php"); |
---|
4 | |
---|
5 | class Box |
---|
6 | { |
---|
7 | function Box($title = '') |
---|
8 | { |
---|
9 | $this->title_ = $title; |
---|
10 | $this->box_array = array(); |
---|
11 | } |
---|
12 | |
---|
13 | // its called setIcon... and it sets the Icon. |
---|
14 | function setIcon($icon) |
---|
15 | { |
---|
16 | $this->icon_ = $icon; |
---|
17 | } |
---|
18 | |
---|
19 | // add something to the array that we send to smarty later... |
---|
20 | // types can be caption, img, link, points. Only link needs all 3 attribues |
---|
21 | function addOption($type, $name, $url = '') |
---|
22 | { |
---|
23 | $this->box_array[] = array('type' => $type, 'name' => $name, 'url' => $url); |
---|
24 | } |
---|
25 | |
---|
26 | function generate() |
---|
27 | { |
---|
28 | global $smarty; |
---|
29 | |
---|
30 | $smarty->assign('count', count($this->box_array)); |
---|
31 | if ($this->icon_) |
---|
32 | { |
---|
33 | $smarty->assign('icon', IMG_URL."/".$this->icon_); |
---|
34 | } |
---|
35 | $smarty->assign('title', $this->title_ ); |
---|
36 | $smarty->assign('items', $this->box_array); |
---|
37 | |
---|
38 | return $smarty->fetch(get_tpl('box')); |
---|
39 | } |
---|
40 | } |
---|
41 | |
---|
42 | class AwardBox |
---|
43 | { |
---|
44 | function AwardBox($list, $title, $comment, $entity, $award) |
---|
45 | { |
---|
46 | $this->toplist_ = $list; |
---|
47 | $this->title_ = $title; |
---|
48 | $this->comment_ = $comment; |
---|
49 | $this->entity_ = $entity; |
---|
50 | $this->award_ = $award; |
---|
51 | } |
---|
52 | |
---|
53 | function generate() |
---|
54 | { |
---|
55 | global $config, $smarty; |
---|
56 | |
---|
57 | $rows = array(); |
---|
58 | $max = 0; |
---|
59 | |
---|
60 | for ($i = 1; $i < 11; $i++) |
---|
61 | { |
---|
62 | $row = $this->toplist_->getRow(); |
---|
63 | if ($row) |
---|
64 | { |
---|
65 | array_push($rows, $row); |
---|
66 | } |
---|
67 | if ($row['cnt'] > $max) |
---|
68 | { |
---|
69 | $max = $row['cnt']; |
---|
70 | } |
---|
71 | } |
---|
72 | |
---|
73 | if (!$rows[0]['plt_id']) |
---|
74 | { |
---|
75 | return; |
---|
76 | } |
---|
77 | |
---|
78 | $pilot = new Pilot($rows[0]['plt_id']); |
---|
79 | $smarty->assign('title', $this->title_); |
---|
80 | $smarty->assign('pilot_portrait', $pilot->getPortraitURL(64)); |
---|
81 | $smarty->assign('award_img', IMG_URL."/awards/".$this->award_.".gif"); |
---|
82 | $smarty->assign('url', "?a=pilot_detail&plt_id=".$rows[0]['plt_id'] ); |
---|
83 | $smarty->assign('name', $pilot->getName() ); |
---|
84 | |
---|
85 | $bar = new BarGraph($rows[0]['cnt'], $max, 60); |
---|
86 | $smarty->assign('bar', $bar->generate()); |
---|
87 | $smarty->assign('cnt', $rows[0]['cnt']); |
---|
88 | |
---|
89 | for ($i = 2; $i < 11; $i++) |
---|
90 | { |
---|
91 | if (!$rows[$i - 1]['plt_id']) |
---|
92 | { |
---|
93 | break; |
---|
94 | } |
---|
95 | $pilot = new Pilot($rows[$i - 1]['plt_id']); |
---|
96 | $bar = new BarGraph($rows[$i - 1]['cnt'], $max, 60); |
---|
97 | $top[$i] = array('url'=> "?a=pilot_detail&plt_id=".$rows[$i - 1]['plt_id'], 'name'=>$pilot->getName(), 'bar'=>$bar->generate(), 'cnt'=>$rows[$i - 1]['cnt']); |
---|
98 | } |
---|
99 | |
---|
100 | $smarty->assign('top', $top); |
---|
101 | $smarty->assign('comment', $this->comment_); |
---|
102 | return $smarty->fetch(get_tpl('award_box')); |
---|
103 | } |
---|
104 | } |
---|
105 | ?> |
---|