pkg_details.php 8.83 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
$popularity = $row['Popularity'];
29

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

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

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

42
43
$deps = pkg_dependencies($row["ID"]);
$requiredby = pkg_required($row["Name"]);
44

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

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

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

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

85
# $sources[0] = 'src';
86
$sources = pkg_sources($row["ID"]);
87
88
89

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

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

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

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

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