0ba7d3709fb3a46e74368ee78977f2d267b6ecbe
[speedfreak] / Server / application / controllers / pages.php
1 <?php
2 /**
3  * Static pages controller
4  * 
5  * @todo Refactoring needed
6  * @author Artem Daniliants <artem@daniliants.com>
7  *
8  */
9 class Pages_Controller extends Template_Controller {
10
11         public $template = 'pages/base'; //defaults to template but you can set your own view file
12
13         public $auto_render = TRUE; //defaults to true, renders the template after the controller method is done
14
15         public function __construct()
16         {
17                 parent::__construct(); //necessary
18         }
19         
20         
21         /**
22          * Generate lightbox markup
23          * 
24          * @param array $images
25          */
26         private function lightbox($images){
27                 $output = '';
28                 foreach ($images as $i){
29                         $output .= '<a href="'.url::base().'static/img/screenshots/big/'.$i['img'].'.png" rel="lightbox[screenshots]" title="'.$i['title'].'"><img border=0 class="lightbox_thumbs" src="'.url::base().'static/img/screenshots/small/'.$i['img'].'.png" alt="'.$i['alt'].'"/></a>';
30                 }
31                 return $output;
32         }
33
34         public function index()
35         {
36
37                 $this->template->title = 'Maemo5 application for car enthusiasts and speed freaks';
38                 $this->template->header = 'Home';
39                 
40                 $this->template->content = '
41                         SpeedFreak is a free application for your mobile that allows you to measure your car\'s performance such as acceleration and top speed. In order to make it even 
42 more interesting you can compete against others on our leaderboards to see who\'s car packs the most punch!             
43 <br /><br />
44
45 SpeedFreak is developed by group of enthusiastic programmers with passion for speed and OpenSource. If you want to get involved by contributing code, ideas, bug reports, translation and more just click on
46 community link!
47 ';
48                 $this->template->sidebar_title = 'SpeedFreak for Nokia N900';
49                 $this->template->sidebar_content ='
50 <img src="'.url::base().'static/img/speedfreak_n900.png" /><br />
51 <p>Download SpeedFreak for Nokia N900.</p>
52 <p><a href="#" class="link"><span><span>Download now</span></span></a></p>
53 ';
54
55
56
57         }
58
59         public function leaderboards($category='')
60         {
61                 //@todo: Fix this hack. OMG what a horrible hack. That's what I get for coding at 4am =)
62                 $categories = array('acceleration-0-20' => 'Acceleration from 0 to 20 km/h', 'acceleration-0-40' => 'Acceleration from 0 to 40 km/h', 'acceleration-0-100'=> 'Acceleration from 0 to 100 km/h');
63
64                 if (!array_key_exists($category,$categories))
65                 $category='acceleration-0-100';
66                         
67                 $this->template->title = $categories[$category];
68
69                 $results = new Result_Model();
70                 if ($rows=$results->get_results($category,10)){
71                         $output = '';
72                         foreach ($rows as $r){
73                                 $output .= '
74                         <tr>
75         <td align="right">'.$r->username.'</td>
76         <td align="center">'.$r->value.' seconds</td>
77         <td>'.$r->result_date.'</td>
78 </tr>';
79                         }
80                         $output ='
81 <table cellspacing="20" cellpadding="20">
82 <tr>
83         <td><strong>Nick</strong></td>
84         <td><strong>Record (seconds)</strong></td>
85         <td><strong>Date</strong></td>
86 </tr>
87 '.$output.'
88 </table>
89                 
90 ';
91                 }
92                 else
93                 $output="No results :(";
94
95
96
97                 $this->template->header = $categories[$category];
98                 $this->template->content = $output;
99                 $this->template->sidebar_title = 'Categories';
100                 $this->template->sidebar_content ='
101 <ul class="list">
102         <li><a href="'.url::site('pages/leaderboards/acceleration-0-20').'" title="Leaderboard for acceleration from 0 to 20 km/h category">Acceleration from 0 to 20 km/h</a></li> 
103         <li><a href="'.url::site('pages/leaderboards/acceleration-0-40').'" title="Leaderboard for acceleration from 0 to 40 km/h category">Acceleration from 0 to 40 km/h</a></li> 
104         <li><a href="'.url::site('pages/leaderboards/acceleration-0-100').'" title="Leaderboard for acceleration from 0 to 100 km/h category">Acceleration from 0 to 100 km/h</a></li> 
105 </ul>
106 ';
107
108
109
110         }
111         
112         public function screenshots()
113         {
114                 $this->template->title = 'Screenshots';
115                 $this->template->header = 'Screenshots';
116                 $this->template->head = '
117                 <script type="text/javascript" src="'.url::base().'static/js/prototype.js"></script>
118                 <script type="text/javascript" src="'.url::base().'static/js/scriptaculous.js?load=effects,builder"></script>
119                 <script type="text/javascript" src="'.url::base().'static/js/lightbox.js"></script>
120                 <link rel="stylesheet" href="'.url::base().'static/css/lightbox.css" type="text/css" media="screen" />
121                 ';
122                 
123                 $screenshots=array();
124                 $screenshots[0]['img']=1;
125                 $screenshots[0]['alt']='Main window';
126                 $screenshots[0]['title']='OpenSource Maemo 5 application for car enthusiasts';
127                 
128                 $screenshots[1]['img']=2;
129                 $screenshots[1]['alt']='Acceleration screen';
130                 $screenshots[1]['title']='See how fast your car accelerates and compete for the first position on our leaderboards';
131                 
132                 $screenshots[2]['img']=3;
133                 $screenshots[2]['alt']='Categories window';
134                 $screenshots[2]['title']='You can compete in defferent categories';
135                 
136                 $screenshots[3]['img']=4;
137                 $screenshots[3]['alt']='Route window';
138                 $screenshots[3]['title']='Save your roadtrip route';
139                 
140                 $screenshots[4]['img']=5;
141                 $screenshots[4]['alt']='Registration window';
142                 $screenshots[4]['title']="Participating in our community is as easy as registering for an account";
143                 
144                 $screenshots[5]['img']=6;
145                 $screenshots[5]['alt']='Credits window';
146                 $screenshots[5]['title']='SpeedFreak is developed by a group of dedicated contributors. Join us and help make it even better!';
147                 
148                 $lightbox = $this->lightbox($screenshots);
149                 
150                 $this->template->content = '
151 '.$lightbox.'
152 ';
153                 $this->template->sidebar_title = 'SpeedFreak for Nokia N900';
154                 $this->template->sidebar_content ='
155 <img src="'.url::base().'static/img/speedfreak_n900.png" /><br />
156 <p>Download SpeedFreak for Nokia N900.</p>
157 <p><a href="#" class="link"><span><span>Download now</span></span></a></p>
158 ';
159
160         }
161 }