summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2014-10-10 12:27:13 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2014-10-10 12:29:18 +0200
commita1bee1a21e3ac4ee475332bfda63fa502ba51694 (patch)
treed4ec48c8e17fc20232e4a78a2c3794377db9977b /web
parent725a4778dbe51873e1ab1219339397ad50d78e61 (diff)
downloadaur-a1bee1a21e3ac4ee475332bfda63fa502ba51694.tar.gz
aur-a1bee1a21e3ac4ee475332bfda63fa502ba51694.tar.xz
Add support for architecture-specific sources
As a follow-up to 4d7da95 (Add support for architecture-specific fields, 2014-08-10), handle architecture-specific source fields as well. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web')
-rw-r--r--web/html/pkgsubmit.php8
-rw-r--r--web/lib/pkgfuncs.inc.php40
-rw-r--r--web/template/pkg_details.php24
3 files changed, 44 insertions, 28 deletions
diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php
index e1963de7..8cecd673 100644
--- a/web/html/pkgsubmit.php
+++ b/web/html/pkgsubmit.php
@@ -176,7 +176,6 @@ if ($uid):
break;
case 'license':
case 'groups':
- case 'source':
$section_info[$key][] = $value;
break;
case 'depends':
@@ -186,6 +185,7 @@ if ($uid):
case 'conflicts':
case 'provides':
case 'replaces':
+ case 'source':
$section_info[$key][$arch][] = $value;
break;
}
@@ -382,8 +382,10 @@ if ($uid):
}
}
- foreach ($pi['source'] as $src) {
- pkg_add_src($pkgid, $src);
+ foreach ($pi['source'] as $srcarch => $srcgrp) {
+ foreach ($srcgrp as $src) {
+ pkg_add_src($pkgid, $src, $srcarch);
+ }
}
}
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index 6a43a484..cf8c2f9d 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -292,6 +292,31 @@ function pkg_rel_html($name, $cond, $arch) {
}
/**
+ * Get the HTML code to display a source link
+ *
+ * @param string $url The URL of the source
+ * @param string $arch The source architecture
+ *
+ * @return string The HTML code of the label to display
+ */
+function pkg_source_link($url, $arch) {
+ $url = explode('::', $url);
+ $parsed_url = parse_url($url[0]);
+
+ if (isset($parsed_url['scheme']) || isset($url[1])) {
+ $link = '<a href="' . htmlspecialchars((isset($url[1]) ? $url[1] : $url[0]), ENT_QUOTES) . '">' . htmlspecialchars($url[0]) . '</a>';
+ } else {
+ $link = htmlspecialchars($url[0]);
+ }
+
+ if ($arch) {
+ $link .= ' <em>(' . htmlspecialchars($arch) . ')</em>';
+ }
+
+ return $link;
+}
+
+/**
* Determine packages that depend on a package
*
* @param string $name The package name for the dependency search
@@ -327,7 +352,7 @@ function pkg_sources($pkgid) {
$pkgid = intval($pkgid);
if ($pkgid > 0) {
$dbh = DB::connect();
- $q = "SELECT Source FROM PackageSources ";
+ $q = "SELECT Source, SourceArch FROM PackageSources ";
$q.= "WHERE PackageID = " . $pkgid;
$q.= " ORDER BY Source";
$result = $dbh->query($q);
@@ -335,7 +360,7 @@ function pkg_sources($pkgid) {
return array();
}
while ($row = $result->fetch(PDO::FETCH_NUM)) {
- $sources[] = $row[0];
+ $sources[] = $row;
}
}
return $sources;
@@ -831,14 +856,17 @@ function pkg_add_rel($pkgid, $type, $relname, $relcondition, $relarch) {
*
* @param int $pkgid The package ID to add the source for
* @param string $pkgsrc The package source to add to the database
+ * @param string $srcarch The architecture of the source to add
*
* @return void
*/
-function pkg_add_src($pkgid, $pkgsrc) {
+function pkg_add_src($pkgid, $pkgsrc, $srcarch) {
$dbh = DB::connect();
- $q = "INSERT INTO PackageSources (PackageID, Source) VALUES (";
- $q .= $pkgid . ", " . $dbh->quote($pkgsrc) . ")";
-
+ $q = sprintf("INSERT INTO PackageSources (PackageID, Source, SourceArch) VALUES (%d, %s, %s)",
+ $pkgid,
+ $dbh->quote($pkgsrc),
+ $srcarch ? $dbh->quote($srcarch) : 'NULL'
+ );
$dbh->exec($q);
}
diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php
index 3752e1aa..d09b3d86 100644
--- a/web/template/pkg_details.php
+++ b/web/template/pkg_details.php
@@ -379,28 +379,14 @@ if ($row["PackagerUID"]):
<div id="pkgfiles" class="listing">
<h3><?= __('Sources') ?></h3>
</div>
-<?php if (count($sources) > 0): ?>
+ <?php if (count($sources) > 0): ?>
<div>
<ul id="pkgsrcslist">
-<?php
- while (list($k, $src) = each($sources)):
- $src = explode('::', $src);
- $parsed_url = parse_url($src[0]);
-
- # It is an external source
- if (isset($parsed_url['scheme']) || isset($src[1])):
-?>
- <li><a href="<?= htmlspecialchars((isset($src[1]) ? $src[1] : $src[0]), ENT_QUOTES) ?>"><?= htmlspecialchars($src[0]) ?> </a></li>
-<?php
- else:
- # It is presumably an internal source
- $src = $src[0];
-?>
- <li><?= htmlspecialchars($src) ?></li>
- <?php endif; ?>
- <?php endwhile; ?>
+ <?php while (list($k, $src) = each($sources)): ?>
+ <li><?= pkg_source_link($src[0], $src[1]) ?></li>
+ <?php endwhile; ?>
</ul>
</div>
-<?php endif; ?>
+ <?php endif; ?>
</div>
</div>