Created first draft of the site
[speedfreak] / Server / application / controllers / pages.php
1 <?php
2 class Pages_Controller extends Template_Controller {
3
4         public $template = 'pages/base'; //defaults to template but you can set your own view file
5
6         public $auto_render = TRUE; //defaults to true, renders the template after the controller method is done
7
8         public function __construct()
9         {
10                 parent::__construct(); //necessary
11         }
12
13         public function index()
14         {
15                 $this->template->title = 'Maemo5 application for car enthusiasts and speed freaks';
16                 $this->template->header = 'Home';
17                 $this->template->content = '
18 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 
19 more interesting you can compete against others on our leaderboards to see who\'s car packs the most punch!             
20 <br /><br />
21
22 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
23 community link!
24 ';
25                 $this->template->sidebar_title = 'SpeedFreak for Nokia N900';
26                 $this->template->sidebar_content ='
27 <img src="'.url::base().'static/img/speedfreak_n900.png" /><br />
28 <p>Download SpeedFreak for Nokia N900.</p>
29 <p><a href="#" class="link"><span><span>Download now</span></span></a></p>
30 ';
31
32
33
34         }
35
36         public function leaderboards($category='')
37         {
38                 //@todo: Fix this hack. OMG what a horrible hack. That's what I get for coding at 4am =)
39                 $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');
40
41                 if (!array_key_exists($category,$categories))
42                 $category='acceleration-0-100';
43                         
44                 $this->template->title = $categories[$category];
45
46                 $results = new Result_Model();
47                 if ($rows=$results->get_results($category,10)){
48                         $output = '';
49                         foreach ($rows as $r){
50                                 $output .= '
51                         <tr>
52         <td align="right">'.$r->username.'</td>
53         <td align="center">'.$r->value.' seconds</td>
54         <td>'.$r->result_date.'</td>
55 </tr>';
56                         }
57                         $output ='
58 <table cellspacing="20" cellpadding="20">
59 <tr>
60         <td><strong>Nick</strong></td>
61         <td><strong>Record (seconds)</strong></td>
62         <td><strong>Date</strong></td>
63 </tr>
64 '.$output.'
65 </table>
66                 
67 ';
68                 }
69                 else
70                 $output="No results :(";
71
72
73
74                 $this->template->header = $categories[$category];
75                 $this->template->content = $output;
76                 $this->template->sidebar_title = 'Categories';
77                 $this->template->sidebar_content ='
78 <ul class="list">
79         <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> 
80         <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> 
81         <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> 
82 </ul>
83 ';
84
85
86
87         }
88         
89         public function screenshots()
90         {
91                 $this->template->title = 'Screenshots';
92                 $this->template->header = 'Screenshots';
93                 $this->template->content = '
94 Our freaky elfs are still working on those. Check back later =)
95 ';
96                 $this->template->sidebar_title = 'SpeedFreak for Nokia N900';
97                 $this->template->sidebar_content ='
98 <img src="'.url::base().'static/img/speedfreak_n900.png" /><br />
99 <p>Download SpeedFreak for Nokia N900.</p>
100 <p><a href="#" class="link"><span><span>Download now</span></span></a></p>
101 ';
102
103
104
105         }
106 }