From 993fcb7811d763368a6940730d3870b0013623c0 Mon Sep 17 00:00:00 2001 From: eric Date: Thu, 1 Jul 2004 22:20:09 +0000 Subject: still working on pkgsearch.php::do_Details --- web/lib/aur.inc | 18 +++++++++ web/lib/pkgfuncs.inc | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 118 insertions(+), 2 deletions(-) (limited to 'web/lib') diff --git a/web/lib/aur.inc b/web/lib/aur.inc index f97a131..bdec643 100644 --- a/web/lib/aur.inc +++ b/web/lib/aur.inc @@ -140,6 +140,24 @@ function new_sid() { } +# obtain the username if given their Users.ID +# +function username_from_id($id="") { + if (!$id) { + return ""; + } + $dbh = db_connect(); + $q = "SELECT Username FROM Users WHERE ID = " . mysql_escape_string($id); + $result = db_query($q, $dbh); + if (!$result) { + return "None"; + } + $row = mysql_fetch_row($result); + + return $row[0]; +} + + # obtain the username if given their current SID # function username_from_sid($sid="") { diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index 8894d3c..0c2e868 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -33,10 +33,51 @@ function pkgLocations() { return $locs; } +# grab package dependencies +# +function package_dependencies($pkgid=0) { + $deps = array(); + if ($pkgid) { + $dbh = db_connect(); + $q = "SELECT DepPkgID, Name FROM PackageDepends, Packages "; + $q.= "WHERE PackageDepends.DepPkgID = Packages.ID "; + $q.= "AND PackageDepends.PackageID = ".mysql_escape_string($pkgid); + $q.= " ORDER BY Name"; + $result = db_query($q, $dbh); + if (!$result) {return array();} + while ($row = mysql_fetch_row($result)) { + $deps[] = $row; + } + } + return $deps; +} + +# grab package sources +# +function package_sources($pkgid=0) { + $sources = array(); + if ($pkgid) { + $dbh = db_connect(); + $q = "SELECT Source FROM PackageSources "; + $q.= "WHERE PackageID = ".mysql_escape_string($pkgid); + $q.= " ORDER BY Source"; + $result = db_query($q, $dbh); + if (!$result) {return array();} + while ($row = mysql_fetch_row($result)) { + $sources[] = $row[0]; + } + } + return $sources; +} + # display package details # function package_details($id=0) { - $q = "SELECT * FROM Packages WHERE ID = ".intval($_REQUEST["ID"]); + $q = "SELECT *,Location,Category "; + $q.= "FROM Packages,PackageLocations,PackageCategories "; + $q.= "WHERE Packages.LocationID = PackageLocations.ID "; + $q.= "AND Packages.CategoryID = PackageCategories.ID "; + $q.= "ANd Packages.ID = ".intval($_REQUEST["ID"]); $dbh = db_connect(); $results = db_query($q, $dbh); if (!$results) { @@ -63,7 +104,64 @@ function package_details($id=0) { print "
\n"; print "\n"; print "\n"; - print " \n"; + print " \n"; + print "\n"; + print "\n"; + print " \n"; + print "\n"; + print "\n"; + print " \n"; + print "\n"; + print "\n"; + print " "; + print "\n"; + print "\n"; + print " "; + print "\n"; + print "\n"; + print " "; + print "\n"; + print "\n"; + print " "; + print "\n"; + print "\n"; + print " "; + + print " "; + print "\n"; print "
NAME"; + print $row["Name"] . "-" . $row["Version"]."
"; + print "".$row["URL"]."
".$row["Description"]; + print "
"; + print $row["Location"]." :: ".$row["Category"]."
".__("Maintainer").": "; + if (isset($row["AURMaintainerUID"])) { + $maintainer = username_from_id($row["AURMaintainerUID"]); + } elseif (isset($row["MaintainerUID"])) { + $maintainer = username_from_id($row["MaintainerUID"]); + } else { + $maintainer = "None"; + } + print $maintainer . "
"; + print ""; + print "\n"; + print "\n"; + print "
"; + print "Dependencies
"; + $deps = package_dependencies($row["ID"]); # $deps[0] = array('id','name'); + while (list($k, $darr) = each($deps)) { + print $darr[0]." - ".$darr[1]."
\n"; + } + print "
"; + print ""; + print "\n"; + print "\n"; + print "
"; + print "Sources
"; + $sources = package_sources($row["ID"]); # $sources[0] = 'src'; + while (list($k, $src) = each($sources)) { + # TODO left off here... URLify + print $src."
\n"; + } + print "
\n"; -- cgit v1.2.3-70-g09d2