summaryrefslogtreecommitdiffstats
path: root/zoom.php
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2010-09-19 10:30:28 +0200
committerRemi Collet <fedora@famillecollet.com>2010-09-19 10:30:28 +0200
commit9689e536a9c72251fc20512f81a24b3a92a53c22 (patch)
tree9f8ba704cee5e93277073ed3a885da0f553dfdac /zoom.php
parent17b1b4b609c3437744b127427d9f366b93eb8910 (diff)
add header + fix version when epoch
Diffstat (limited to 'zoom.php')
-rw-r--r--zoom.php25
1 files changed, 13 insertions, 12 deletions
diff --git a/zoom.php b/zoom.php
index 39381a7..c36c2c5 100644
--- a/zoom.php
+++ b/zoom.php
@@ -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 {