pkg_details.php 12.6 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
$votes = $row['NumVotes'];
22

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

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

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

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

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

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

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

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

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

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

170
	<table id="pkginfo">
171
172
		<tr>
			<th><?= __('Git Clone URL') . ': ' ?></th>
173
			<td>
174
				<a href="<?= $git_clone_uri_anon ?>"><?= $git_clone_uri_anon ?></a> (<?= __('read-only') ?>)
175
176
177
178
				<?php if ($uid == $row["MaintainerUID"]): ?>
				<br /> <a href="<?= $git_clone_uri_priv ?>"><?= $git_clone_uri_priv ?></a>
				<?php endif; ?>
			</td>
179
		</tr>
180
181
182
183
		<tr>
			<th><?= __('Package Base') . ': ' ?></th>
			<td class="wrap"><a href="<?= htmlspecialchars(get_pkgbase_uri($row['BaseName']), ENT_QUOTES); ?>"><?= htmlspecialchars($row['BaseName']); ?></a></td>
		</tr>
184
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
185
186
			<th><?= __('Description') . ': ' ?></th>
			<td class="wrap"><?= htmlspecialchars($row['Description']); ?></td>
187
188
		</tr>
		<tr>
189
			<th><?= __('Upstream URL') . ': ' ?></th>
Lukas Fleischer's avatar
Lukas Fleischer committed
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"]))):
194
?>
195
196
		<tr>
			<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" />
Lukas Fleischer's avatar
Lukas Fleischer committed
201
						<?php if ($SID): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
202
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
Lukas Fleischer's avatar
Lukas Fleischer committed
203
						<?php endif; ?>
204
205
						<input type="text" name="keywords" value="<?= htmlspecialchars(implode(" ", $keywords), ENT_QUOTES) ?>"/>
						<input type="submit" value="<?= __('Update') ?>"/>
206
207
208
					</div>
				</form>
			</td>
209
		</tr>
210
<?php endif; ?>
211
		<?php if (count($lics) > 0): ?>
212
		<tr>
213
214
215
216
217
218
219
220
221
222
223
224
			<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>
225
		</tr>
226
		<?php endif; ?>
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
		<?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; ?>
243
244
245
246
247
248
249
		<?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)): ?>
250
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
251
					<?php else: ?>
252
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
253
254
255
256
257
258
259
260
261
262
263
264
265
					<?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)): ?>
266
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
267
					<?php else: ?>
268
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
269
270
271
272
273
274
275
276
277
278
279
280
281
					<?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)): ?>
282
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
283
					<?php else: ?>
284
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
285
286
287
288
289
290
					<?php endif; ?>
				</span>
				<?php endforeach; ?>
			</td>
		</tr>
		<?php endif; ?>
291
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
292
			<th><?= __('Submitter') .': ' ?></th>
Lukas Fleischer's avatar
Lukas Fleischer committed
293
			<td><?= html_format_username($submitter) ?></td>
294
		</tr>
295
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
296
			<th><?= __('Maintainer') .': ' ?></th>
297
			<td><?= html_format_maintainers($maintainer, $comaintainers) ?></td>
298
299
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
300
301
			<th><?= __('Last Packager') .': ' ?></th>
			<td><?= html_format_username($packager) ?></td>
302
303
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
304
			<th><?= __('Votes') . ': ' ?></th>
Lukas Fleischer's avatar
Lukas Fleischer committed
305
			<?php if (has_credential(CRED_PKGBASE_LIST_VOTERS)): ?>
306
			<td><a href="<?= get_pkgbase_uri($row['BaseName']); ?>voters/"><?= $votes ?></a></td>
Lukas Fleischer's avatar
Lukas Fleischer committed
307
			<?php else: ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
308
			<td><?= $votes ?></td>
Lukas Fleischer's avatar
Lukas Fleischer committed
309
			<?php endif; ?>
310
311
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
312
313
			<th><?= __('First Submitted') . ': ' ?></th>
			<td><?= $submitted_time ?></td>
314
315
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
316
317
			<th><?= __('Last Updated') . ': ' ?></th>
			<td><?= $updated_time ?></td>
318
319
320
321
322
		</tr>
	</table>

	<div id="metadata">
		<div id="pkgdeps" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
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
330
			</ul>
<?php endif; ?>
331
		</div>
332
		<div id="pkgreqs" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
333
			<h3><?= __('Required by') . " (" . count($requiredby) . ")"?></h3>
334
<?php if (count($requiredby) > 0): ?>
335
			<ul id="pkgreqslist">
336
337
338
<?php
	# darr: (PackageName, PackageID)
	while (list($k, $darr) = each($requiredby)):
339
?>
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
342
343
344
345
	<?php endwhile; ?>
			</ul>
<?php endif; ?>
		</div>
		<div id="pkgfiles" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
346
			<h3><?= __('Sources') ?></h3>
347
		</div>
348
		<?php if (count($sources) > 0): ?>
349
		<div>
Lukas Fleischer's avatar
Lukas Fleischer committed
350
			<ul id="pkgsrcslist">
351
352
353
					<?php while (list($k, $src) = each($sources)): ?>
					<li><?= pkg_source_link($src[0], $src[1]) ?></li>
					<?php endwhile; ?>
354
355
			</ul>
		</div>
356
		<?php endif; ?>
357
358
	</div>
</div>