pkg_details.php 8.87 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
if ($row["MaintainerUID"] !== NULL) {
	$maintainers = array_merge(array($row["MaintainerUID"]), pkgbase_get_comaintainer_uids(array($base_id)));
} else {
24
	$maintainers = array();
25
}
26
$unflaggers = array_merge($maintainers, array($row["FlaggerUID"]));
27

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

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

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

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

43
44
$deps = pkg_dependencies($row["ID"]);
$requiredby = pkg_required($row["Name"]);
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
# $sources[0] = 'src';
87
$sources = pkg_sources($row["ID"]);
88
89
90

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

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

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

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

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