summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--zoom.php52
1 files changed, 47 insertions, 5 deletions
diff --git a/zoom.php b/zoom.php
index 11bf489..3143946 100644
--- a/zoom.php
+++ b/zoom.php
@@ -39,6 +39,9 @@ require 'include/main.php';
$fedcli = new FedoraPkgdb();
$name = $_GET['rpm'];
+if (isset($_GET['type'])){
+ $type = $_GET['type'];
+}
$smarty->assign('name_required', true);
$smarty->assign('name', $name);
@@ -192,8 +195,47 @@ if ( !isset($name) || !$name ) {
);
}
}
-
-$page_content = $smarty->fetch('zoom.tpl');
-$smarty->assign('page_content', $page_content);
-$smarty->display('main.tpl');
-?> \ No newline at end of file
+if (!isset($type) || $type == "html"){
+ // Displays the output as html
+ $page_content = $smarty->fetch('zoom.tpl');
+ $smarty->assign('page_content', $page_content);
+ $smarty->display('main.tpl');
+} else if ($type == "json"){
+ // Displays the output as json
+ $json = "{";
+ $json .= '"package": "' . $name ."\", ";
+ $json .= '"branch": [';
+ $cnt = 0;
+ foreach ($packages as $package){
+ $cnt += 1;
+ $json .= "{";
+ $json .= '"'. $package->repo_main .'": ';
+ if ($package->epoch){
+ $json .= '"'.$package->epoch.'" ';
+ } else {
+ $json .= '"'.$package->ver."-".$package->rel.'" ';
+ }
+ $json .= "}";
+ if ($cnt != count($packages)){
+ $json .= ",";
+ }
+ }
+ $json .= "]}";
+ echo $json;
+} else if ($type == "text"){
+ // Displays the output as text
+ $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 .= "\n";
+ }
+ echo $text;
+}
+?>