summaryrefslogtreecommitdiff
path: root/web/lib/pkgfuncs.inc.php
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2014-04-17 20:07:07 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2014-04-17 21:10:58 +0200
commit895907579e89816074457b2bc3bbd34f5addc46f (patch)
treeaaf045c46e673a47f186ae89f9ab4428a911594c /web/lib/pkgfuncs.inc.php
parent73936002f7d5685a9063683f68d4e8c2e01be0ac (diff)
Display dependency type of package dependencies
This adds a label to makedepends, checkdepends and optdepends on the package details page. makedepends are labelled with "(make)", checkdepends with "(check)" and optdepends are labeled with "(optional)", followed by the optdepend description. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/pkgfuncs.inc.php')
-rw-r--r--web/lib/pkgfuncs.inc.php43
1 files changed, 42 insertions, 1 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index 153e2a8..5c30a95 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -116,8 +116,9 @@ function pkg_dependencies($pkgid) {
$pkgid = intval($pkgid);
if ($pkgid > 0) {
$dbh = DB::connect();
- $q = "SELECT pd.DepName, pd.DepCondition, p.ID FROM PackageDepends pd ";
+ $q = "SELECT pd.DepName, dt.Name, pd.DepCondition, p.ID FROM PackageDepends pd ";
$q.= "LEFT JOIN Packages p ON pd.DepName = p.Name ";
+ $q.= "LEFT JOIN DependencyTypes dt ON dt.ID = pd.DepTypeID ";
$q.= "WHERE pd.PackageID = ". $pkgid . " ";
$q.= "ORDER BY pd.DepName";
$result = $dbh->query($q);
@@ -147,6 +148,46 @@ function pkg_dependency_type_id_from_name($name) {
}
/**
+ * Get the HTML code to display a package dependency link
+ *
+ * @param string $name The name of the dependency
+ * @param string $type The name of the dependency type
+ * @param string $cond The package dependency condition string
+ * @param int $pkg_id The package of the package to display the dependency for
+ *
+ * @return string The HTML code of the label to display
+ */
+function pkg_depend_link($name, $type, $cond, $pkg_id) {
+ if ($type == 'optdepends' && strpos($name, ':') !== false) {
+ $tokens = explode(':', $name, 2);
+ $name = $tokens[0];
+ $desc = $tokens[1];
+ } else {
+ $desc = '(unknown)';
+ }
+
+ $link = '<a href="';
+ if (is_null($pkg_id)) {
+ $link .= 'https://www.archlinux.org/packages/?q=' . urlencode($name);
+ } else {
+ $link .= htmlspecialchars(get_pkg_uri($name), ENT_QUOTES);
+ }
+ $link .= '" title="' . __('View packages details for') .' ' . htmlspecialchars($name) . '">';
+ $link .= htmlspecialchars($name) . '</a>';
+ $link .= htmlspecialchars($cond);
+
+ if ($type == 'makedepends') {
+ $link .= ' <em>(make)</em>';
+ } elseif ($type == 'checkdepends') {
+ $link .= ' <em>(check)</em>';
+ } elseif ($type == 'optdepends') {
+ $link .= ' <em>(optional) &ndash; ' . htmlspecialchars($desc) . ' </em>';
+ }
+
+ return $link;
+}
+
+/**
* Determine packages that depend on a package
*
* @param string $name The package name for the dependency search