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