From f9476c10930029ca7a44a14b5e1749d36512880c Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sun, 13 Sep 2015 17:54:36 +0200 Subject: Show providers in dependencies For all "virtual provisions" in package dependencies, show links to the actual packages providing the dependency. This partly implements FS#14125. Signed-off-by: Lukas Fleischer --- web/lib/pkgfuncs.inc.php | 65 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 6 deletions(-) (limited to 'web/lib/pkgfuncs.inc.php') diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index d760429..d83a01f 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -154,6 +154,33 @@ function pkg_groups($pkgid) { return $grps; } +/** + * Get providers for a specific package + * + * @param string $name The name of the "package" to get providers for + * + * @return array The IDs and names of all providers of the package + */ +function pkg_providers($name) { + $dbh = DB::connect(); + $q = "SELECT p.ID, p.Name FROM Packages p "; + $q.= "INNER JOIN PackageRelations pr ON pr.PackageID = p.ID "; + $q.= "INNER JOIN RelationTypes rt ON rt.ID = pr.RelTypeID "; + $q.= "WHERE rt.Name = 'provides' "; + $q.= "AND pr.RelName = " . $dbh->quote($name); + $result = $dbh->query($q); + + if (!$result) { + return array(); + } + + $providers = array(); + while ($row = $result->fetch(PDO::FETCH_NUM)) { + $providers[] = $row; + } + return $providers; +} + /** * Get package dependencies for a specific package * @@ -232,15 +259,41 @@ function pkg_depend_link($name, $type, $cond, $arch, $pkg_id, $show_desc=true) { $desc = '(unknown)'; } - $link = ' 0) { + $link = htmlspecialchars($name) . ' '; + $link .= '('; + foreach ($providers as $provider) { + $name = $provider[1]; + $link .= ''; + $link .= htmlspecialchars($name) . ', '; + } + $link = substr($link, 0, -2); + $link .= ')'; } else { - $link .= htmlspecialchars(get_pkg_uri($name), ENT_QUOTES); + $link = ''; + $link .= htmlspecialchars($name) . ''; + $link .= htmlspecialchars($cond); } - $link .= '" title="' . __('View packages details for') .' ' . htmlspecialchars($name) . '">'; - $link .= htmlspecialchars($name) . ''; - $link .= htmlspecialchars($cond); if ($type != 'depends' || $arch) { $link .= ' ('; -- cgit v1.2.3-70-g09d2