pkg_details.php 12.5 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
$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
		</tr>
191
<?php
192
if (has_credential(CRED_PKGBASE_SET_KEYWORDS, array($row["MaintainerUID"]))):
193
?>
194
195
		<tr>
			<th><?= __('Keywords') . ': ' ?></th>
196
			<td>
197
				<form method="post" action="<?= htmlspecialchars(get_pkgbase_uri($row['BaseName']), ENT_QUOTES); ?>">
198
					<div>
199
						<input type="hidden" name="action" value="do_SetKeywords" />
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
204
						<input type="text" name="keywords" value="<?= htmlspecialchars(implode(" ", $keywords), ENT_QUOTES) ?>"/>
						<input type="submit" value="<?= __('Update') ?>"/>
205
206
207
					</div>
				</form>
			</td>
208
		</tr>
209
<?php endif; ?>
210
		<?php if (count($lics) > 0): ?>
211
		<tr>
212
213
214
215
216
217
218
219
220
221
222
223
			<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>
224
		</tr>
225
		<?php endif; ?>
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
		<?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; ?>
242
243
244
245
246
247
248
		<?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)): ?>
249
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
250
					<?php else: ?>
251
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
252
253
254
255
256
257
258
259
260
261
262
263
264
					<?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)): ?>
265
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
266
					<?php else: ?>
267
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
268
269
270
271
272
273
274
275
276
277
278
279
280
					<?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)): ?>
281
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
282
					<?php else: ?>
283
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
284
285
286
287
288
289
					<?php endif; ?>
				</span>
				<?php endforeach; ?>
			</td>
		</tr>
		<?php endif; ?>
290
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
291
			<th><?= __('Submitter') .': ' ?></th>
Lukas Fleischer's avatar
Lukas Fleischer committed
292
			<td><?= html_format_username($submitter) ?></td>
293
		</tr>
294
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
295
			<th><?= __('Maintainer') .': ' ?></th>
Lukas Fleischer's avatar
Lukas Fleischer committed
296
			<td><?= html_format_username($maintainer) ?></td>
297
298
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
299
300
			<th><?= __('Last Packager') .': ' ?></th>
			<td><?= html_format_username($packager) ?></td>
301
302
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
303
			<th><?= __('Votes') . ': ' ?></th>
Lukas Fleischer's avatar
Lukas Fleischer committed
304
			<?php if (has_credential(CRED_PKGBASE_LIST_VOTERS)): ?>
305
			<td><a href="<?= get_pkgbase_uri($row['BaseName']); ?>voters/"><?= $votes ?></a></td>
Lukas Fleischer's avatar
Lukas Fleischer committed
306
			<?php else: ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
307
			<td><?= $votes ?></td>
Lukas Fleischer's avatar
Lukas Fleischer committed
308
			<?php endif; ?>
309
310
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
311
312
			<th><?= __('First Submitted') . ': ' ?></th>
			<td><?= $submitted_time ?></td>
313
314
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
315
316
			<th><?= __('Last Updated') . ': ' ?></th>
			<td><?= $updated_time ?></td>
317
318
319
320
321
		</tr>
	</table>

	<div id="metadata">
		<div id="pkgdeps" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
322
			<h3><?= __('Dependencies') . " (" . count($deps) . ")"?></h3>
323
<?php if (count($deps) > 0): ?>
324
			<ul id="pkgdepslist">
325
<?php while (list($k, $darr) = each($deps)): ?>
326
	<li><?= pkg_depend_link($darr[0], $darr[1], $darr[2], $darr[3], $darr[4]); ?></li>
327
<?php endwhile; ?>
328
329
			</ul>
<?php endif; ?>
330
		</div>
331
		<div id="pkgreqs" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
332
			<h3><?= __('Required by') . " (" . count($requiredby) . ")"?></h3>
333
<?php if (count($requiredby) > 0): ?>
334
			<ul id="pkgreqslist">
335
336
337
<?php
	# darr: (PackageName, PackageID)
	while (list($k, $darr) = each($requiredby)):
338
?>
339
				<li><a href="<?= htmlspecialchars(get_pkg_uri($darr[0]), ENT_QUOTES); ?>" title="<?= __('View packages details for').' ' . htmlspecialchars($darr[0]) ?>"><?= htmlspecialchars($darr[0]) ?></a></li>
340
341
342
343
344
	<?php endwhile; ?>
			</ul>
<?php endif; ?>
		</div>
		<div id="pkgfiles" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
345
			<h3><?= __('Sources') ?></h3>
346
		</div>
347
		<?php if (count($sources) > 0): ?>
348
		<div>
Lukas Fleischer's avatar
Lukas Fleischer committed
349
			<ul id="pkgsrcslist">
350
351
352
					<?php while (list($k, $src) = each($sources)): ?>
					<li><?= pkg_source_link($src[0], $src[1]) ?></li>
					<?php endwhile; ?>
353
354
			</ul>
		</div>
355
		<?php endif; ?>
356
357
	</div>
</div>