pkg_details.php 10.8 KB
Newer Older
1
<?php
2
3
$atype = account_from_sid($SID);
$uid = uid_from_sid($SID);
4

5
$pkgid = intval($row['ID']);
6

7
$catarr = pkgCategories();
8

9
10
$submitter = username_from_id($row["SubmitterUID"]);
$maintainer = username_from_id($row["MaintainerUID"]);
11

12
$votes = $row['NumVotes'];
13

14
15
16
17
18
# In case of wanting to put a custom message
$msg = __('unknown');
$license = empty($row['License']) ? $msg : $row['License'];

# Print the timestamps for last updates
19
20
21
$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"]));
22

23
$urlpath = URL_DIR . substr($row['Name'], 0, 2) . "/" . $row['Name'];
Lukas Fleischer's avatar
Lukas Fleischer committed
24

25
26
$deps = package_dependencies($row["ID"]);
$requiredby = package_required($row["Name"]);
27

28
29
30
31
# $sources[0] = 'src';
$sources = package_sources($row["ID"]);
?>
<div id="pkgdetails" class="box">
Lukas Fleischer's avatar
Lukas Fleischer committed
32
	<h2><?= __('Package Details') . ': ' . htmlspecialchars($row['Name']) . ' ' . htmlspecialchars($row['Version']) ?></h2>
33
34
	<div id="detailslinks" class="listing">
		<div id="actionlist">
35
			<h4><?= __('Package Actions') ?></h4>
36
			<ul class="small">
Lukas Fleischer's avatar
Lukas Fleischer committed
37
38
				<li><a href="<?= $urlpath ?>/PKGBUILD"><?= __('View PKGBUILD') ?></a></li>
				<li><a href="<?= $urlpath . '/' . $row['Name'] ?>.tar.gz"><?= __('Download tarball') ?></a></li>
39
				<li><span class="flagged"><?php if ($row["OutOfDateTS"] !== NULL) { echo __('Flagged out-of-date')." (${out_of_date_time})"; } ?></span></li>
40
				<?php if ($USE_VIRTUAL_URLS && $uid): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
41
				<?php if ($row["OutOfDateTS"] === NULL): ?>
42
43
				<li>
					<form action="<?= get_pkg_uri($row['Name']) . 'flag/'; ?>" method="post">
44
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
45
46
47
						<input type="submit" class="button text-button" name="do_Flag" value="<?= __('Flag package out-of-date') ?>" />
					</form>
				</li>
48
49
				<?php elseif (($row["OutOfDateTS"] !== NULL) &&
				($uid == $row["MaintainerUID"] || $atype == "Trusted User" || $atype == "Developer")): ?>
50
51
				<li>
					<form action="<?= get_pkg_uri($row['Name']) . 'unflag/'; ?>" method="post">
52
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
53
54
55
						<input type="submit" class="button text-button" name="do_UnFlag" value="<?= __('Unflag package') ?>" />
					</form>
				</li>
Lukas Fleischer's avatar
Lukas Fleischer committed
56
				<?php endif; ?>
57
				<?php if (user_voted($uid, $row['ID'])): ?>
58
59
				<li>
					<form action="<?= get_pkg_uri($row['Name']) . 'unvote/'; ?>" method="post">
60
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
61
62
63
						<input type="submit" class="button text-button" name="do_UnVote" value="<?= __('Remove vote') ?>" />
					</form>
				</li>
64
				<?php else: ?>
65
66
				<li>
					<form action="<?= get_pkg_uri($row['Name']) . 'vote/'; ?>" method="post">
67
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
68
69
70
						<input type="submit" class="button text-button" name="do_Vote" value="<?= __('Vote for this package') ?>" />
					</form>
				</li>
71
72
				<?php endif; ?>
				<?php if (user_notify($uid, $row['ID'])): ?>
73
74
				<li>
					<form action="<?= get_pkg_uri($row['Name']) . 'unnotify/'; ?>" method="post">
75
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
76
77
78
						<input type="submit" class="button text-button" name="do_UnNotify" value="<?= __('Disable notifications') ?>" />
					</form>
				</li>
79
				<?php else: ?>
80
81
				<li>
					<form action="<?= get_pkg_uri($row['Name']) . 'notify/'; ?>" method="post">
82
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
83
84
85
						<input type="submit" class="button text-button" name="do_Notify" value="<?= __('Notify of new comments') ?>" />
					</form>
				</li>
86
				<?php endif; ?>
87
88
				<?php if ($atype == "Trusted User" || $atype == "Developer"): ?>
				<li><a href="<?= get_pkg_uri($row['Name']) . 'delete/'; ?>"><?= __('Delete Package'); ?></a></li>
89
				<li><a href="<?= get_pkg_uri($row['Name']) . 'merge/'; ?>"><?= __('Merge Package'); ?></a></li>
90
				<?php endif; ?>
91
				<?php endif; ?>
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108

				<?php if ($uid && $row["MaintainerUID"] === NULL): ?>
				<li>
					<form action="<?= get_pkg_uri($row['Name']) . 'adopt/'; ?>" method="post">
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
						<input type="submit" class="button text-button" name="do_Adopt" value="<?= __('Adopt Package') ?>" />
					</form>
				</li>
				<?php elseif ($uid && $uid == $row["MaintainerUID"] ||
					$atype == "Trusted User" || $atype == "Developer"): ?>
				<li>
					<form action="<?= get_pkg_uri($row['Name']) . 'disown/'; ?>" method="post">
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
						<input type="submit" class="button text-button" name="do_Disown" value="<?= __('Disown Package') ?>" />
					</form>
				</li>
				<?php endif; ?>
109
110
111
			</ul>
		</div>
	</div>
112

113
	<table id="pkginfo">
114
115
116
117
		<tr>
			<th><?= __('Package Base') . ': ' ?></th>
			<td class="wrap"><a href="<?= htmlspecialchars(get_pkgbase_uri($row['BaseName']), ENT_QUOTES); ?>"><?= htmlspecialchars($row['BaseName']); ?></a></td>
		</tr>
118
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
119
120
			<th><?= __('Description') . ': ' ?></th>
			<td class="wrap"><?= htmlspecialchars($row['Description']); ?></td>
121
122
		</tr>
		<tr>
123
			<th><?= __('Upstream URL') . ': ' ?></th>
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
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
127
			<th><?= __('Category') . ': ' ?></th>
128
<?php
129
130
if ($SID && ($uid == $row["MaintainerUID"] ||
	($atype == "Developer" || $atype == "Trusted User"))):
131
?>
132
			<td>
Lukas Fleischer's avatar
Lukas Fleischer committed
133
				<form method="post" action="<?= htmlspecialchars(get_pkg_uri($row['Name']), ENT_QUOTES); ?>">
134
135
					<div>
						<input type="hidden" name="action" value="do_ChangeCategory" />
Lukas Fleischer's avatar
Lukas Fleischer committed
136
						<?php if ($SID): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
137
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
Lukas Fleischer's avatar
Lukas Fleischer committed
138
						<?php endif; ?>
139
						<select name="category_id">
140
<?php
141
	foreach ($catarr as $cid => $catname):
142
?>
Lukas Fleischer's avatar
Lukas Fleischer committed
143
							<option value="<?= $cid ?>"<?php if ($cid == $row["CategoryID"]) { ?> selected="selected" <?php } ?>><?= $catname ?></option>
144
145
	<?php endforeach; ?>
						</select>
Lukas Fleischer's avatar
Lukas Fleischer committed
146
						<input type="submit" value="<?= __('Change category') ?>"/>
147
148
149
150
					</div>
				</form>
<?php else: ?>
			<td>
Lukas Fleischer's avatar
Lukas Fleischer committed
151
				<a href="<?= get_uri('/packages/'); ?>?C=<?= $row['CategoryID'] ?>"><?= $row['Category'] ?></a>
152
153
<?php endif; ?>
			</td>
154
		</tr>
155
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
156
157
			<th><?= __('License') . ': ' ?></th>
			<td><?= htmlspecialchars($license) ?></td>
158
159
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
160
			<th><?= __('Submitter') .': ' ?></th>
161
<?php
162
163
if ($row["SubmitterUID"]):
	if ($SID):
164
		if (!$USE_VIRTUAL_URLS):
165
?>
Lukas Fleischer's avatar
Lukas Fleischer committed
166
			<td><a href="<?= get_uri('/account/'); ?>?Action=AccountInfo&amp;ID=<?= htmlspecialchars($row['SubmitterUID'], ENT_QUOTES) ?>" title="<?= __('View account information for')?> <?= htmlspecialchars($submitter) ?>"><?= htmlspecialchars($submitter) ?></a></td>
167
168
169
		<?php else: ?>
			<td><a href="<?= get_uri('/account/') . htmlspecialchars($submitter, ENT_QUOTES) ?>" title="<?= __('View account information for %s', htmlspecialchars($submitter)) ?>"><?= htmlspecialchars($submitter) ?></a></td>
		<?php endif; ?>
170
<?php else: ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
171
		<td><?= htmlspecialchars($submitter) ?></td>
172
173
	<?php endif; ?>
<?php else: ?>
174
			<td><?= __('None') ?></td>
175
<?php endif; ?>
176
		</tr>
177
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
178
			<th><?= __('Maintainer') .': ' ?></th>
179
<?php
180
181
if ($row["MaintainerUID"]):
	if ($SID):
182
		if (!$USE_VIRTUAL_URLS):
183
?>
Lukas Fleischer's avatar
Lukas Fleischer committed
184
			<td><a href="<?= get_uri('/account/'); ?>?Action=AccountInfo&amp;ID=<?= htmlspecialchars($row['MaintainerUID'], ENT_QUOTES) ?>" title="<?= __('View account information for')?> <?= htmlspecialchars($maintainer) ?>"><?= htmlspecialchars($maintainer) ?></a></td>
185
186
187
		<?php else: ?>
			<td><a href="<?= get_uri('/account/') . htmlspecialchars($maintainer, ENT_QUOTES) ?>" title="<?= __('View account information for %s', htmlspecialchars($maintainer)) ?>"><?= htmlspecialchars($maintainer) ?></a></td>
		<?php endif; ?>
188
	<?php else: ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
189
		<td><?= htmlspecialchars($maintainer) ?></td>
190
191
	<?php endif; ?>
<?php else: ?>
192
			<td><?= __('None') ?></td>
193
194
195
<?php endif; ?>
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
196
			<th><?= __('Votes') . ': ' ?></th>
197
198
<?php if ($atype == "Developer" || $atype == "Trusted User"): ?>
<?php if ($USE_VIRTUAL_URLS): ?>
199
			<td><a href="<?= get_pkg_uri($row['Name']); ?>voters/"><?= $votes ?></a></td>
200
<?php else: ?>
201
			<td><a href="<?= get_uri('/voters/'); ?>?N=<?= htmlspecialchars($row['Name'], ENT_QUOTES) ?>"><?= $votes ?></a></td>
202
<?php endif; ?>
203
<?php else: ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
204
			<td><?= $votes ?></td>
205
206
207
<?php endif; ?>
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
208
209
			<th><?= __('First Submitted') . ': ' ?></th>
			<td><?= $submitted_time ?></td>
210
211
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
212
213
			<th><?= __('Last Updated') . ': ' ?></th>
			<td><?= $updated_time ?></td>
214
215
216
217
218
		</tr>
	</table>

	<div id="metadata">
		<div id="pkgdeps" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
219
			<h3><?= __('Dependencies') . " (" . count($deps) . ")"?></h3>
220
221
222
223
224
225
226
<?php if (count($deps) > 0): ?>
			<ul>
<?php
	while (list($k, $darr) = each($deps)):
		# darr: (DepName, DepCondition, PackageID), where ID is NULL if it didn't exist
		if (!is_null($darr[2])):
?>
227
				<li><a href="<?= htmlspecialchars(get_pkg_uri($darr[0]), ENT_QUOTES); ?>" title="<?= __('View packages details for').' '. htmlspecialchars($darr[0]) ?>"><?= htmlspecialchars($darr[0]) ?></a><?= htmlspecialchars($darr[1]) ?></li>
228
		<?php else: ?>
229
				<li><a href="https://www.archlinux.org/packages/?q=<?= urlencode($darr[0])?>" title="<?= __('View packages details for').' ' . htmlspecialchars($darr[0]) ?>"><?= htmlspecialchars($darr[0]) ?></a><?= htmlspecialchars($darr[1]) ?></li>
230
231
232
233
		<?php endif; ?>
	<?php endwhile; ?>
			</ul>
<?php endif; ?>
234
		</div>
235
		<div id="pkgreqs" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
236
			<h3><?= __('Required by') . " (" . count($requiredby) . ")"?></h3>
237
238
239
240
241
<?php if (count($requiredby) > 0): ?>
			<ul>
<?php
	# darr: (PackageName, PackageID)
	while (list($k, $darr) = each($requiredby)):
242
?>
243
				<li><a href="<?= htmlspecialchars(get_pkg_uri($darr[0]), ENT_QUOTES); ?>" title="<?= __('View packages details for').' ' . htmlspecialchars($darr[0]) ?>"><?= htmlspecialchars($darr[0]) ?></a></li>
244
245
246
247
248
	<?php endwhile; ?>
			</ul>
<?php endif; ?>
		</div>
		<div id="pkgfiles" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
249
			<h3><?= __('Sources') ?></h3>
250
251
		</div>
<?php if (count($sources) > 0): ?>
252
		<div>
253
254
255
256
257
			<ul>
<?php
	while (list($k, $src) = each($sources)):
		$src = explode('::', $src);
		$parsed_url = parse_url($src[0]);
258

259
260
261
		# It is an external source
		if (isset($parsed_url['scheme']) || isset($src[1])):
?>
Lukas Fleischer's avatar
Lukas Fleischer committed
262
				<li><a href="<?= htmlspecialchars((isset($src[1]) ? $src[1] : $src[0]), ENT_QUOTES) ?>"><?= htmlspecialchars($src[0]) ?> </a></li>
263
264
265
266
267
<?php
		else:
			# It is presumably an internal source
			$src = $src[0];
?>
Lukas Fleischer's avatar
Lukas Fleischer committed
268
				<li><?= htmlspecialchars($src) ?></li>
269
270
271
272
273
		<?php endif; ?>
	<?php endwhile; ?>
			</ul>
		</div>
<?php endif; ?>
274
275
	</div>
</div>