From 17b1b4b609c3437744b127427d9f366b93eb8910 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sun, 19 Sep 2010 10:06:10 +0200 Subject: clean + coding standard --- zoom.php | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'zoom.php') diff --git a/zoom.php b/zoom.php index 3143946..39381a7 100644 --- a/zoom.php +++ b/zoom.php @@ -39,9 +39,7 @@ require 'include/main.php'; $fedcli = new FedoraPkgdb(); $name = $_GET['rpm']; -if (isset($_GET['type'])){ - $type = $_GET['type']; -} +$type = (isset($_GET['type']) ? $_GET['type'] : "html"); $smarty->assign('name_required', true); $smarty->assign('name', $name); @@ -195,41 +193,36 @@ if ( !isset($name) || !$name ) { ); } } -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"){ +if ($type == "json") { // Displays the output as json $json = "{"; $json .= '"package": "' . $name ."\", "; $json .= '"branch": ['; $cnt = 0; - foreach ($packages as $package){ + foreach ($packages as $package) { $cnt += 1; $json .= "{"; $json .= '"'. $package->repo_main .'": '; - if ($package->epoch){ + if ($package->epoch) { $json .= '"'.$package->epoch.'" '; } else { $json .= '"'.$package->ver."-".$package->rel.'" '; } $json .= "}"; - if ($cnt != count($packages)){ + if ($cnt != count($packages)) { $json .= ","; } } $json .= "]}"; echo $json; -} else if ($type == "text"){ +} else if ($type == "text") { // Displays the output as text $text = 'package: ' . $name ." \n"; $cnt = 0; - foreach ($packages as $package){ + foreach ($packages as $package) { $cnt += 1; $text .= $package->repo_main .': '; - if ($package->epoch){ + if ($package->epoch) { $text .= $package->epoch; } else { $text .= $package->ver."-".$package->rel; @@ -237,5 +230,10 @@ if (!isset($type) || $type == "html"){ $text .= "\n"; } echo $text; +} else { + // Displays the output as html + $page_content = $smarty->fetch('zoom.tpl'); + $smarty->assign('page_content', $page_content); + $smarty->display('main.tpl'); } ?> -- cgit