예제 #1
0
 public function list_results($category, $limit, $show_unit = false)
 {
     $results = new Result_Model();
     $cat = new Category_Model();
     if ($cat->category_exists($category) and apiler::is_authorized() and isset($limit)) {
         $view = new View('api/results');
         $view->results = $results->get_results($category, $limit);
         $view->show_unit = $show_unit;
         $view->render(true);
     } else {
         apiler::not_authorized();
     }
 }
예제 #2
0
파일: pages.php 프로젝트: ArtemD/SpeedFreak
    public function leaderboards($category = '')
    {
        //@todo: Fix this hack. OMG what a horrible hack. That's what I get for coding at 4am =)
        $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');
        if (!array_key_exists($category, $categories)) {
            $category = 'acceleration-0-100';
        }
        $this->template->title = $categories[$category];
        $results = new Result_Model();
        if ($rows = $results->get_results($category, 10)) {
            $output = '';
            foreach ($rows as $r) {
                $output .= '
			<tr>
	<td align="right">' . $r->username . '</td>
	<td align="center">' . $r->value . ' seconds</td>
	<td>' . $r->result_date . '</td>
</tr>';
            }
            $output = '
<table cellspacing="20" cellpadding="20">
<tr>
	<td><strong>Nick</strong></td>
	<td><strong>Record (seconds)</strong></td>
	<td><strong>Date</strong></td>
</tr>
' . $output . '
</table>
		
';
        } else {
            $output = "No results :(";
        }
        $this->template->header = $categories[$category];
        $this->template->content = $output;
        $this->template->sidebar_title = 'Categories';
        $this->template->sidebar_content = '
<ul class="list">
	<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> 
	<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> 
	<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> 
</ul>
';
    }