Added optional parameter to show units in results request
authorArtem Daniliants <artem@daniliants.com>
Wed, 21 Apr 2010 08:06:39 +0000 (11:06 +0300)
committerArtem Daniliants <artem@daniliants.com>
Wed, 21 Apr 2010 08:06:39 +0000 (11:06 +0300)
Server/application/controllers/api.php
Server/application/views/api/results.php

index 0b95e41..fe8a5f7 100644 (file)
@@ -108,12 +108,13 @@ class Api_Controller extends Controller{
      * Get results
      *
      */
-    public function results($category, $limit){
+    public function results($category, $limit, $show_unit=false){
        $results = New Result_Model();
        $cat = New Category_Model();
         if ($cat->category_exists($category) AND $this->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
index d823be0..01ab1a8 100644 (file)
@@ -1,5 +1,5 @@
 <?php echo "<?"; ?>xml version="1.0" encoding="utf-8" <?php echo "?>"; ?>
 
 <results>
-    <?php $i=1; foreach ($results as $r){ ?>   <result username="<?php echo $r->username; ?>" position="<?php echo $i; ?>" date="<?php echo $r->result_date; ?>" unit="<?php echo $r->unit; ?>" value="<?php echo $r->value; ?>" />
+    <?php $i=1; foreach ($results as $r){ ?>   <result username="<?php echo $r->username; ?>" position="<?php echo $i; ?>" date="<?php echo $r->result_date; ?>" <?php if (isset($show_unit) AND $show_unit==false) echo 'unit='.$r->unit.'" '; ?>value="<?php echo $r->value; ?>" />
 <?php $i++; } ?></results>
\ No newline at end of file