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