pkg_details.php 13.9 KB
Newer Older
1
<?php
2

3
4
5
$pkgbuild_uri = sprintf(config_get('options', 'pkgbuild_uri'), urlencode($row['BaseName']));
$log_uri = sprintf(config_get('options', 'log_uri'), urlencode($row['BaseName']));
$snapshot_uri = sprintf(config_get('options', 'snapshot_uri'), urlencode($row['BaseName']));
6
7
$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']));
8

9
$uid = uid_from_sid($SID);
10

11
$pkgid = intval($row['ID']);
12
$base_id = intval($row['BaseID']);
13

14
$catarr = pkgbase_categories();
15

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

20
$votes = $row['NumVotes'];
21

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

# Print the timestamps for last updates
27
28
29
$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"]));
30

31
$lics = pkg_licenses($row["ID"]);
32
33
$grps = pkg_groups($row["ID"]);

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

37
usort($deps, function($x, $y) {
38
39
40
41
42
43
44
45
46
47
48
	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]);
49
50
51
	}
});

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

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

62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
$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;
	}
}

77
# $sources[0] = 'src';
78
$sources = pkg_sources($row["ID"]);
79
80
?>
<div id="pkgdetails" class="box">
Lukas Fleischer's avatar
Lukas Fleischer committed
81
	<h2><?= __('Package Details') . ': ' . htmlspecialchars($row['Name']) . ' ' . htmlspecialchars($row['Version']) ?></h2>
82
83
	<div id="detailslinks" class="listing">
		<div id="actionlist">
84
			<h4><?= __('Package Actions') ?></h4>
85
			<ul class="small">
86
				<li>
87
88
					<a href="<?= $pkgbuild_uri ?>"><?= __('View PKGBUILD') ?></a> /
					<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>
Lukas Fleischer's avatar
Lukas Fleischer committed
93
				<?php if ($uid): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
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
99
100
						<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
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
106
107
						<input type="submit" class="button text-button" name="do_UnFlag" value="<?= __('Unflag package') ?>" />
					</form>
				</li>
Lukas Fleischer's avatar
Lukas Fleischer committed
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
114
115
						<input type="submit" class="button text-button" name="do_UnVote" value="<?= __('Remove vote') ?>" />
					</form>
				</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
121
122
						<input type="submit" class="button text-button" name="do_Vote" value="<?= __('Vote for this package') ?>" />
					</form>
				</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
129
130
						<input type="submit" class="button text-button" name="do_UnNotify" value="<?= __('Disable notifications') ?>" />
					</form>
				</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
136
137
						<input type="submit" class="button text-button" name="do_Notify" value="<?= __('Notify of new comments') ?>" />
					</form>
				</li>
138
				<?php endif; ?>
139
140
141
				<?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; ?>
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>
Lukas Fleischer's avatar
Lukas Fleischer committed
144
				<?php if (has_credential(CRED_PKGBASE_DELETE)): ?>
145
146
				<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>
147
				<?php endif; ?>
148
				<?php endif; ?>
149
150
151

				<?php if ($uid && $row["MaintainerUID"] === NULL): ?>
				<li>
152
					<form action="<?= get_pkgbase_uri($row['BaseName']) . 'adopt/'; ?>" method="post">
153
154
155
156
						<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
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
161
162
163
164
						<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; ?>
165
166
167
			</ul>
		</div>
	</div>
168

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

	<div id="metadata">
		<div id="pkgdeps" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
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
356
			</ul>
<?php endif; ?>
357
		</div>
358
		<div id="pkgreqs" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
359
			<h3><?= __('Required by') . " (" . count($requiredby) . ")"?></h3>
360
<?php if (count($requiredby) > 0): ?>
361
			<ul id="pkgreqslist">
362
363
364
<?php
	# darr: (PackageName, PackageID)
	while (list($k, $darr) = each($requiredby)):
365
?>
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
368
369
370
371
	<?php endwhile; ?>
			</ul>
<?php endif; ?>
		</div>
		<div id="pkgfiles" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
372
			<h3><?= __('Sources') ?></h3>
373
		</div>
374
		<?php if (count($sources) > 0): ?>
375
		<div>
Lukas Fleischer's avatar
Lukas Fleischer committed
376
			<ul id="pkgsrcslist">
377
378
379
					<?php while (list($k, $src) = each($sources)): ?>
					<li><?= pkg_source_link($src[0], $src[1]) ?></li>
					<?php endwhile; ?>
380
381
			</ul>
		</div>
382
		<?php endif; ?>
383
384
	</div>
</div>