diff options
Diffstat (limited to 'zoom.php')
-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 { |