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