\n";
print " \n";
# TODO need an "action" table in here like on /devel? It would
# allow the visitor to flag packages out-of-date, vote, adopt/disown?
# Probably need to think about the overall UI of this - the package
# name will be a link that goes to 'details'. There should also be
# a column for 'manage/edit'
if ($SID) {
print "
\n";
print "\n";
print "
\n";
print " \n";
}
# query to pull out package info
#
$q = "SELECT Packages.*, IF(ISNULL(PackageID), 0, COUNT(*)) AS Votes ";
$q.= "FROM Packages LEFT JOIN PackageVotes ";
$q.= "ON Packages.ID = PackageVotes.PackageID ";
$has_where = 0;
if ($L) {
$q.= "WHERE LocationID = ".intval($L)." ";
$has_where = 1;
}
if ($C) {
if (!$has_where) {
$q.= "WHERE CategoryID = ".intval($C)." ";
$has_where = 1;
} else {
$q.= "AND CategoryID = ".intval($C)." ";
}
}
if ($K) {
if (!$has_where) {
$q.= "WHERE (Name LIKE '".mysql_escape_string($K)."%' OR ";
$q.= "Description LIKE '%".mysql_escape_string($K)."%') ";
$has_where = 1;
} else {
$q.= "AND (Name LIKE '".mysql_escape_string($K)."%' OR ";
$q.= "Description LIKE '%".mysql_escape_string($K)."%') ";
}
}
if ($M && $SID) {
if ($myuid) {
if (!$has_where) {
$q.= "WHERE MaintainerUID = ".$myuid." ";
$has_where = 1;
} else {
$q.= "AND MaintainerUID = ".$myuid." ";
}
}
}
$q.= "GROUP BY PackageID ";
switch ($SB) {
case 'c':
$q.= "ORDER BY CategoryID ASC, Name ASC, LocationID ASC ";
break;
case 'l':
$q.= "ORDER BY LocationID ASC, Name ASC, CategoryID ASC ";
break;
case 'v':
$q.= "ORDER BY Votes DESC, Name ASC, CategoryID ASC ";
break;
default:
$q.= "ORDER BY Name ASC, LocationID ASC, CategoryID ASC ";
break;
}
$q.= "LIMIT ".$OFFSET.", ".intval($PP);
$result = db_query($q, $dbh);
if (!$result) {
print __("No packages matched your search criteria.");
} elseif (!mysql_num_rows($result)) {
print __("No packages matched your search criteria.");
} else {
# print out package search results
#
print "