pkg_details.php 13.8 KB
Newer Older
1
<?php
2
3

$cgit_uri = config_get('options', 'cgit_uri');
4
5
$git_clone_uri_anon = sprintf(config_get('options', 'git_clone_uri_anon'), htmlspecialchars($row['BaseName']));
$git_clone_uri_priv = sprintf(config_get('options', 'git_clone_uri_priv'), htmlspecialchars($row['BaseName']));
6

7
$uid = uid_from_sid($SID);
8

9
$pkgid = intval($row['ID']);
10
$base_id = intval($row['BaseID']);
11

12
$catarr = pkgbase_categories();
13

14
15
$submitter = username_from_id($row["SubmitterUID"]);
$maintainer = username_from_id($row["MaintainerUID"]);
16
$packager = username_from_id($row["PackagerUID"]);
17

18
$votes = $row['NumVotes'];
19

20
21
22
23
24
# In case of wanting to put a custom message
$msg = __('unknown');
$license = empty($row['License']) ? $msg : $row['License'];

# Print the timestamps for last updates
25
26
27
$updated_time = ($row["ModifiedTS"] == 0) ? $msg : gmdate("Y-m-d H:i", intval($row["ModifiedTS"]));
$submitted_time = ($row["SubmittedTS"] == 0) ? $msg : gmdate("Y-m-d H:i", intval($row["SubmittedTS"]));
$out_of_date_time = ($row["OutOfDateTS"] == 0) ? $msg : gmdate("Y-m-d", intval($row["OutOfDateTS"]));
28

29
$lics = pkg_licenses($row["ID"]);
30
31
$grps = pkg_groups($row["ID"]);

32
33
$deps = pkg_dependencies($row["ID"]);
$requiredby = pkg_required($row["Name"]);
34

35
usort($deps, function($x, $y) {
36
37
38
39
40
41
42
43
44
45
46
	if ($x[1] != $y[1]) {
		if ($x[1] == "depends") {
			return -1;
		} elseif ($y[1] == "depends") {
			return 1;
		}
		return strcmp($x[1], $y[1]);
	} elseif ($x[3] != $y[3]) {
		return strcmp($x[3], $y[3]);
	} else {
		return strcmp($x[0], $y[0]);
47
48
49
	}
});

50
$rels = pkg_relations($row["ID"]);
51
52
53
54
55
56
57
58
59

usort($rels, function($x, $y) {
	if ($x[3] != $y[3]) {
		return strcmp($x[3], $y[3]);
	} else {
		return strcmp($x[0], $y[0]);
	}
});

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
$rels_c = $rels_p = $rels_r = array();
foreach ($rels as $rel) {
	switch ($rel[1]) {
	case "conflicts":
		$rels_c[] = $rel;
		break;
	case "provides":
		$rels_p[] = $rel;
		break;
	case "replaces":
		$rels_r[] = $rel;
		break;
	}
}

75
# $sources[0] = 'src';
76
$sources = pkg_sources($row["ID"]);
77
78
?>
<div id="pkgdetails" class="box">
Lukas Fleischer's avatar
Lukas Fleischer committed
79
	<h2><?= __('Package Details') . ': ' . htmlspecialchars($row['Name']) . ' ' . htmlspecialchars($row['Version']) ?></h2>
80
81
	<div id="detailslinks" class="listing">
		<div id="actionlist">
82
			<h4><?= __('Package Actions') ?></h4>
83
			<ul class="small">
84
				<li>
Lukas Fleischer's avatar
Lukas Fleischer committed
85
86
					<a href="<?= $cgit_uri . '/tree/PKGBUILD?h=' . urlencode($row['BaseName']) ?>"><?= __('View PKGBUILD') ?></a> /
					<a href="<?= $cgit_uri . '/log/?h=' . urlencode($row['BaseName']) ?>"><?= __('View Changes') ?></a>
87
				</li>
Lukas Fleischer's avatar
Lukas Fleischer committed
88
				<li><a href="<?= $cgit_uri . '/snapshot/' . urlencode($row['BaseName']) . '.tar.gz' ?>"><?= __('Download snapshot') ?></a>
89
				<li><a href="https://wiki.archlinux.org/index.php/Special:Search?search=<?= urlencode($row['Name']) ?>"><?= __('Search wiki') ?></a></li>
90
				<li><span class="flagged"><?php if ($row["OutOfDateTS"] !== NULL) { echo __('Flagged out-of-date')." (${out_of_date_time})"; } ?></span></li>
Lukas Fleischer's avatar
Lukas Fleischer committed
91
				<?php if ($uid): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
92
				<?php if ($row["OutOfDateTS"] === NULL): ?>
93
				<li>
94
					<form action="<?= get_pkgbase_uri($row['BaseName']) . 'flag/'; ?>" method="post">
95
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
96
97
98
						<input type="submit" class="button text-button" name="do_Flag" value="<?= __('Flag package out-of-date') ?>" />
					</form>
				</li>
Lukas Fleischer's avatar
Lukas Fleischer committed
99
				<?php elseif (($row["OutOfDateTS"] !== NULL) && has_credential(CRED_PKGBASE_UNFLAG, array($row["MaintainerUID"]))): ?>
100
				<li>
101
					<form action="<?= get_pkgbase_uri($row['BaseName']) . 'unflag/'; ?>" method="post">
102
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
103
104
105
						<input type="submit" class="button text-button" name="do_UnFlag" value="<?= __('Unflag package') ?>" />
					</form>
				</li>
Lukas Fleischer's avatar
Lukas Fleischer committed
106
				<?php endif; ?>
107
				<?php if (pkgbase_user_voted($uid, $base_id)): ?>
108
				<li>
109
					<form action="<?= get_pkgbase_uri($row['BaseName']) . 'unvote/'; ?>" method="post">
110
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
111
112
113
						<input type="submit" class="button text-button" name="do_UnVote" value="<?= __('Remove vote') ?>" />
					</form>
				</li>
114
				<?php else: ?>
115
				<li>
116
					<form action="<?= get_pkgbase_uri($row['BaseName']) . 'vote/'; ?>" method="post">
117
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
118
119
120
						<input type="submit" class="button text-button" name="do_Vote" value="<?= __('Vote for this package') ?>" />
					</form>
				</li>
121
				<?php endif; ?>
122
				<?php if (pkgbase_user_notify($uid, $base_id)): ?>
123
				<li>
124
					<form action="<?= get_pkgbase_uri($row['BaseName']) . 'unnotify/'; ?>" method="post">
125
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
126
127
128
						<input type="submit" class="button text-button" name="do_UnNotify" value="<?= __('Disable notifications') ?>" />
					</form>
				</li>
129
				<?php else: ?>
130
				<li>
131
					<form action="<?= get_pkgbase_uri($row['BaseName']) . 'notify/'; ?>" method="post">
132
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
133
134
135
						<input type="submit" class="button text-button" name="do_Notify" value="<?= __('Notify of new comments') ?>" />
					</form>
				</li>
136
				<?php endif; ?>
137
138
139
				<?php if (has_credential(CRED_PKGBASE_EDIT_COMAINTAINERS, array($row["MaintainerUID"]))): ?>
				<li><a href="<?= get_pkgbase_uri($row['BaseName']) . 'comaintainers/'; ?>"><?= __('Manage Co-Maintainers'); ?></a></li>
				<?php endif; ?>
140
				<li><span class="flagged"><?php if ($row["RequestCount"] > 0) { echo _n('%d pending request', '%d pending requests', $row["RequestCount"]); } ?></span></li>
141
				<li><a href="<?= get_pkgbase_uri($row['BaseName']) . 'request/'; ?>"><?= __('File Request'); ?></a></li>
Lukas Fleischer's avatar
Lukas Fleischer committed
142
				<?php if (has_credential(CRED_PKGBASE_DELETE)): ?>
143
144
				<li><a href="<?= get_pkgbase_uri($row['BaseName']) . 'delete/'; ?>"><?= __('Delete Package'); ?></a></li>
				<li><a href="<?= get_pkgbase_uri($row['BaseName']) . 'merge/'; ?>"><?= __('Merge Package'); ?></a></li>
145
				<?php endif; ?>
146
				<?php endif; ?>
147
148
149

				<?php if ($uid && $row["MaintainerUID"] === NULL): ?>
				<li>
150
					<form action="<?= get_pkgbase_uri($row['BaseName']) . 'adopt/'; ?>" method="post">
151
152
153
154
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
						<input type="submit" class="button text-button" name="do_Adopt" value="<?= __('Adopt Package') ?>" />
					</form>
				</li>
Lukas Fleischer's avatar
Lukas Fleischer committed
155
				<?php elseif (has_credential(CRED_PKGBASE_DISOWN, array($row["MaintainerUID"]))): ?>
156
				<li>
157
					<form action="<?= get_pkgbase_uri($row['BaseName']) . 'disown/'; ?>" method="post">
158
159
160
161
162
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
						<input type="submit" class="button text-button" name="do_Disown" value="<?= __('Disown Package') ?>" />
					</form>
				</li>
				<?php endif; ?>
163
164
165
			</ul>
		</div>
	</div>
166

167
	<table id="pkginfo">
168
169
		<tr>
			<th><?= __('Git Clone URL') . ': ' ?></th>
170
171
172
173
174
175
			<td>
				<a href="<?= $git_clone_uri_anon ?>"><?= $git_clone_uri_anon ?></a>
				<?php if ($uid == $row["MaintainerUID"]): ?>
				<br /> <a href="<?= $git_clone_uri_priv ?>"><?= $git_clone_uri_priv ?></a>
				<?php endif; ?>
			</td>
176
		</tr>
177
178
179
180
		<tr>
			<th><?= __('Package Base') . ': ' ?></th>
			<td class="wrap"><a href="<?= htmlspecialchars(get_pkgbase_uri($row['BaseName']), ENT_QUOTES); ?>"><?= htmlspecialchars($row['BaseName']); ?></a></td>
		</tr>
181
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
182
183
			<th><?= __('Description') . ': ' ?></th>
			<td class="wrap"><?= htmlspecialchars($row['Description']); ?></td>
184
185
		</tr>
		<tr>
186
			<th><?= __('Upstream URL') . ': ' ?></th>
Lukas Fleischer's avatar
Lukas Fleischer committed
187
			<td><a href="<?= htmlspecialchars($row['URL'], ENT_QUOTES) ?>" title="<?= __('Visit the website for') . ' ' . htmlspecialchars( $row['Name'])?>"><?= htmlspecialchars($row['URL'], ENT_QUOTES) ?></a></td>
188
189
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
190
			<th><?= __('Category') . ': ' ?></th>
191
<?php
Lukas Fleischer's avatar
Lukas Fleischer committed
192
if (has_credential(CRED_PKGBASE_CHANGE_CATEGORY, array($row["MaintainerUID"]))):
193
?>
194
			<td>
195
				<form method="post" action="<?= htmlspecialchars(get_pkgbase_uri($row['BaseName']), ENT_QUOTES); ?>">
196
197
					<div>
						<input type="hidden" name="action" value="do_ChangeCategory" />
Lukas Fleischer's avatar
Lukas Fleischer committed
198
						<?php if ($SID): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
199
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
Lukas Fleischer's avatar
Lukas Fleischer committed
200
						<?php endif; ?>
201
						<select name="category_id">
202
<?php
203
	foreach ($catarr as $cid => $catname):
204
?>
Lukas Fleischer's avatar
Lukas Fleischer committed
205
							<option value="<?= $cid ?>"<?php if ($cid == $row["CategoryID"]) { ?> selected="selected" <?php } ?>><?= $catname ?></option>
206
207
	<?php endforeach; ?>
						</select>
Lukas Fleischer's avatar
Lukas Fleischer committed
208
						<input type="submit" value="<?= __('Change category') ?>"/>
209
210
211
212
					</div>
				</form>
<?php else: ?>
			<td>
Lukas Fleischer's avatar
Lukas Fleischer committed
213
				<a href="<?= get_uri('/packages/'); ?>?C=<?= $row['CategoryID'] ?>"><?= $row['Category'] ?></a>
214
215
<?php endif; ?>
			</td>
216
		</tr>
217
		<?php if (count($lics) > 0): ?>
218
		<tr>
219
220
221
222
223
224
225
226
227
228
229
230
			<th><?= __('Licenses') . ': ' ?></th>
			<td class="wrap">
				<?php foreach($lics as $lic): ?>
				<span class="related">
					<?php if ($lic !== end($lics)): ?>
					<?= htmlspecialchars($lic) ?>,
					<?php else: ?>
					<?= htmlspecialchars($lic) ?>
					<?php endif; ?>
				</span>
				<?php endforeach; ?>
			</td>
231
		</tr>
232
		<?php endif; ?>
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
		<?php if (count($grps) > 0): ?>
		<tr>
			<th><?= __('Groups') . ': ' ?></th>
			<td class="wrap">
				<?php foreach($grps as $grp): ?>
				<span class="related">
					<?php if ($grp !== end($grps)): ?>
					<?= htmlspecialchars($grp) ?>,
					<?php else: ?>
					<?= htmlspecialchars($grp) ?>
					<?php endif; ?>
				</span>
				<?php endforeach; ?>
			</td>
		</tr>
		<?php endif; ?>
249
250
251
252
253
254
255
		<?php if (count($rels_c) > 0): ?>
		<tr>
			<th><?= __('Conflicts') . ': ' ?></th>
			<td class="wrap relatedto">
				<?php foreach($rels_c as $rarr): ?>
				<span class="related">
					<?php if ($rarr !== end($rels_c)): ?>
256
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
257
					<?php else: ?>
258
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
259
260
261
262
263
264
265
266
267
268
269
270
271
					<?php endif; ?>
				</span>
				<?php endforeach; ?>
			</td>
		</tr>
		<?php endif; ?>
		<?php if (count($rels_p) > 0): ?>
		<tr>
			<th><?= __('Provides') . ': ' ?></th>
			<td class="wrap relatedto">
				<?php foreach($rels_p as $rarr): ?>
				<span class="related">
					<?php if ($rarr !== end($rels_p)): ?>
272
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
273
					<?php else: ?>
274
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
275
276
277
278
279
280
281
282
283
284
285
286
287
					<?php endif; ?>
				</span>
				<?php endforeach; ?>
			</td>
		</tr>
		<?php endif; ?>
		<?php if (count($rels_r) > 0): ?>
		<tr>
			<th><?= __('Replaces') . ': ' ?></th>
			<td class="wrap relatedto">
				<?php foreach($rels_r as $rarr): ?>
				<span class="related">
					<?php if ($rarr !== end($rels_r)): ?>
288
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
289
					<?php else: ?>
290
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
291
292
293
294
295
296
					<?php endif; ?>
				</span>
				<?php endforeach; ?>
			</td>
		</tr>
		<?php endif; ?>
297
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
298
			<th><?= __('Submitter') .': ' ?></th>
Lukas Fleischer's avatar
Lukas Fleischer committed
299
300
301
302
303
			<?php if ($row["SubmitterUID"] && $SID): ?>
			<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>
			<?php elseif ($row["SubmitterUID"] && !$SID): ?>
			<td><?= html_format_username($submitter) ?></td>
			<?php else: ?>
304
			<td><?= __('None') ?></td>
Lukas Fleischer's avatar
Lukas Fleischer committed
305
			<?php endif; ?>
306
		</tr>
307
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
308
			<th><?= __('Maintainer') .': ' ?></th>
Lukas Fleischer's avatar
Lukas Fleischer committed
309
			<?php if ($row["MaintainerUID"] && $SID): ?>
310
			<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>
Lukas Fleischer's avatar
Lukas Fleischer committed
311
312
313
			<?php elseif ($row["MaintainerUID"] && !$SID): ?>
			<td><?= html_format_username($maintainer) ?></td>
			<?php else: ?>
314
			<td><?= __('None') ?></td>
Lukas Fleischer's avatar
Lukas Fleischer committed
315
			<?php endif; ?>
316
317
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
318
319
			<th><?= __('Last Packager') .': ' ?></th>
			<?php if ($row["PackagerUID"] && $SID): ?>
320
			<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>
Lukas Fleischer's avatar
Lukas Fleischer committed
321
322
323
			<?php elseif ($row["PackagerUID"] && !$SID): ?>
			<td><?= html_format_username($packager) ?></td>
			<?php else: ?>
324
			<td><?= __('None') ?></td>
Lukas Fleischer's avatar
Lukas Fleischer committed
325
			<?php endif; ?>
326
327
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
328
			<th><?= __('Votes') . ': ' ?></th>
Lukas Fleischer's avatar
Lukas Fleischer committed
329
			<?php if (has_credential(CRED_PKGBASE_LIST_VOTERS)): ?>
330
			<td><a href="<?= get_pkgbase_uri($row['BaseName']); ?>voters/"><?= $votes ?></a></td>
Lukas Fleischer's avatar
Lukas Fleischer committed
331
			<?php else: ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
332
			<td><?= $votes ?></td>
Lukas Fleischer's avatar
Lukas Fleischer committed
333
			<?php endif; ?>
334
335
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
336
337
			<th><?= __('First Submitted') . ': ' ?></th>
			<td><?= $submitted_time ?></td>
338
339
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
340
341
			<th><?= __('Last Updated') . ': ' ?></th>
			<td><?= $updated_time ?></td>
342
343
344
345
346
		</tr>
	</table>

	<div id="metadata">
		<div id="pkgdeps" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
347
			<h3><?= __('Dependencies') . " (" . count($deps) . ")"?></h3>
348
<?php if (count($deps) > 0): ?>
349
			<ul id="pkgdepslist">
350
<?php while (list($k, $darr) = each($deps)): ?>
351
	<li><?= pkg_depend_link($darr[0], $darr[1], $darr[2], $darr[3], $darr[4]); ?></li>
352
<?php endwhile; ?>
353
354
			</ul>
<?php endif; ?>
355
		</div>
356
		<div id="pkgreqs" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
357
			<h3><?= __('Required by') . " (" . count($requiredby) . ")"?></h3>
358
<?php if (count($requiredby) > 0): ?>
359
			<ul id="pkgreqslist">
360
361
362
<?php
	# darr: (PackageName, PackageID)
	while (list($k, $darr) = each($requiredby)):
363
?>
364
				<li><a href="<?= htmlspecialchars(get_pkg_uri($darr[0]), ENT_QUOTES); ?>" title="<?= __('View packages details for').' ' . htmlspecialchars($darr[0]) ?>"><?= htmlspecialchars($darr[0]) ?></a></li>
365
366
367
368
369
	<?php endwhile; ?>
			</ul>
<?php endif; ?>
		</div>
		<div id="pkgfiles" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
370
			<h3><?= __('Sources') ?></h3>
371
		</div>
372
		<?php if (count($sources) > 0): ?>
373
		<div>
Lukas Fleischer's avatar
Lukas Fleischer committed
374
			<ul id="pkgsrcslist">
375
376
377
					<?php while (list($k, $src) = each($sources)): ?>
					<li><?= pkg_source_link($src[0], $src[1]) ?></li>
					<?php endwhile; ?>
378
379
			</ul>
		</div>
380
		<?php endif; ?>
381
382
	</div>
</div>