pkg_details.php 11.3 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
88

$base_uri = get_pkgbase_uri($row['BaseName']);

89
90
?>
<div id="pkgdetails" class="box">
Lukas Fleischer's avatar
Lukas Fleischer committed
91
	<h2><?= __('Package Details') . ': ' . htmlspecialchars($row['Name']) . ' ' . htmlspecialchars($row['Version']) ?></h2>
92
93
	<div id="detailslinks" class="listing">
		<div id="actionlist">
94
			<h4><?= __('Package Actions') ?></h4>
95
			<ul class="small">
96
				<li>
97
98
					<a href="<?= $pkgbuild_uri ?>"><?= __('View PKGBUILD') ?></a> /
					<a href="<?= $log_uri ?>"><?= __('View Changes') ?></a>
99
				</li>
100
				<li><a href="<?= $snapshot_uri ?>"><?= __('Download snapshot') ?></a>
101
				<li><a href="https://wiki.archlinux.org/index.php/Special:Search?search=<?= urlencode($row['Name']) ?>"><?= __('Search wiki') ?></a></li>
102
				<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
103
				<?php if ($uid): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
104
				<?php if ($row["OutOfDateTS"] === NULL): ?>
105
				<li><?= html_action_form($base_uri . 'flag/', "do_Flag", __('Flag package out-of-date')) ?></li>
106
				<?php elseif (($row["OutOfDateTS"] !== NULL) && has_credential(CRED_PKGBASE_UNFLAG, $maintainers)): ?>
107
				<li><?= html_action_form($base_uri . 'unflag/', "do_UnFlag", __('Unflag package')) ?></li>
Lukas Fleischer's avatar
Lukas Fleischer committed
108
				<?php endif; ?>
109

110
				<?php if (pkgbase_user_voted($uid, $base_id)): ?>
111
				<li><?= html_action_form($base_uri . 'unvote/', "do_UnVote", __('Remove vote')) ?></li>
112
				<?php else: ?>
113
				<li><?= html_action_form($base_uri . 'vote/', "do_Vote", __('Vote for this package')) ?></li>
114
				<?php endif; ?>
115

116
				<?php if (pkgbase_user_notify($uid, $base_id)): ?>
117
				<li><?= html_action_form($base_uri . 'unnotify/', "do_UnNotify", __('Disable notifications')) ?></li>
118
				<?php else: ?>
119
				<li><?= html_action_form($base_uri . 'notify/', "do_Notify", __('Notify of new comments')) ?></li>
120
				<?php endif; ?>
121

122
				<?php if (has_credential(CRED_PKGBASE_EDIT_COMAINTAINERS, array($row["MaintainerUID"]))): ?>
123
				<li><?= html_action_link($base_uri . 'comaintainers/', __('Manage Co-Maintainers')) ?></a></li>
124
				<?php endif; ?>
125

126
				<li><span class="flagged"><?php if ($row["RequestCount"] > 0) { echo _n('%d pending request', '%d pending requests', $row["RequestCount"]); } ?></span></li>
127
128
				<li><?= html_action_link($base_uri . 'request/', __('File Request')) ?></a></li>

Lukas Fleischer's avatar
Lukas Fleischer committed
129
				<?php if (has_credential(CRED_PKGBASE_DELETE)): ?>
130
131
				<li><?= html_action_link($base_uri . 'delete/', __('Delete Package')) ?></a></li>
				<li><?= html_action_link($base_uri . 'merge/', __('Merge Package')) ?></a></li>
132
				<?php endif; ?>
133
134

				<?php if ($uid && $row["MaintainerUID"] === NULL): ?>
135
				<li><?= html_action_form($base_uri . 'adopt/', "do_Adopt", __('Adopt Package')) ?></li>
Lukas Fleischer's avatar
Lukas Fleischer committed
136
				<?php elseif (has_credential(CRED_PKGBASE_DISOWN, array($row["MaintainerUID"]))): ?>
137
138
				<li><?= html_action_form($base_uri . 'disown/', "do_Disown", __('Disown Package')) ?></li>
				<?php endif; ?>
139
				<?php endif; ?>
140
141
142
			</ul>
		</div>
	</div>
143

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

	<div id="metadata">
		<div id="pkgdeps" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
317
			<h3><?= __('Dependencies') . " (" . count($deps) . ")"?></h3>
318
<?php if (count($deps) > 0): ?>
319
			<ul id="pkgdepslist">
320
<?php while (list($k, $darr) = each($deps)): ?>
321
	<li><?= pkg_depend_link($darr[0], $darr[1], $darr[2], $darr[3], $darr[4]); ?></li>
322
<?php endwhile; ?>
323
324
			</ul>
<?php endif; ?>
325
		</div>
326
		<div id="pkgreqs" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
327
			<h3><?= __('Required by') . " (" . count($requiredby) . ")"?></h3>
328
<?php if (count($requiredby) > 0): ?>
329
			<ul id="pkgreqslist">
330
331
332
				<?php while (list($k, $darr) = each($requiredby)): ?>
				<li><?= pkg_depend_link($darr[0], $darr[1], $darr[2], $darr[3], $darr[4], false); ?></li>
				<?php endwhile; ?>
333
334
335
336
			</ul>
<?php endif; ?>
		</div>
		<div id="pkgfiles" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
337
			<h3><?= __('Sources') ?></h3>
338
		</div>
339
		<?php if (count($sources) > 0): ?>
340
		<div>
Lukas Fleischer's avatar
Lukas Fleischer committed
341
			<ul id="pkgsrcslist">
342
343
344
					<?php while (list($k, $src) = each($sources)): ?>
					<li><?= pkg_source_link($src[0], $src[1]) ?></li>
					<?php endwhile; ?>
345
346
			</ul>
		</div>
347
		<?php endif; ?>
348
349
	</div>
</div>