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

3
$pkgbuild_uri = sprintf(config_get('options', 'source_file_uri'), 'PKGBUILD', urlencode($row['BaseName']));
4
5
$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
$max_depends = config_get_int('options', 'max_depends');
9

10
$uid = uid_from_sid($SID);
11

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

15
$keywords = pkgbase_get_keywords($base_id);
16

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

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

29
$votes = $row['NumVotes'];
30
$popularity = $row['Popularity'];
31

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

# Print the timestamps for last updates
Mark Weiman's avatar
Mark Weiman committed
37
38
39
$updated_time = ($row["ModifiedTS"] == 0) ? $msg : date("Y-m-d H:i", intval($row["ModifiedTS"]));
$submitted_time = ($row["SubmittedTS"] == 0) ? $msg : date("Y-m-d H:i", intval($row["SubmittedTS"]));
$out_of_date_time = ($row["OutOfDateTS"] == 0) ? $msg : date("Y-m-d", intval($row["OutOfDateTS"]));
40

41
$lics = pkg_licenses($row["ID"]);
42
43
$grps = pkg_groups($row["ID"]);

44
$deps = pkg_dependencies($row["ID"], $max_depends);
Lukas Fleischer's avatar
Lukas Fleischer committed
45

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

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

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

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

86
$requiredby = pkg_required($row["Name"], $rels_p, $max_depends);
87

88
# $sources[0] = 'src';
89
$sources = pkg_sources($row["ID"]);
90
91
92

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

93
94
?>
<div id="pkgdetails" class="box">
Lukas Fleischer's avatar
Lukas Fleischer committed
95
	<h2><?= __('Package Details') . ': ' . htmlspecialchars($row['Name']) . ' ' . htmlspecialchars($row['Version']) ?></h2>
96
97

	<?php include('pkgbase_actions.php') ?>
98

99
	<table id="pkginfo">
100
101
		<tr>
			<th><?= __('Git Clone URL') . ': ' ?></th>
102
			<td>
103
				<a href="<?= $git_clone_uri_anon ?>"><?= $git_clone_uri_anon ?></a> (<?= __('read-only') ?>)
104
				<?php if (in_array($uid, $maintainers)): ?>
105
106
107
				<br /> <a href="<?= $git_clone_uri_priv ?>"><?= $git_clone_uri_priv ?></a>
				<?php endif; ?>
			</td>
108
		</tr>
109
110
111
112
		<tr>
			<th><?= __('Package Base') . ': ' ?></th>
			<td class="wrap"><a href="<?= htmlspecialchars(get_pkgbase_uri($row['BaseName']), ENT_QUOTES); ?>"><?= htmlspecialchars($row['BaseName']); ?></a></td>
		</tr>
113
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
114
			<th><?= __('Description') . ': ' ?></th>
115
<?php if (!empty($row['Description'])): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
116
			<td class="wrap"><?= htmlspecialchars($row['Description']); ?></td>
117
118
119
<?php else: ?>
			<td class="wrap"><?= __('None') ?></td>
<?php endif; ?>
120
121
		</tr>
		<tr>
122
			<th><?= __('Upstream URL') . ': ' ?></th>
123
<?php if (!empty($row['URL'])): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
124
			<td><a href="<?= htmlspecialchars($row['URL'], ENT_QUOTES) ?>" title="<?= __('Visit the website for') . ' ' . htmlspecialchars( $row['Name'])?>"><?= htmlspecialchars($row['URL'], ENT_QUOTES) ?></a></td>
125
126
127
<?php else: ?>
			<td class="wrap"><?= __('None') ?></td>
<?php endif; ?>
128
		</tr>
129
<?php
130
if (has_credential(CRED_PKGBASE_SET_KEYWORDS, $maintainers) || count($keywords) > 0):
131
?>
132
133
		<tr>
			<th><?= __('Keywords') . ': ' ?></th>
134
			<td>
135
<?php
136
if (has_credential(CRED_PKGBASE_SET_KEYWORDS, $maintainers)):
137
?>
138
				<form method="post" action="<?= htmlspecialchars(get_pkgbase_uri($row['BaseName']), ENT_QUOTES); ?>">
139
					<div>
140
						<input type="hidden" name="action" value="do_SetKeywords" />
Lukas Fleischer's avatar
Lukas Fleischer committed
141
						<?php if ($SID): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
142
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
Lukas Fleischer's avatar
Lukas Fleischer committed
143
						<?php endif; ?>
144
145
						<input type="text" name="keywords" value="<?= htmlspecialchars(implode(" ", $keywords), ENT_QUOTES) ?>"/>
						<input type="submit" value="<?= __('Update') ?>"/>
146
147
					</div>
				</form>
148
149
150
151
152
153
154
155
156
<?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;
?>
157
			</td>
158
		</tr>
159
<?php endif; ?>
160
		<?php if (count($lics) > 0): ?>
161
		<tr>
162
163
164
165
166
167
168
169
170
171
172
173
			<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>
174
		</tr>
175
		<?php endif; ?>
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
		<?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; ?>
192
193
194
195
196
197
198
		<?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)): ?>
199
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
200
					<?php else: ?>
201
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
202
203
204
205
206
207
208
209
210
211
212
213
214
					<?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)): ?>
215
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
216
					<?php else: ?>
217
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
218
219
220
221
222
223
224
225
226
227
228
229
230
					<?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)): ?>
231
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
232
					<?php else: ?>
233
					<?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
234
235
236
237
238
239
					<?php endif; ?>
				</span>
				<?php endforeach; ?>
			</td>
		</tr>
		<?php endif; ?>
240
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
241
			<th><?= __('Submitter') .': ' ?></th>
Lukas Fleischer's avatar
Lukas Fleischer committed
242
			<td><?= html_format_username($submitter) ?></td>
243
		</tr>
244
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
245
			<th><?= __('Maintainer') .': ' ?></th>
246
			<td><?= html_format_maintainers($maintainer, $comaintainers) ?></td>
247
248
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
249
250
			<th><?= __('Last Packager') .': ' ?></th>
			<td><?= html_format_username($packager) ?></td>
251
252
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
253
			<th><?= __('Votes') . ': ' ?></th>
Lukas Fleischer's avatar
Lukas Fleischer committed
254
			<?php if (has_credential(CRED_PKGBASE_LIST_VOTERS)): ?>
255
			<td><a href="<?= get_pkgbase_uri($row['BaseName']); ?>voters/"><?= $votes ?></a></td>
Lukas Fleischer's avatar
Lukas Fleischer committed
256
			<?php else: ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
257
			<td><?= $votes ?></td>
Lukas Fleischer's avatar
Lukas Fleischer committed
258
			<?php endif; ?>
259
		</tr>
260
261
262
263
		<tr>
			<th><?= __('Popularity') . ': ' ?></th>
			<td><?= number_format($popularity, 6) ?></td>
		</tr>
264
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
265
266
			<th><?= __('First Submitted') . ': ' ?></th>
			<td><?= $submitted_time ?></td>
267
268
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
269
270
			<th><?= __('Last Updated') . ': ' ?></th>
			<td><?= $updated_time ?></td>
271
272
273
274
275
		</tr>
	</table>

	<div id="metadata">
		<div id="pkgdeps" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
276
			<h3><?= __('Dependencies') . " (" . count($deps) . ")"?></h3>
277
<?php if (count($deps) > 0): ?>
278
			<ul id="pkgdepslist">
279
<?php while (list($k, $darr) = each($deps)): ?>
280
	<li><?= pkg_depend_link($darr[0], $darr[1], $darr[2], $darr[3], $darr[4], $darr[5]); ?></li>
281
<?php endwhile; ?>
282
283
			</ul>
<?php endif; ?>
284
		</div>
285
		<div id="pkgreqs" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
286
			<h3><?= __('Required by') . " (" . count($requiredby) . ")"?></h3>
287
<?php if (count($requiredby) > 0): ?>
288
			<ul id="pkgreqslist">
289
				<?php while (list($k, $darr) = each($requiredby)): ?>
290
				<li><?= pkg_requiredby_link($darr[0], $darr[1], $darr[2], $darr[3], $row['Name']); ?></li>
291
				<?php endwhile; ?>
292
293
294
295
			</ul>
<?php endif; ?>
		</div>
		<div id="pkgfiles" class="listing">
296
			<h3><?= __('Sources') . " (" . count($sources) . ")"?></h3>
297
		</div>
298
		<?php if (count($sources) > 0): ?>
299
		<div>
Lukas Fleischer's avatar
Lukas Fleischer committed
300
			<ul id="pkgsrcslist">
301
					<?php while (list($k, $src) = each($sources)): ?>
302
					<li><?= pkg_source_link($src[0], $src[1], urlencode($row['BaseName'])) ?></li>
303
					<?php endwhile; ?>
304
305
			</ul>
		</div>
306
		<?php endif; ?>
307
308
	</div>
</div>