From 3af8ea3d42dda70d34ef1c2523a93748ade3933c Mon Sep 17 00:00:00 2001
From: Callan Barrett <wizzomafizzo@gmail.com>
Date: Mon, 5 May 2008 02:19:29 +0800
Subject: [PATCH] Don't show None on pacckage info page

Just cuts out the table of deps/sources if none exist instead of
displaying "None"

Signed-off-by: Callan Barrett <wizzomafizzo@gmail.com>
---
 web/lib/pkgfuncs.inc |  170 +++++++++++++++++++++++++-------------------------
 1 files changed, 84 insertions(+), 86 deletions(-)

diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc
index 1feceb6..4553a10 100644
--- a/web/lib/pkgfuncs.inc
+++ b/web/lib/pkgfuncs.inc
@@ -360,106 +360,104 @@ function package_details($id=0, $SID="") {
 				echo "\n<tr><td colspan='2'>";
 				echo "<span class='f6'>".__("This package has been flagged out of date.")."</span></td></tr>";
 			}
+			// haha holy shit!
 			echo "      <tr><td class='boxSoft' colspan='2'><img src='/images/pad.gif' height='30'></td></tr>\n";
             echo "      <tr>\n";
-            echo "        <td valign='top' style='padding-right: 10'>\n";
-			echo "          <table class='boxSoft' style='width: 200px'>\n";
-			echo "            <tr><td class='boxSoftTitle'><span class='f3'>";
-			echo __("Dependencies")."</span></td></tr>\n";
-			echo "            <tr><td class='boxSoft'>";
+
 			$deps = package_dependencies($row["ID"]); # $deps[0] = array('id','name', 'dummy');
-			if (count($deps) == 0) {
-				print "None\n";
-			} else {
-				while (list($k, $darr) = each($deps)) {
-					$url = "<a href='/packages.php?do_Details=1&ID=".$darr[0];
-					while(list($k, $var) = each($pkgsearch_vars)) {
-						if (($var == "do_Orphans") && $_REQUEST[$var]) {
-							$url .= "&".$var."=1";
-						} else {
-							$url .= "&".$var."=".rawurlencode(stripslashes($_REQUEST[$var]));
-						}
-					}
-					reset($pkgsearch_vars);
+			if (count($deps) > 0) {
+        echo "        <td valign='top' style='padding-right: 10'>\n";
+  			echo "          <table class='boxSoft' style='width: 200px'>\n";
+  			echo "            <tr><td class='boxSoftTitle'><span class='f3'>";
+  			echo __("Dependencies")."</span></td></tr>\n";
+  			echo "            <tr><td class='boxSoft'>";
+
+  				while (list($k, $darr) = each($deps)) {
+  					$url = "<a href='/packages.php?do_Details=1&ID=".$darr[0];
+  					while(list($k, $var) = each($pkgsearch_vars)) {
+  						if (($var == "do_Orphans") && $_REQUEST[$var]) {
+  							$url .= "&".$var."=1";
+  						} else {
+  							$url .= "&".$var."=".rawurlencode(stripslashes($_REQUEST[$var]));
+  						}
+  					}
+  					reset($pkgsearch_vars);
 																								 
-									// $darr[3] is the DepCondition                                               
+  									// $darr[3] is the DepCondition                                               
 																								 
-					if ($darr[2] == 0) echo $url."'>".$darr[1].$darr[3]."</a><br />\n";
-					else echo "<a href='http://archlinux.org/packages/search/".$darr[1]."'>".$darr[1].$darr[3]."</a><br />\n";
-				}
-			}
-			echo "</td></tr>\n";
-			echo "</table></td>";
-
-			# reverse-deps by tardo - could use some beautification
-			echo "  <td valign='top'>";
-			echo "<table class='boxSoft' style='width: 200px'>";
-			echo "<tr><td class='boxSoftTitle'><span class='f3'>";
-			echo __("Required by")."</span></td></tr>\n";
-			echo "<tr><td class='boxSoft'>";
+  					if ($darr[2] == 0) echo $url."'>".$darr[1].$darr[3]."</a><br />\n";
+  					else echo "<a href='http://archlinux.org/packages/search/".$darr[1]."'>".$darr[1].$darr[3]."</a><br />\n";
+  				}
+  			echo "</td></tr>\n";
+  			echo "</table></td>";
+		  }
+			
 			$deps = package_required($row["ID"]);
-			if (count($deps) == 0) {
-				print "None\n";
-			} else {
-				while (list($k, $darr) = each($deps)) {
-					$url = "<a href='/packages.php?do_Details=1&ID=".$darr[0];
-					while(list($k, $var) = each($pkgsearch_vars)) {
-						if (($var == "do_Orphans") && $_REQUEST[$var]) {
-							$url .= "&".$var."=1";
-						} else {
-							$url .= "&".$var."=".rawurlencode(stripslashes($_REQUEST[$var]));
-						}
-					}
-					reset($pkgsearch_vars);
+			if (count($deps) > 0) {
+  			# reverse-deps by tardo - could use some beautification
+  			echo "  <td valign='top'>";
+  			echo "<table class='boxSoft' style='width: 200px'>";
+  			echo "<tr><td class='boxSoftTitle'><span class='f3'>";
+  			echo __("Required by")."</span></td></tr>\n";
+  			echo "<tr><td class='boxSoft'>";
+  				while (list($k, $darr) = each($deps)) {
+  					$url = "<a href='/packages.php?do_Details=1&ID=".$darr[0];
+  					while(list($k, $var) = each($pkgsearch_vars)) {
+  						if (($var == "do_Orphans") && $_REQUEST[$var]) {
+  							$url .= "&".$var."=1";
+  						} else {
+  							$url .= "&".$var."=".rawurlencode(stripslashes($_REQUEST[$var]));
+  						}
+  					}
+  					reset($pkgsearch_vars);
 																								 
-									// $darr[3] is the DepCondition                                               
+  									// $darr[3] is the DepCondition                                               
 																								 
-					if ($darr[2] == 0) print $url."'>".$darr[1].$darr[3]."</a><br />\n";
-					else print "<a href='http://archlinux.org/packages/search/".$darr[1]."'>".$darr[1].$darr[3]."</a><br />\n";
-				}
-			}
-			echo "</td></tr>\n";
-			echo "          </table>\n";
-			echo "        </td>\n";
-			echo "        <td valign='top'>\n";
-			echo "          <table class='boxSoft' style='width: 200px'>\n";
-			echo "            <tr><td class='boxSoftTitle'><span class='f3'>";
-			echo __("Sources")."</span></td></tr>\n";
-			echo "            <tr><td class='boxSoft'>";
-			$sources = package_sources($row["ID"]); # $sources[0] = 'src';
-			if (count($sources) == 0) {
-				print "None\n";
-			} else {
-				while (list($k, $src) = each($sources)) {
-					$parsed_url = parse_url($src);
-					if ($parsed_url['scheme'])
-					{
-						//It is an external source
-						echo "<a href='".$src."'>".$src."</a><br />\n";
-					}
-					else 
-					{
-						//It is presumably an internal source
-						if ($row["LocationID"] == 2) {
-							echo "<a href='".dirname($row['URLPath'])."/".$row['Name'];
-							echo "/".$src."'>".$src."</a><br />\n";
-						} elseif ($row["LocationID"] == 3) {
-							echo "<a href='http://cvs.archlinux.org/cgi-bin/viewcvs.cgi/*checkout*/".$row["Category"]."/".$row["Name"]."/".$src."/?rev=HEAD&cvsroot=AUR&only_with_tag=CURRENT'>";
-							echo $src."</a><br />\n";
-						}
-					}
-				}
-			}
-			echo "</td></tr>\n";
-			echo "          </table>\n";
-			echo "        </td>\n";
+  					if ($darr[2] == 0) print $url."'>".$darr[1].$darr[3]."</a><br />\n";
+  					else print "<a href='http://archlinux.org/packages/search/".$darr[1]."'>".$darr[1].$darr[3]."</a><br />\n";
+  				}
+  			echo "</td></tr>\n";
+  			echo "          </table>\n";
+  			echo "        </td>\n";
+  		}
+  		
+  		$sources = package_sources($row["ID"]); # $sources[0] = 'src';
+			if (count($sources) > 0) {
+  			echo "        <td valign='top'>\n";
+  			echo "          <table class='boxSoft' style='width: 200px'>\n";
+  			echo "            <tr><td class='boxSoftTitle'><span class='f3'>";
+  			echo __("Sources")."</span></td></tr>\n";
+  			echo "            <tr><td class='boxSoft'>";
+  				while (list($k, $src) = each($sources)) {
+  					$parsed_url = parse_url($src);
+  					if ($parsed_url['scheme'])
+  					{
+  						//It is an external source
+  						echo "<a href='".$src."'>".$src."</a><br />\n";
+  					}
+  					else 
+  					{
+  						//It is presumably an internal source
+  						if ($row["LocationID"] == 2) {
+  							echo "<a href='".dirname($row['URLPath'])."/".$row['Name'];
+  							echo "/".$src."'>".$src."</a><br />\n";
+  						} elseif ($row["LocationID"] == 3) {
+  							echo "<a href='http://cvs.archlinux.org/cgi-bin/viewcvs.cgi/*checkout*/".$row["Category"]."/".$row["Name"]."/".$src."/?rev=HEAD&cvsroot=AUR&only_with_tag=CURRENT'>";
+  							echo $src."</a><br />\n";
+  						}
+  					}
+  				}
+  			echo "</td></tr>\n";
+  			echo "          </table>\n";
+  			echo "        </td>\n";
+		  }
+		  
 			echo "      </tr>\n";
 			echo "    </table>\n";
 			echo "  </div>\n";
 			echo "</div>\n\n";
 			echo "<br />\n\n";
 
-
 			# Actions Bar
 			#
 			if ($SID) {
-- 
1.5.3.8

