pkg_details.php 8.66 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

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

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

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