Added login functionality to users controller
[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 <center>
42 <object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/edKtuF__L_8&hl=en_US&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/edKtuF__L_8&hl=en_US&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>
43 </center>
44 <br />
45 <br />          
46                         
47 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 
48 more interesting you can compete against others on our leaderboards to see who\'s car packs the most punch!             
49 <br /><br />
50
51 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
52 community link!
53 ';
54                 $this->template->sidebar_title = 'SpeedFreak for Nokia N900';
55                 $this->template->sidebar_content ='
56 <img src="'.url::base().'static/img/speedfreak_n900.png" /><br />
57 <p>Download SpeedFreak for Nokia N900.</p>
58 <p><a href="https://garage.maemo.org/projects/speedfreak/" class="link"><span><span>Download now</span></span></a></p>
59 ';
60
61
62
63         }
64
65         public function leaderboards($category='')
66         {
67                 //@todo: Fix this hack. OMG what a horrible hack. That's what I get for coding at 4am =)
68                 $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');
69
70                 if (!array_key_exists($category,$categories))
71                 $category='acceleration-0-100';
72                         
73                 $this->template->title = $categories[$category];
74
75                 $results = new Result_Model();
76                 if ($rows=$results->get_results($category,10)){
77                         $output = '';
78                         foreach ($rows as $r){
79                                 $output .= '
80                         <tr>
81         <td align="right">'.$r->username.'</td>
82         <td align="center">'.$r->value.' seconds</td>
83         <td>'.$r->result_date.'</td>
84 </tr>';
85                         }
86                         $output ='
87 <table cellspacing="20" cellpadding="20">
88 <tr>
89         <td><strong>Nick</strong></td>
90         <td><strong>Record (seconds)</strong></td>
91         <td><strong>Date</strong></td>
92 </tr>
93 '.$output.'
94 </table>
95                 
96 ';
97                 }
98                 else
99                 $output="No results :(";
100
101
102
103                 $this->template->header = $categories[$category];
104                 $this->template->content = $output;
105                 $this->template->sidebar_title = 'Categories';
106                 $this->template->sidebar_content ='
107 <ul class="list">
108         <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> 
109         <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> 
110         <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> 
111 </ul>
112 ';
113
114
115
116         }
117         
118         public function screenshots()
119         {
120                 $this->template->title = 'Screenshots';
121                 $this->template->header = 'Screenshots';
122                 $this->template->head = '
123                 <script type="text/javascript" src="'.url::base().'static/js/prototype.js"></script>
124                 <script type="text/javascript" src="'.url::base().'static/js/scriptaculous.js?load=effects,builder"></script>
125                 <script type="text/javascript" src="'.url::base().'static/js/lightbox.js"></script>
126                 <link rel="stylesheet" href="'.url::base().'static/css/lightbox.css" type="text/css" media="screen" />
127                 ';
128                 
129                 $screenshots=array();
130                 $screenshots[0]['img']=1;
131                 $screenshots[0]['alt']='Main window';
132                 $screenshots[0]['title']='OpenSource Maemo 5 application for car enthusiasts';
133                 
134                 $screenshots[1]['img']=2;
135                 $screenshots[1]['alt']='Acceleration screen';
136                 $screenshots[1]['title']='See how fast your car accelerates and compete for the first position on our leaderboards';
137                 
138                 $screenshots[2]['img']=3;
139                 $screenshots[2]['alt']='Categories window';
140                 $screenshots[2]['title']='You can compete in defferent categories';
141                 
142                 $screenshots[3]['img']=4;
143                 $screenshots[3]['alt']='Route window';
144                 $screenshots[3]['title']='Save your roadtrip route';
145                 
146                 $screenshots[4]['img']=5;
147                 $screenshots[4]['alt']='Registration window';
148                 $screenshots[4]['title']="Participating in our community is as easy as registering for an account";
149                 
150                 $screenshots[5]['img']=6;
151                 $screenshots[5]['alt']='Credits window';
152                 $screenshots[5]['title']='SpeedFreak is developed by a group of dedicated contributors. Join us and help make it even better!';
153                 
154                 $lightbox = $this->lightbox($screenshots);
155                 
156                 $this->template->content = '
157 '.$lightbox.'
158 ';
159                 $this->template->sidebar_title = 'SpeedFreak for Nokia N900';
160                 $this->template->sidebar_content ='
161 <img src="'.url::base().'static/img/speedfreak_n900.png" /><br />
162 <p>Download SpeedFreak for Nokia N900.</p>
163 <p><a href="#" class="link"><span><span>Download now</span></span></a></p>
164 ';
165
166         }
167 }