diff options
| author | Remi Collet <fedora@famillecollet.com> | 2010-09-19 10:30:28 +0200 | 
|---|---|---|
| committer | Remi Collet <fedora@famillecollet.com> | 2010-09-19 10:30:28 +0200 | 
| commit | 9689e536a9c72251fc20512f81a24b3a92a53c22 (patch) | |
| tree | 9f8ba704cee5e93277073ed3a885da0f553dfdac | |
| parent | 17b1b4b609c3437744b127427d9f366b93eb8910 (diff) | |
add header + fix version when epoch
| -rw-r--r-- | zoom.php | 25 | 
1 files changed, 13 insertions, 12 deletions
| @@ -193,22 +193,23 @@ if ( !isset($name) || !$name ) {          );      }  } +  if ($type == "json") { -    // Displays the output as json +    // Displays the output as json (TODO : why not use json_encode) +    header('Content-Type: application/json'); +      $json = "{"; -    $json .= '"package": "' . $name ."\", "; -    $json .= '"branch": ['; +    $json .= '"package":"' . $name ."\","; +    $json .= '"branch":[';      $cnt = 0;      foreach ($packages as $package) {          $cnt += 1;          $json .= "{"; -        $json .= '"'. $package->repo_main .'": '; +        $json .= '"'. $package->repo_main .'":"';          if ($package->epoch) { -            $json .= '"'.$package->epoch.'" '; -        } else { -            $json .= '"'.$package->ver."-".$package->rel.'" '; +            $json .= $package->epoch.':';          } -        $json .= "}"; +        $json .= $package->ver."-".$package->rel.'"}';          if ($cnt != count($packages)) {              $json .= ",";          } @@ -217,17 +218,17 @@ if ($type == "json") {      echo $json;  } else if ($type == "text") {      // Displays the output as text +    header('Content-Type: text/plain'); +      $text = 'package: ' . $name ." \n";      $cnt = 0;      foreach ($packages as $package) {          $cnt += 1;          $text .= $package->repo_main .': ';          if ($package->epoch) { -            $text .= $package->epoch; -        } else { -            $text .= $package->ver."-".$package->rel; +            $text .= $package->epoch.':';          } -        $text .= "\n"; +        $text .= $package->ver."-".$package->rel."\n";      }      echo $text;  } else { | 
