summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2015-06-25 08:47:57 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2015-06-27 13:04:03 +0200
commitd1c331613d3b2c9a996dbb7afe0067e37e4bcd76 (patch)
tree3529fea79a220382dca04a0ad28586eef98e90f7
parentb1e3bfb48fbf0dd0fb5846f9da2136737693dd8c (diff)
downloadaur-d1c331613d3b2c9a996dbb7afe0067e37e4bcd76.tar.gz
aur-d1c331613d3b2c9a996dbb7afe0067e37e4bcd76.tar.xz
Display (reverse) optional dependencies as "Required by"
Also, change pkg_required() such that the returned array has the same structure as the result of pkg_dependencies(). Fixes FS#45452. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
-rw-r--r--web/lib/pkgfuncs.inc.php13
-rw-r--r--web/template/pkg_details.php9
2 files changed, 11 insertions, 11 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index f03134c6..110290ba 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -179,10 +179,11 @@ function pkg_relations($pkgid) {
* @param string $cond The package dependency condition string
* @param string $arch The package dependency architecture
* @param int $pkg_id The package of the package to display the dependency for
+ * @param bool $show_desc Whether the description of optdepends is shown
*
* @return string The HTML code of the label to display
*/
-function pkg_depend_link($name, $type, $cond, $arch, $pkg_id) {
+function pkg_depend_link($name, $type, $cond, $arch, $pkg_id, $show_desc=true) {
if ($type == 'optdepends' && strpos($name, ':') !== false) {
$tokens = explode(':', $name, 2);
$name = $tokens[0];
@@ -221,7 +222,7 @@ function pkg_depend_link($name, $type, $cond, $arch, $pkg_id) {
}
$link .= ')';
- if ($type == 'optdepends') {
+ if ($show_desc && $type == 'optdepends') {
$link .= ' &ndash; ' . htmlspecialchars($desc) . ' </em>';
}
$link .= '</em>';
@@ -285,9 +286,11 @@ function pkg_required($name="") {
$deps = array();
if ($name != "") {
$dbh = DB::connect();
- $q = "SELECT DISTINCT p.Name, PackageID FROM PackageDepends pd ";
- $q.= "JOIN Packages p ON pd.PackageID = p.ID ";
- $q.= "WHERE DepName = " . $dbh->quote($name) . " ";
+ $q = "SELECT p.Name, dt.Name, '' AS DepCondition, pd.DepArch, p.ID FROM PackageDepends pd ";
+ $q.= "LEFT JOIN Packages p ON p.ID = pd.PackageID ";
+ $q.= "LEFT JOIN DependencyTypes dt ON dt.ID = pd.DepTypeID ";
+ $q.= "WHERE pd.DepName = " . $dbh->quote($name) . " ";
+ $q.= "OR SUBSTRING(pd.DepName FROM 1 FOR POSITION(': ' IN pd.DepName) - 1) = " . $dbh->quote($name) . " ";
$q.= "ORDER BY p.Name";
$result = $dbh->query($q);
if (!$result) {return array();}
diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php
index 1e2b9a58..6864431f 100644
--- a/web/template/pkg_details.php
+++ b/web/template/pkg_details.php
@@ -359,12 +359,9 @@ endif;
<h3><?= __('Required by') . " (" . count($requiredby) . ")"?></h3>
<?php if (count($requiredby) > 0): ?>
<ul id="pkgreqslist">
-<?php
- # darr: (PackageName, PackageID)
- while (list($k, $darr) = each($requiredby)):
-?>
- <li><a href="<?= htmlspecialchars(get_pkg_uri($darr[0]), ENT_QUOTES); ?>" title="<?= __('View packages details for').' ' . htmlspecialchars($darr[0]) ?>"><?= htmlspecialchars($darr[0]) ?></a></li>
- <?php endwhile; ?>
+ <?php while (list($k, $darr) = each($requiredby)): ?>
+ <li><?= pkg_depend_link($darr[0], $darr[1], $darr[2], $darr[3], $darr[4], false); ?></li>
+ <?php endwhile; ?>
</ul>
<?php endif; ?>
</div>