mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Display package relations on the details page
This adds information from the following three fields to the package details page: * conflicts * provides * replaces If either of these fields is empty, it is not displayed. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
92812050a0
commit
3720bdf6b2
2 changed files with 92 additions and 0 deletions
|
@ -132,6 +132,34 @@ function pkg_dependencies($pkgid) {
|
|||
return $deps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get package relations for a specific package
|
||||
*
|
||||
* @param int $pkgid The package to get relations for
|
||||
*
|
||||
* @return array All package relations for the package
|
||||
*/
|
||||
function pkg_relations($pkgid) {
|
||||
$rels = array();
|
||||
$pkgid = intval($pkgid);
|
||||
if ($pkgid > 0) {
|
||||
$dbh = DB::connect();
|
||||
$q = "SELECT pr.RelName, rt.Name, pr.RelCondition, p.ID FROM PackageRelations pr ";
|
||||
$q.= "LEFT JOIN Packages p ON pr.RelName = p.Name ";
|
||||
$q.= "LEFT JOIN RelationTypes rt ON rt.ID = pr.RelTypeID ";
|
||||
$q.= "WHERE pr.PackageID = ". $pkgid . " ";
|
||||
$q.= "ORDER BY pr.RelName";
|
||||
$result = $dbh->query($q);
|
||||
if (!$result) {
|
||||
return array();
|
||||
}
|
||||
while ($row = $result->fetch(PDO::FETCH_NUM)) {
|
||||
$rels[] = $row;
|
||||
}
|
||||
}
|
||||
return $rels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID of a dependency type given its name
|
||||
*
|
||||
|
|
|
@ -25,6 +25,22 @@ $urlpath = URL_DIR . substr($row['BaseName'], 0, 2) . "/" . $row['BaseName'];
|
|||
$deps = pkg_dependencies($row["ID"]);
|
||||
$requiredby = pkg_required($row["Name"]);
|
||||
|
||||
$rels = pkg_relations($row["ID"]);
|
||||
$rels_c = $rels_p = $rels_r = array();
|
||||
foreach ($rels as $rel) {
|
||||
switch ($rel[1]) {
|
||||
case "conflicts":
|
||||
$rels_c[] = $rel;
|
||||
break;
|
||||
case "provides":
|
||||
$rels_p[] = $rel;
|
||||
break;
|
||||
case "replaces":
|
||||
$rels_r[] = $rel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
# $sources[0] = 'src';
|
||||
$sources = pkg_sources($row["ID"]);
|
||||
?>
|
||||
|
@ -156,6 +172,54 @@ if ($SID && ($uid == $row["MaintainerUID"] ||
|
|||
<th><?= __('License') . ': ' ?></th>
|
||||
<td><?= htmlspecialchars($license) ?></td>
|
||||
</tr>
|
||||
<?php if (count($rels_c) > 0): ?>
|
||||
<tr>
|
||||
<th><?= __('Conflicts') . ': ' ?></th>
|
||||
<td class="wrap relatedto">
|
||||
<?php foreach($rels_c as $rarr): ?>
|
||||
<span class="related">
|
||||
<?php if ($rarr !== end($rels_c)): ?>
|
||||
<?= htmlspecialchars($rarr[0]) ?>,
|
||||
<?php else: ?>
|
||||
<?= htmlspecialchars($rarr[0]) ?>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if (count($rels_p) > 0): ?>
|
||||
<tr>
|
||||
<th><?= __('Provides') . ': ' ?></th>
|
||||
<td class="wrap relatedto">
|
||||
<?php foreach($rels_p as $rarr): ?>
|
||||
<span class="related">
|
||||
<?php if ($rarr !== end($rels_p)): ?>
|
||||
<?= htmlspecialchars($rarr[0]) ?>,
|
||||
<?php else: ?>
|
||||
<?= htmlspecialchars($rarr[0]) ?>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if (count($rels_r) > 0): ?>
|
||||
<tr>
|
||||
<th><?= __('Replaces') . ': ' ?></th>
|
||||
<td class="wrap relatedto">
|
||||
<?php foreach($rels_r as $rarr): ?>
|
||||
<span class="related">
|
||||
<?php if ($rarr !== end($rels_r)): ?>
|
||||
<?= htmlspecialchars($rarr[0]) ?>,
|
||||
<?php else: ?>
|
||||
<?= htmlspecialchars($rarr[0]) ?>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<tr>
|
||||
<th><?= __('Submitter') .': ' ?></th>
|
||||
<?php
|
||||
|
|
Loading…
Add table
Reference in a new issue