Make url and pkgdesc fields optional
[aur.git] / web / template / pkg_details.php
blob1e2b9a5813b0f6703dea85741cfd15b4e578bec6
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 $keywords = pkgbase_get_keywords($base_id);
16 $submitter = username_from_id($row["SubmitterUID"]);
17 $maintainer = username_from_id($row["MaintainerUID"]);
18 $comaintainers = pkgbase_get_comaintainers($base_id);
19 $packager = username_from_id($row["PackagerUID"]);
21 if ($row["MaintainerUID"] !== NULL) {
22 $maintainers = array_merge(array($row["MaintainerUID"]), pkgbase_get_comaintainer_uids(array($base_id)));
23 } else {
24 $maintainers = NULL;
27 $votes = $row['NumVotes'];
29 # In case of wanting to put a custom message
30 $msg = __('unknown');
31 $license = empty($row['License']) ? $msg : $row['License'];
33 # Print the timestamps for last updates
34 $updated_time = ($row["ModifiedTS"] == 0) ? $msg : gmdate("Y-m-d H:i", intval($row["ModifiedTS"]));
35 $submitted_time = ($row["SubmittedTS"] == 0) ? $msg : gmdate("Y-m-d H:i", intval($row["SubmittedTS"]));
36 $out_of_date_time = ($row["OutOfDateTS"] == 0) ? $msg : gmdate("Y-m-d", intval($row["OutOfDateTS"]));
38 $lics = pkg_licenses($row["ID"]);
39 $grps = pkg_groups($row["ID"]);
41 $deps = pkg_dependencies($row["ID"]);
42 $requiredby = pkg_required($row["Name"]);
44 usort($deps, function($x, $y) {
45 if ($x[1] != $y[1]) {
46 if ($x[1] == "depends") {
47 return -1;
48 } elseif ($y[1] == "depends") {
49 return 1;
51 return strcmp($x[1], $y[1]);
52 } elseif ($x[3] != $y[3]) {
53 return strcmp($x[3], $y[3]);
54 } else {
55 return strcmp($x[0], $y[0]);
57 });
59 $rels = pkg_relations($row["ID"]);
61 usort($rels, function($x, $y) {
62 if ($x[3] != $y[3]) {
63 return strcmp($x[3], $y[3]);
64 } else {
65 return strcmp($x[0], $y[0]);
67 });
69 $rels_c = $rels_p = $rels_r = array();
70 foreach ($rels as $rel) {
71 switch ($rel[1]) {
72 case "conflicts":
73 $rels_c[] = $rel;
74 break;
75 case "provides":
76 $rels_p[] = $rel;
77 break;
78 case "replaces":
79 $rels_r[] = $rel;
80 break;
84 # $sources[0] = 'src';
85 $sources = pkg_sources($row["ID"]);
87 <div id="pkgdetails" class="box">
88 <h2><?= __('Package Details') . ': ' . htmlspecialchars($row['Name']) . ' ' . htmlspecialchars($row['Version']) ?></h2>
89 <div id="detailslinks" class="listing">
90 <div id="actionlist">
91 <h4><?= __('Package Actions') ?></h4>
92 <ul class="small">
93 <li>
94 <a href="<?= $pkgbuild_uri ?>"><?= __('View PKGBUILD') ?></a> /
95 <a href="<?= $log_uri ?>"><?= __('View Changes') ?></a>
96 </li>
97 <li><a href="<?= $snapshot_uri ?>"><?= __('Download snapshot') ?></a>
98 <li><a href="https://wiki.archlinux.org/index.php/Special:Search?search=<?= urlencode($row['Name']) ?>"><?= __('Search wiki') ?></a></li>
99 <li><span class="flagged"><?php if ($row["OutOfDateTS"] !== NULL) { echo __('Flagged out-of-date')." (${out_of_date_time})"; } ?></span></li>
100 <?php if ($uid): ?>
101 <?php if ($row["OutOfDateTS"] === NULL): ?>
102 <li>
103 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'flag/'; ?>" method="post">
104 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
105 <input type="submit" class="button text-button" name="do_Flag" value="<?= __('Flag package out-of-date') ?>" />
106 </form>
107 </li>
108 <?php elseif (($row["OutOfDateTS"] !== NULL) && has_credential(CRED_PKGBASE_UNFLAG, $maintainers)): ?>
109 <li>
110 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'unflag/'; ?>" method="post">
111 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
112 <input type="submit" class="button text-button" name="do_UnFlag" value="<?= __('Unflag package') ?>" />
113 </form>
114 </li>
115 <?php endif; ?>
116 <?php if (pkgbase_user_voted($uid, $base_id)): ?>
117 <li>
118 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'unvote/'; ?>" method="post">
119 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
120 <input type="submit" class="button text-button" name="do_UnVote" value="<?= __('Remove vote') ?>" />
121 </form>
122 </li>
123 <?php else: ?>
124 <li>
125 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'vote/'; ?>" method="post">
126 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
127 <input type="submit" class="button text-button" name="do_Vote" value="<?= __('Vote for this package') ?>" />
128 </form>
129 </li>
130 <?php endif; ?>
131 <?php if (pkgbase_user_notify($uid, $base_id)): ?>
132 <li>
133 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'unnotify/'; ?>" method="post">
134 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
135 <input type="submit" class="button text-button" name="do_UnNotify" value="<?= __('Disable notifications') ?>" />
136 </form>
137 </li>
138 <?php else: ?>
139 <li>
140 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'notify/'; ?>" method="post">
141 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
142 <input type="submit" class="button text-button" name="do_Notify" value="<?= __('Notify of new comments') ?>" />
143 </form>
144 </li>
145 <?php endif; ?>
146 <?php if (has_credential(CRED_PKGBASE_EDIT_COMAINTAINERS, array($row["MaintainerUID"]))): ?>
147 <li><a href="<?= get_pkgbase_uri($row['BaseName']) . 'comaintainers/'; ?>"><?= __('Manage Co-Maintainers'); ?></a></li>
148 <?php endif; ?>
149 <li><span class="flagged"><?php if ($row["RequestCount"] > 0) { echo _n('%d pending request', '%d pending requests', $row["RequestCount"]); } ?></span></li>
150 <li><a href="<?= get_pkgbase_uri($row['BaseName']) . 'request/'; ?>"><?= __('File Request'); ?></a></li>
151 <?php if (has_credential(CRED_PKGBASE_DELETE)): ?>
152 <li><a href="<?= get_pkgbase_uri($row['BaseName']) . 'delete/'; ?>"><?= __('Delete Package'); ?></a></li>
153 <li><a href="<?= get_pkgbase_uri($row['BaseName']) . 'merge/'; ?>"><?= __('Merge Package'); ?></a></li>
154 <?php endif; ?>
155 <?php endif; ?>
157 <?php if ($uid && $row["MaintainerUID"] === NULL): ?>
158 <li>
159 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'adopt/'; ?>" method="post">
160 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
161 <input type="submit" class="button text-button" name="do_Adopt" value="<?= __('Adopt Package') ?>" />
162 </form>
163 </li>
164 <?php elseif (has_credential(CRED_PKGBASE_DISOWN, array($row["MaintainerUID"]))): ?>
165 <li>
166 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'disown/'; ?>" method="post">
167 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
168 <input type="submit" class="button text-button" name="do_Disown" value="<?= __('Disown Package') ?>" />
169 </form>
170 </li>
171 <?php endif; ?>
172 </ul>
173 </div>
174 </div>
176 <table id="pkginfo">
177 <tr>
178 <th><?= __('Git Clone URL') . ': ' ?></th>
179 <td>
180 <a href="<?= $git_clone_uri_anon ?>"><?= $git_clone_uri_anon ?></a> (<?= __('read-only') ?>)
181 <?php if (in_array($uid, $maintainers)): ?>
182 <br /> <a href="<?= $git_clone_uri_priv ?>"><?= $git_clone_uri_priv ?></a>
183 <?php endif; ?>
184 </td>
185 </tr>
186 <tr>
187 <th><?= __('Package Base') . ': ' ?></th>
188 <td class="wrap"><a href="<?= htmlspecialchars(get_pkgbase_uri($row['BaseName']), ENT_QUOTES); ?>"><?= htmlspecialchars($row['BaseName']); ?></a></td>
189 </tr>
190 <tr>
191 <th><?= __('Description') . ': ' ?></th>
192 <?php if (!empty($row['Description'])): ?>
193 <td class="wrap"><?= htmlspecialchars($row['Description']); ?></td>
194 <?php else: ?>
195 <td class="wrap"><?= __('None') ?></td>
196 <?php endif; ?>
197 </tr>
198 <tr>
199 <th><?= __('Upstream URL') . ': ' ?></th>
200 <?php if (!empty($row['URL'])): ?>
201 <td><a href="<?= htmlspecialchars($row['URL'], ENT_QUOTES) ?>" title="<?= __('Visit the website for') . ' ' . htmlspecialchars( $row['Name'])?>"><?= htmlspecialchars($row['URL'], ENT_QUOTES) ?></a></td>
202 <?php else: ?>
203 <td class="wrap"><?= __('None') ?></td>
204 <?php endif; ?>
205 </tr>
206 <?php
207 if (has_credential(CRED_PKGBASE_SET_KEYWORDS, $maintainers) || count($keywords) > 0):
209 <tr>
210 <th><?= __('Keywords') . ': ' ?></th>
211 <td>
212 <?php
213 if (has_credential(CRED_PKGBASE_SET_KEYWORDS, $maintainers)):
215 <form method="post" action="<?= htmlspecialchars(get_pkgbase_uri($row['BaseName']), ENT_QUOTES); ?>">
216 <div>
217 <input type="hidden" name="action" value="do_SetKeywords" />
218 <?php if ($SID): ?>
219 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
220 <?php endif; ?>
221 <input type="text" name="keywords" value="<?= htmlspecialchars(implode(" ", $keywords), ENT_QUOTES) ?>"/>
222 <input type="submit" value="<?= __('Update') ?>"/>
223 </div>
224 </form>
225 <?php
226 else:
227 foreach ($keywords as $kw) {
228 echo '<a class="keyword" href="';
229 echo get_uri('/packages/') . '?K=' . urlencode($kw) . '&amp;SB=p';
230 echo '">' . htmlspecialchars($kw) . "</a>\n";
232 endif;
234 </td>
235 </tr>
236 <?php endif; ?>
237 <?php if (count($lics) > 0): ?>
238 <tr>
239 <th><?= __('Licenses') . ': ' ?></th>
240 <td class="wrap">
241 <?php foreach($lics as $lic): ?>
242 <span class="related">
243 <?php if ($lic !== end($lics)): ?>
244 <?= htmlspecialchars($lic) ?>,
245 <?php else: ?>
246 <?= htmlspecialchars($lic) ?>
247 <?php endif; ?>
248 </span>
249 <?php endforeach; ?>
250 </td>
251 </tr>
252 <?php endif; ?>
253 <?php if (count($grps) > 0): ?>
254 <tr>
255 <th><?= __('Groups') . ': ' ?></th>
256 <td class="wrap">
257 <?php foreach($grps as $grp): ?>
258 <span class="related">
259 <?php if ($grp !== end($grps)): ?>
260 <?= htmlspecialchars($grp) ?>,
261 <?php else: ?>
262 <?= htmlspecialchars($grp) ?>
263 <?php endif; ?>
264 </span>
265 <?php endforeach; ?>
266 </td>
267 </tr>
268 <?php endif; ?>
269 <?php if (count($rels_c) > 0): ?>
270 <tr>
271 <th><?= __('Conflicts') . ': ' ?></th>
272 <td class="wrap relatedto">
273 <?php foreach($rels_c as $rarr): ?>
274 <span class="related">
275 <?php if ($rarr !== end($rels_c)): ?>
276 <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
277 <?php else: ?>
278 <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
279 <?php endif; ?>
280 </span>
281 <?php endforeach; ?>
282 </td>
283 </tr>
284 <?php endif; ?>
285 <?php if (count($rels_p) > 0): ?>
286 <tr>
287 <th><?= __('Provides') . ': ' ?></th>
288 <td class="wrap relatedto">
289 <?php foreach($rels_p as $rarr): ?>
290 <span class="related">
291 <?php if ($rarr !== end($rels_p)): ?>
292 <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
293 <?php else: ?>
294 <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
295 <?php endif; ?>
296 </span>
297 <?php endforeach; ?>
298 </td>
299 </tr>
300 <?php endif; ?>
301 <?php if (count($rels_r) > 0): ?>
302 <tr>
303 <th><?= __('Replaces') . ': ' ?></th>
304 <td class="wrap relatedto">
305 <?php foreach($rels_r as $rarr): ?>
306 <span class="related">
307 <?php if ($rarr !== end($rels_r)): ?>
308 <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
309 <?php else: ?>
310 <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
311 <?php endif; ?>
312 </span>
313 <?php endforeach; ?>
314 </td>
315 </tr>
316 <?php endif; ?>
317 <tr>
318 <th><?= __('Submitter') .': ' ?></th>
319 <td><?= html_format_username($submitter) ?></td>
320 </tr>
321 <tr>
322 <th><?= __('Maintainer') .': ' ?></th>
323 <td><?= html_format_maintainers($maintainer, $comaintainers) ?></td>
324 </tr>
325 <tr>
326 <th><?= __('Last Packager') .': ' ?></th>
327 <td><?= html_format_username($packager) ?></td>
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>