summaryrefslogtreecommitdiffstats
path: root/zoom.php
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2010-09-19 10:00:21 +0200
committerRemi Collet <fedora@famillecollet.com>2010-09-19 10:00:21 +0200
commit0275880dbd7380b5b6a38a6902aef4063fc89f63 (patch)
tree0d4205e434b649be3db0e0718f8ef9c322a6ba60 /zoom.php
parent715ba4df3faccf9839f7e194bf41078cae91027b (diff)
patch from pingou
Diffstat (limited to 'zoom.php')
-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;
+}
+?>