pkg_details.php 13 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
$keywords = pkgbase_get_keywords($base_id);
15

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

21
22
23
24
25
26
if ($row["MaintainerUID"] !== NULL) {
	$maintainers = array_merge(array($row["MaintainerUID"]), pkgbase_get_comaintainer_uids(array($base_id)));
} else {
	$maintainers = NULL;
}

27
$votes = $row['NumVotes'];
28

29
30
31
32
33
# In case of wanting to put a custom message
$msg = __('unknown');
$license = empty($row['License']) ? $msg : $row['License'];

# Print the timestamps for last updates
34
35
36
$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"]));
37

38
$lics = pkg_licenses($row["ID"]);
39
40
$grps = pkg_groups($row["ID"]);

41
42
$deps = pkg_dependencies($row["ID"]);
$requiredby = pkg_required($row["Name"]);
43

44
usort($deps, function($x, $y) {
45
46
47
48
49
50
51
52
53
54
55
	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]);
56
57
58
	}
});

59
$rels = pkg_relations($row["ID"]);
60
61
62
63
64
65
66
67
68

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

69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
$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;
	}
}

84
# $sources[0] = 'src';
85
$sources = pkg_sources($row["ID"]);
86
87
?>
<div id="pkgdetails" class="box">
Lukas Fleischer's avatar
Lukas Fleischer committed
88
	<h2><?= __('Package Details') . ': ' . htmlspecialchars($row['Name']) . ' ' . htmlspecialchars($row['Version']) ?></h2>
89
90
	<div id="detailslinks" class="listing">
		<div id="actionlist">
91
			<h4><?= __('Package Actions') ?></h4>
92
			<ul class="small">
93
				<li>
94
95
					<a href="<?= $pkgbuild_uri ?>"><?= __('View PKGBUILD') ?></a> /
					<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>
Lukas Fleischer's avatar
Lukas Fleischer committed
100
				<?php if ($uid): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
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
106
107
						<input type="submit" class="button text-button" name="do_Flag" value="<?= __('Flag package out-of-date') ?>" />
					</form>
				</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
113
114
						<input type="submit" class="button text-button" name="do_UnFlag" value="<?= __('Unflag package') ?>" />
					</form>
				</li>
Lukas Fleischer's avatar
Lukas Fleischer committed
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
121
122
						<input type="submit" class="button text-button" name="do_UnVote" value="<?= __('Remove vote') ?>" />
					</form>
				</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
128
129
						<input type="submit" class="button text-button" name="do_Vote" value="<?= __('Vote for this package') ?>" />
					</form>
				</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
136
137
						<input type="submit" class="button text-button" name="do_UnNotify" value="<?= __('Disable notifications') ?>" />
					</form>
				</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
143
144
						<input type="submit" class="button text-button" name="do_Notify" value="<?= __('Notify of new comments') ?>" />
					</form>
				</li>
145
				<?php endif; ?>
146
147
148
				<?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; ?>
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>
Lukas Fleischer's avatar
Lukas Fleischer committed
151
				<?php if (has_credential(CRED_PKGBASE_DELETE)): ?>
152
153
				<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>
154
				<?php endif; ?>
155
				<?php endif; ?>
156
157
158

				<?php if ($uid && $row["MaintainerUID"] === NULL): ?>
				<li>
159
					<form action="<?= get_pkgbase_uri($row['BaseName']) . 'adopt/'; ?>" method="post">
160
161
162
163
						<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
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
168
169
170
171
						<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; ?>
172
173
174
			</ul>
		</div>
	</div>
175

176
	<table id="pkginfo">
177
178
		<tr>
			<th><?= __('Git Clone URL') . ': ' ?></th>
179
			<td>
180
				<a href="<?= $git_clone_uri_anon ?>"><?= $git_clone_uri_anon ?></a> (<?= __('read-only') ?>)
181
182
183
184
				<?php if ($uid == $row["MaintainerUID"]): ?>
				<br /> <a href="<?= $git_clone_uri_priv ?>"><?= $git_clone_uri_priv ?></a>
				<?php endif; ?>
			</td>
185
		</tr>
186
187
188
189
		<tr>
			<th><?= __('Package Base') . ': ' ?></th>
			<td class="wrap"><a href="<?= htmlspecialchars(get_pkgbase_uri($row['BaseName']), ENT_QUOTES); ?>"><?= htmlspecialchars($row['BaseName']); ?></a></td>
		</tr>
190
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
191
192
			<th><?= __('Description') . ': ' ?></th>
			<td class="wrap"><?= htmlspecialchars($row['Description']); ?></td>
193
194
		</tr>
		<tr>
195
			<th><?= __('Upstream URL') . ': ' ?></th>
Lukas Fleischer's avatar
Lukas Fleischer committed
196
			<td><a href="<?= htmlspecialchars($row['URL'], ENT_QUOTES) ?>" title="<?= __('Visit the website for') . ' ' . htmlspecialchars( $row['Name'])?>"><?= htmlspecialchars($row['URL'], ENT_QUOTES) ?></a></td>
197
		</tr>
198
<?php
199
if (has_credential(CRED_PKGBASE_SET_KEYWORDS, $maintainers) || count($keywords) > 0):
200
?>
201
202
		<tr>
			<th><?= __('Keywords') . ': ' ?></th>
203
			<td>
204
<?php
205
if (has_credential(CRED_PKGBASE_SET_KEYWORDS, $maintainers)):
206
?>
207
				<form method="post" action="<?= htmlspecialchars(get_pkgbase_uri($row['BaseName']), ENT_QUOTES); ?>">
208
					<div>
209
						<input type="hidden" name="action" value="do_SetKeywords" />
Lukas Fleischer's avatar
Lukas Fleischer committed
210
						<?php if ($SID): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
211
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
Lukas Fleischer's avatar
Lukas Fleischer committed
212
						<?php endif; ?>
213
214
						<input type="text" name="keywords" value="<?= htmlspecialchars(implode(" ", $keywords), ENT_QUOTES) ?>"/>
						<input type="submit" value="<?= __('Update') ?>"/>
215
216
					</div>
				</form>
217
218
219
220
221
222
223
224
225
<?php
else:
	foreach ($keywords as $kw) {
		echo '<a class="keyword" href="';
		echo get_uri('/packages/') . '?K=' . urlencode($kw) . '&amp;SB=p';
		echo '">' . htmlspecialchars($kw) . "</a>\n";
	}
endif;
?>
226
			</td>
227
		</tr>
228
<?php endif; ?>
229
		<?php if (count($lics) > 0): ?>
230
		<tr>
231
232
233
234
235
236
237
238
239
240
241
242
			<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>
243
		</tr>
244
		<?php endif; ?>
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
		<?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; ?>
261
262
263
264
265
266
267
		<?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)): ?>
268
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
269
					<?php else: ?>
270
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
271
272
273
274
275
276
277
278
279
280
281
282
283
					<?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)): ?>
284
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
285
					<?php else: ?>
286
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
287
288
289
290
291
292
293
294
295
296
297
298
299
					<?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)): ?>
300
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
301
					<?php else: ?>
302
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
303
304
305
306
307
308
					<?php endif; ?>
				</span>
				<?php endforeach; ?>
			</td>
		</tr>
		<?php endif; ?>
309
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
310
			<th><?= __('Submitter') .': ' ?></th>
Lukas Fleischer's avatar
Lukas Fleischer committed
311
			<td><?= html_format_username($submitter) ?></td>
312
		</tr>
313
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
314
			<th><?= __('Maintainer') .': ' ?></th>
315
			<td><?= html_format_maintainers($maintainer, $comaintainers) ?></td>
316
317
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
318
319
			<th><?= __('Last Packager') .': ' ?></th>
			<td><?= html_format_username($packager) ?></td>
320
321
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
322
			<th><?= __('Votes') . ': ' ?></th>
Lukas Fleischer's avatar
Lukas Fleischer committed
323
			<?php if (has_credential(CRED_PKGBASE_LIST_VOTERS)): ?>
324
			<td><a href="<?= get_pkgbase_uri($row['BaseName']); ?>voters/"><?= $votes ?></a></td>
Lukas Fleischer's avatar
Lukas Fleischer committed
325
			<?php else: ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
326
			<td><?= $votes ?></td>
Lukas Fleischer's avatar
Lukas Fleischer committed
327
			<?php endif; ?>
328
329
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
330
331
			<th><?= __('First Submitted') . ': ' ?></th>
			<td><?= $submitted_time ?></td>
332
333
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
334
335
			<th><?= __('Last Updated') . ': ' ?></th>
			<td><?= $updated_time ?></td>
336
337
338
339
340
		</tr>
	</table>

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