mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
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>
This commit is contained in:
parent
73936002f7
commit
895907579e
2 changed files with 45 additions and 11 deletions
|
@ -116,8 +116,9 @@ function pkg_dependencies($pkgid) {
|
||||||
$pkgid = intval($pkgid);
|
$pkgid = intval($pkgid);
|
||||||
if ($pkgid > 0) {
|
if ($pkgid > 0) {
|
||||||
$dbh = DB::connect();
|
$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 Packages p ON pd.DepName = p.Name ";
|
||||||
|
$q.= "LEFT JOIN DependencyTypes dt ON dt.ID = pd.DepTypeID ";
|
||||||
$q.= "WHERE pd.PackageID = ". $pkgid . " ";
|
$q.= "WHERE pd.PackageID = ". $pkgid . " ";
|
||||||
$q.= "ORDER BY pd.DepName";
|
$q.= "ORDER BY pd.DepName";
|
||||||
$result = $dbh->query($q);
|
$result = $dbh->query($q);
|
||||||
|
@ -146,6 +147,46 @@ function pkg_dependency_type_id_from_name($name) {
|
||||||
return $result->fetch(PDO::FETCH_COLUMN, 0);
|
return $result->fetch(PDO::FETCH_COLUMN, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) – ' . htmlspecialchars($desc) . ' </em>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $link;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine packages that depend on a package
|
* Determine packages that depend on a package
|
||||||
*
|
*
|
||||||
|
|
|
@ -219,16 +219,9 @@ if ($row["MaintainerUID"]):
|
||||||
<h3><?= __('Dependencies') . " (" . count($deps) . ")"?></h3>
|
<h3><?= __('Dependencies') . " (" . count($deps) . ")"?></h3>
|
||||||
<?php if (count($deps) > 0): ?>
|
<?php if (count($deps) > 0): ?>
|
||||||
<ul>
|
<ul>
|
||||||
<?php
|
<?php while (list($k, $darr) = each($deps)): ?>
|
||||||
while (list($k, $darr) = each($deps)):
|
<li><?= pkg_depend_link($darr[0], $darr[1], $darr[2], $darr[3]); ?></li>
|
||||||
# darr: (DepName, DepCondition, PackageID), where ID is NULL if it didn't exist
|
<?php endwhile; ?>
|
||||||
if (!is_null($darr[2])):
|
|
||||||
?>
|
|
||||||
<li><a href="<?= htmlspecialchars(get_pkg_uri($darr[0]), ENT_QUOTES); ?>" title="<?= __('View packages details for').' '. htmlspecialchars($darr[0]) ?>"><?= htmlspecialchars($darr[0]) ?></a><?= htmlspecialchars($darr[1]) ?></li>
|
|
||||||
<?php else: ?>
|
|
||||||
<li><a href="https://www.archlinux.org/packages/?q=<?= urlencode($darr[0])?>" title="<?= __('View packages details for').' ' . htmlspecialchars($darr[0]) ?>"><?= htmlspecialchars($darr[0]) ?></a><?= htmlspecialchars($darr[1]) ?></li>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php endwhile; ?>
|
|
||||||
</ul>
|
</ul>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue