Always use virtual URLs
[aur.git] / web / template / pkg_details.php
bloba8a0b3e713e7490a6a41b1018252b5f1f81da8ba
1 <?php
2 $uid = uid_from_sid($SID);
4 $pkgid = intval($row['ID']);
5 $base_id = intval($row['BaseID']);
7 $catarr = pkgbase_categories();
9 $submitter = username_from_id($row["SubmitterUID"]);
10 $maintainer = username_from_id($row["MaintainerUID"]);
11 $packager = username_from_id($row["PackagerUID"]);
13 $votes = $row['NumVotes'];
15 # In case of wanting to put a custom message
16 $msg = __('unknown');
17 $license = empty($row['License']) ? $msg : $row['License'];
19 # Print the timestamps for last updates
20 $updated_time = ($row["ModifiedTS"] == 0) ? $msg : gmdate("Y-m-d H:i", intval($row["ModifiedTS"]));
21 $submitted_time = ($row["SubmittedTS"] == 0) ? $msg : gmdate("Y-m-d H:i", intval($row["SubmittedTS"]));
22 $out_of_date_time = ($row["OutOfDateTS"] == 0) ? $msg : gmdate("Y-m-d", intval($row["OutOfDateTS"]));
24 $package_url = config_get('options', 'package_url');
25 $urlpath = $package_url . substr($row['BaseName'], 0, 2) . "/" . $row['BaseName'];
27 $lics = pkg_licenses($row["ID"]);
28 $grps = pkg_groups($row["ID"]);
30 $deps = pkg_dependencies($row["ID"]);
31 $requiredby = pkg_required($row["Name"]);
33 usort($deps, function($x, $y) {
34 if ($x[1] != $y[1]) {
35 if ($x[1] == "depends") {
36 return -1;
37 } elseif ($y[1] == "depends") {
38 return 1;
40 return strcmp($x[1], $y[1]);
41 } elseif ($x[3] != $y[3]) {
42 return strcmp($x[3], $y[3]);
43 } else {
44 return strcmp($x[0], $y[0]);
46 });
48 $rels = pkg_relations($row["ID"]);
50 usort($rels, function($x, $y) {
51 if ($x[3] != $y[3]) {
52 return strcmp($x[3], $y[3]);
53 } else {
54 return strcmp($x[0], $y[0]);
56 });
58 $rels_c = $rels_p = $rels_r = array();
59 foreach ($rels as $rel) {
60 switch ($rel[1]) {
61 case "conflicts":
62 $rels_c[] = $rel;
63 break;
64 case "provides":
65 $rels_p[] = $rel;
66 break;
67 case "replaces":
68 $rels_r[] = $rel;
69 break;
73 # $sources[0] = 'src';
74 $sources = pkg_sources($row["ID"]);
76 <div id="pkgdetails" class="box">
77 <h2><?= __('Package Details') . ': ' . htmlspecialchars($row['Name']) . ' ' . htmlspecialchars($row['Version']) ?></h2>
78 <div id="detailslinks" class="listing">
79 <div id="actionlist">
80 <h4><?= __('Package Actions') ?></h4>
81 <ul class="small">
82 <li><a href="<?= $urlpath ?>/PKGBUILD"><?= __('View PKGBUILD') ?></a></li>
83 <li><a href="<?= $urlpath . '/' . $row['BaseName'] ?>.tar.gz"><?= __('Download tarball') ?></a></li>
84 <li><a href="https://wiki.archlinux.org/index.php/Special:Search?search=<?= urlencode($row['Name']) ?>"><?= __('Search wiki') ?></a></li>
85 <li><span class="flagged"><?php if ($row["OutOfDateTS"] !== NULL) { echo __('Flagged out-of-date')." (${out_of_date_time})"; } ?></span></li>
86 <?php if ($uid): ?>
87 <?php if ($row["OutOfDateTS"] === NULL): ?>
88 <li>
89 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'flag/'; ?>" method="post">
90 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
91 <input type="submit" class="button text-button" name="do_Flag" value="<?= __('Flag package out-of-date') ?>" />
92 </form>
93 </li>
94 <?php elseif (($row["OutOfDateTS"] !== NULL) && has_credential(CRED_PKGBASE_UNFLAG, array($row["MaintainerUID"]))): ?>
95 <li>
96 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'unflag/'; ?>" method="post">
97 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
98 <input type="submit" class="button text-button" name="do_UnFlag" value="<?= __('Unflag package') ?>" />
99 </form>
100 </li>
101 <?php endif; ?>
102 <?php if (pkgbase_user_voted($uid, $base_id)): ?>
103 <li>
104 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'unvote/'; ?>" method="post">
105 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
106 <input type="submit" class="button text-button" name="do_UnVote" value="<?= __('Remove vote') ?>" />
107 </form>
108 </li>
109 <?php else: ?>
110 <li>
111 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'vote/'; ?>" method="post">
112 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
113 <input type="submit" class="button text-button" name="do_Vote" value="<?= __('Vote for this package') ?>" />
114 </form>
115 </li>
116 <?php endif; ?>
117 <?php if (pkgbase_user_notify($uid, $base_id)): ?>
118 <li>
119 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'unnotify/'; ?>" method="post">
120 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
121 <input type="submit" class="button text-button" name="do_UnNotify" value="<?= __('Disable notifications') ?>" />
122 </form>
123 </li>
124 <?php else: ?>
125 <li>
126 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'notify/'; ?>" method="post">
127 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
128 <input type="submit" class="button text-button" name="do_Notify" value="<?= __('Notify of new comments') ?>" />
129 </form>
130 </li>
131 <?php endif; ?>
132 <li><span class="flagged"><?php if ($row["RequestCount"] > 0) { echo _n('%d pending request', '%d pending requests', $row["RequestCount"]); } ?></span></li>
133 <li><a href="<?= get_pkgbase_uri($row['BaseName']) . 'request/'; ?>"><?= __('File Request'); ?></a></li>
134 <?php if (has_credential(CRED_PKGBASE_DELETE)): ?>
135 <li><a href="<?= get_pkgbase_uri($row['BaseName']) . 'delete/'; ?>"><?= __('Delete Package'); ?></a></li>
136 <li><a href="<?= get_pkgbase_uri($row['BaseName']) . 'merge/'; ?>"><?= __('Merge Package'); ?></a></li>
137 <?php endif; ?>
138 <?php endif; ?>
140 <?php if ($uid && $row["MaintainerUID"] === NULL): ?>
141 <li>
142 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'adopt/'; ?>" method="post">
143 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
144 <input type="submit" class="button text-button" name="do_Adopt" value="<?= __('Adopt Package') ?>" />
145 </form>
146 </li>
147 <?php elseif (has_credential(CRED_PKGBASE_DISOWN, array($row["MaintainerUID"]))): ?>
148 <li>
149 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'disown/'; ?>" method="post">
150 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
151 <input type="submit" class="button text-button" name="do_Disown" value="<?= __('Disown Package') ?>" />
152 </form>
153 </li>
154 <?php endif; ?>
155 </ul>
156 </div>
157 </div>
159 <table id="pkginfo">
160 <tr>
161 <th><?= __('Package Base') . ': ' ?></th>
162 <td class="wrap"><a href="<?= htmlspecialchars(get_pkgbase_uri($row['BaseName']), ENT_QUOTES); ?>"><?= htmlspecialchars($row['BaseName']); ?></a></td>
163 </tr>
164 <tr>
165 <th><?= __('Description') . ': ' ?></th>
166 <td class="wrap"><?= htmlspecialchars($row['Description']); ?></td>
167 </tr>
168 <tr>
169 <th><?= __('Upstream URL') . ': ' ?></th>
170 <td><a href="<?= htmlspecialchars($row['URL'], ENT_QUOTES) ?>" title="<?= __('Visit the website for') . ' ' . htmlspecialchars( $row['Name'])?>"><?= htmlspecialchars($row['URL'], ENT_QUOTES) ?></a></td>
171 </tr>
172 <tr>
173 <th><?= __('Category') . ': ' ?></th>
174 <?php
175 if (has_credential(CRED_PKGBASE_CHANGE_CATEGORY, array($row["MaintainerUID"]))):
177 <td>
178 <form method="post" action="<?= htmlspecialchars(get_pkgbase_uri($row['BaseName']), ENT_QUOTES); ?>">
179 <div>
180 <input type="hidden" name="action" value="do_ChangeCategory" />
181 <?php if ($SID): ?>
182 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
183 <?php endif; ?>
184 <select name="category_id">
185 <?php
186 foreach ($catarr as $cid => $catname):
188 <option value="<?= $cid ?>"<?php if ($cid == $row["CategoryID"]) { ?> selected="selected" <?php } ?>><?= $catname ?></option>
189 <?php endforeach; ?>
190 </select>
191 <input type="submit" value="<?= __('Change category') ?>"/>
192 </div>
193 </form>
194 <?php else: ?>
195 <td>
196 <a href="<?= get_uri('/packages/'); ?>?C=<?= $row['CategoryID'] ?>"><?= $row['Category'] ?></a>
197 <?php endif; ?>
198 </td>
199 </tr>
200 <?php if (count($lics) > 0): ?>
201 <tr>
202 <th><?= __('Licenses') . ': ' ?></th>
203 <td class="wrap">
204 <?php foreach($lics as $lic): ?>
205 <span class="related">
206 <?php if ($lic !== end($lics)): ?>
207 <?= htmlspecialchars($lic) ?>,
208 <?php else: ?>
209 <?= htmlspecialchars($lic) ?>
210 <?php endif; ?>
211 </span>
212 <?php endforeach; ?>
213 </td>
214 </tr>
215 <?php endif; ?>
216 <?php if (count($grps) > 0): ?>
217 <tr>
218 <th><?= __('Groups') . ': ' ?></th>
219 <td class="wrap">
220 <?php foreach($grps as $grp): ?>
221 <span class="related">
222 <?php if ($grp !== end($grps)): ?>
223 <?= htmlspecialchars($grp) ?>,
224 <?php else: ?>
225 <?= htmlspecialchars($grp) ?>
226 <?php endif; ?>
227 </span>
228 <?php endforeach; ?>
229 </td>
230 </tr>
231 <?php endif; ?>
232 <?php if (count($rels_c) > 0): ?>
233 <tr>
234 <th><?= __('Conflicts') . ': ' ?></th>
235 <td class="wrap relatedto">
236 <?php foreach($rels_c as $rarr): ?>
237 <span class="related">
238 <?php if ($rarr !== end($rels_c)): ?>
239 <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
240 <?php else: ?>
241 <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
242 <?php endif; ?>
243 </span>
244 <?php endforeach; ?>
245 </td>
246 </tr>
247 <?php endif; ?>
248 <?php if (count($rels_p) > 0): ?>
249 <tr>
250 <th><?= __('Provides') . ': ' ?></th>
251 <td class="wrap relatedto">
252 <?php foreach($rels_p as $rarr): ?>
253 <span class="related">
254 <?php if ($rarr !== end($rels_p)): ?>
255 <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
256 <?php else: ?>
257 <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
258 <?php endif; ?>
259 </span>
260 <?php endforeach; ?>
261 </td>
262 </tr>
263 <?php endif; ?>
264 <?php if (count($rels_r) > 0): ?>
265 <tr>
266 <th><?= __('Replaces') . ': ' ?></th>
267 <td class="wrap relatedto">
268 <?php foreach($rels_r as $rarr): ?>
269 <span class="related">
270 <?php if ($rarr !== end($rels_r)): ?>
271 <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
272 <?php else: ?>
273 <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
274 <?php endif; ?>
275 </span>
276 <?php endforeach; ?>
277 </td>
278 </tr>
279 <?php endif; ?>
280 <tr>
281 <th><?= __('Submitter') .': ' ?></th>
282 <?php if ($row["SubmitterUID"] && $SID): ?>
283 <td><a href="<?= get_uri('/account/') . html_format_username($submitter, ENT_QUOTES) ?>" title="<?= __('View account information for %s', html_format_username($submitter)) ?>"><?= html_format_username($submitter) ?></a></td>
284 <?php elseif ($row["SubmitterUID"] && !$SID): ?>
285 <td><?= html_format_username($submitter) ?></td>
286 <?php else: ?>
287 <td><?= __('None') ?></td>
288 <?php endif; ?>
289 </tr>
290 <tr>
291 <th><?= __('Maintainer') .': ' ?></th>
292 <?php if ($row["MaintainerUID"] && $SID): ?>
293 <td><a href="<?= get_uri('/account/') . html_format_username($maintainer) ?>" title="<?= __('View account information for %s', html_format_username($maintainer)) ?>"><?= html_format_username($maintainer) ?></a></td>
294 <?php elseif ($row["MaintainerUID"] && !$SID): ?>
295 <td><?= html_format_username($maintainer) ?></td>
296 <?php else: ?>
297 <td><?= __('None') ?></td>
298 <?php endif; ?>
299 </tr>
300 <tr>
301 <th><?= __('Last Packager') .': ' ?></th>
302 <?php if ($row["PackagerUID"] && $SID): ?>
303 <td><a href="<?= get_uri('/account/') . html_format_username($packager) ?>" title="<?= __('View account information for %s', html_format_username($packager)) ?>"><?= html_format_username($packager) ?></a></td>
304 <?php elseif ($row["PackagerUID"] && !$SID): ?>
305 <td><?= html_format_username($packager) ?></td>
306 <?php else: ?>
307 <td><?= __('None') ?></td>
308 <?php endif; ?>
309 </tr>
310 <tr>
311 <th><?= __('Votes') . ': ' ?></th>
312 <?php if (has_credential(CRED_PKGBASE_LIST_VOTERS)): ?>
313 <td><a href="<?= get_pkgbase_uri($row['Name']); ?>voters/"><?= $votes ?></a></td>
314 <?php else: ?>
315 <td><?= $votes ?></td>
316 <?php endif; ?>
317 </tr>
318 <tr>
319 <th><?= __('First Submitted') . ': ' ?></th>
320 <td><?= $submitted_time ?></td>
321 </tr>
322 <tr>
323 <th><?= __('Last Updated') . ': ' ?></th>
324 <td><?= $updated_time ?></td>
325 </tr>
326 </table>
328 <div id="metadata">
329 <div id="pkgdeps" class="listing">
330 <h3><?= __('Dependencies') . " (" . count($deps) . ")"?></h3>
331 <?php if (count($deps) > 0): ?>
332 <ul id="pkgdepslist">
333 <?php while (list($k, $darr) = each($deps)): ?>
334 <li><?= pkg_depend_link($darr[0], $darr[1], $darr[2], $darr[3], $darr[4]); ?></li>
335 <?php endwhile; ?>
336 </ul>
337 <?php endif; ?>
338 </div>
339 <div id="pkgreqs" class="listing">
340 <h3><?= __('Required by') . " (" . count($requiredby) . ")"?></h3>
341 <?php if (count($requiredby) > 0): ?>
342 <ul id="pkgreqslist">
343 <?php
344 # darr: (PackageName, PackageID)
345 while (list($k, $darr) = each($requiredby)):
347 <li><a href="<?= htmlspecialchars(get_pkg_uri($darr[0]), ENT_QUOTES); ?>" title="<?= __('View packages details for').' ' . htmlspecialchars($darr[0]) ?>"><?= htmlspecialchars($darr[0]) ?></a></li>
348 <?php endwhile; ?>
349 </ul>
350 <?php endif; ?>
351 </div>
352 <div id="pkgfiles" class="listing">
353 <h3><?= __('Sources') ?></h3>
354 </div>
355 <?php if (count($sources) > 0): ?>
356 <div>
357 <ul id="pkgsrcslist">
358 <?php while (list($k, $src) = each($sources)): ?>
359 <li><?= pkg_source_link($src[0], $src[1]) ?></li>
360 <?php endwhile; ?>
361 </ul>
362 </div>
363 <?php endif; ?>
364 </div>
365 </div>