pkg_details.php 9.07 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
35
36
	<div id="detailslinks" class="listing">
		<div id="actionlist">
			<h4>Package Actions</h4>
			<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): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
42
				<li><a href="<?= get_pkg_uri($row['Name']) . 'flag/'; ?>"><?= __('Flag package out-of-date'); ?></a></li>
43
44
				<?php elseif (($row["OutOfDateTS"] !== NULL) &&
				($uid == $row["MaintainerUID"] || $atype == "Trusted User" || $atype == "Developer")): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
45
				<li><a href="<?= get_pkg_uri($row['Name']) . 'unflag/'; ?>"><?= __('Unflag package'); ?></a></li>
Lukas Fleischer's avatar
Lukas Fleischer committed
46
				<?php endif; ?>
47
				<?php if (user_voted($uid, $row['ID'])): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
48
				<li><a href="<?= get_pkg_uri($row['Name']) . 'unvote/'; ?>"><?= __('Remove vote'); ?></a></li>
49
				<?php else: ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
50
				<li><a href="<?= get_pkg_uri($row['Name']) . 'vote/'; ?>"><?= __('Vote for this package'); ?></a></li>
51
52
				<?php endif; ?>
				<?php if (user_notify($uid, $row['ID'])): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
53
				<li><a href="<?= get_pkg_uri($row['Name']) . 'unnotify/'; ?>"><?= __('Disable notifications'); ?></a></li>
54
				<?php else: ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
55
				<li><a href="<?= get_pkg_uri($row['Name']) . 'notify/'; ?>"><?= __('Notify of new comments'); ?></a></li>
56
				<?php endif; ?>
57
58
				<?php if ($atype == "Trusted User" || $atype == "Developer"): ?>
				<li><a href="<?= get_pkg_uri($row['Name']) . 'delete/'; ?>"><?= __('Delete Package'); ?></a></li>
59
				<li><a href="<?= get_pkg_uri($row['Name']) . 'merge/'; ?>"><?= __('Merge Package'); ?></a></li>
60
				<?php endif; ?>
61
				<?php endif; ?>
62
			</ul>
63
			<?php if ($uid): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
64
			<form action="<?= htmlspecialchars(get_pkg_uri($row['Name']), ENT_QUOTES); ?>" method="post">
65
				<div>
Lukas Fleischer's avatar
Lukas Fleischer committed
66
67
68
					<input type="hidden" name="IDs[<?= $row['ID'] ?>]" value="1" />
					<input type="hidden" name="ID" value="<?= $row['ID'] ?>" />
					<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
69
70
				</div>
				<p>
71
					<?php if ($row["MaintainerUID"] === NULL): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
72
						<input type="submit" class="button" name="do_Adopt" value="<?= __("Adopt Packages") ?>" />
73
74
					<?php elseif ($uid == $row["MaintainerUID"] ||
						$atype == "Trusted User" || $atype == "Developer"): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
75
						<input type="submit" class="button" name="do_Disown" value="<?= __("Disown Packages") ?>" />
76
					<?php endif; ?>
77
				</p>
78
			</form>
79
			<?php endif; ?>
80
81
		</div>
	</div>
82

83
84
	<table id="pkginfo">
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
85
86
			<th><?= __('Description') . ': ' ?></th>
			<td class="wrap"><?= htmlspecialchars($row['Description']); ?></td>
87
88
89
		</tr>
		<tr>
			<th>Upstream URL:</th>
Lukas Fleischer's avatar
Lukas Fleischer committed
90
			<td><a href="<?= htmlspecialchars($row['URL'], ENT_QUOTES) ?>" title="<?= __('Visit the website for') . ' ' . htmlspecialchars( $row['Name'])?>"><?= htmlspecialchars($row['URL'], ENT_QUOTES) ?></a></td>
91
92
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
93
			<th><?= __('Category') . ': ' ?></th>
94
<?php
95
96
if ($SID && ($uid == $row["MaintainerUID"] ||
	($atype == "Developer" || $atype == "Trusted User"))):
97
?>
98
			<td>
Lukas Fleischer's avatar
Lukas Fleischer committed
99
				<form method="post" action="<?= htmlspecialchars(get_pkg_uri($row['Name']), ENT_QUOTES); ?>">
100
101
					<div>
						<input type="hidden" name="action" value="do_ChangeCategory" />
Lukas Fleischer's avatar
Lukas Fleischer committed
102
						<?php if ($SID): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
103
						<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
Lukas Fleischer's avatar
Lukas Fleischer committed
104
						<?php endif; ?>
105
						<select name="category_id">
106
<?php
107
	foreach ($catarr as $cid => $catname):
108
?>
Lukas Fleischer's avatar
Lukas Fleischer committed
109
							<option value="<?= $cid ?>"<?php if ($cid == $row["CategoryID"]) { ?> selected="selected" <?php } ?>><?= $catname ?></option>
110
111
	<?php endforeach; ?>
						</select>
Lukas Fleischer's avatar
Lukas Fleischer committed
112
						<input type="submit" value="<?= __('Change category') ?>"/>
113
114
115
116
					</div>
				</form>
<?php else: ?>
			<td>
Lukas Fleischer's avatar
Lukas Fleischer committed
117
				<a href="<?= get_uri('/packages/'); ?>?C=<?= $row['CategoryID'] ?>"><?= $row['Category'] ?></a>
118
119
120
<?php endif; ?>
			</td>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
121
122
			<th><?= __('License') . ': ' ?></th>
			<td><?= htmlspecialchars($license) ?></td>
123
124
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
125
			<th><?= __('Submitter') .': ' ?></th>
126
<?php
127
128
if ($row["SubmitterUID"]):
	if ($SID):
129
		if (!$USE_VIRTUAL_URLS):
130
?>
Lukas Fleischer's avatar
Lukas Fleischer committed
131
			<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>
132
133
134
		<?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; ?>
135
<?php else: ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
136
		<td><?= htmlspecialchars($submitter) ?></td>
137
138
139
140
141
	<?php endif; ?>
<?php else: ?>
			<td>None</td>
<?php endif; ?>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
142
			<th><?= __('Maintainer') .': ' ?></th>
143
<?php
144
145
if ($row["MaintainerUID"]):
	if ($SID):
146
		if (!$USE_VIRTUAL_URLS):
147
?>
Lukas Fleischer's avatar
Lukas Fleischer committed
148
			<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>
149
150
151
		<?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; ?>
152
	<?php else: ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
153
		<td><?= htmlspecialchars($maintainer) ?></td>
154
155
156
157
158
159
	<?php endif; ?>
<?php else: ?>
			<td>None</td>
<?php endif; ?>
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
160
			<th><?= __('Votes') . ': ' ?></th>
161
162
<?php if ($atype == "Developer" || $atype == "Trusted User"): ?>
<?php if ($USE_VIRTUAL_URLS): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
163
			<td><a href="<?= get_pkg_uri($row['Name']); ?>voters/"><?= $votes ?></a>
164
<?php else: ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
165
			<td><a href="<?= get_uri('/voters/'); ?>?ID=<?= $pkgid ?>"><?= $votes ?></a>
166
<?php endif; ?>
167
<?php else: ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
168
			<td><?= $votes ?></td>
169
170
171
<?php endif; ?>
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
172
173
			<th><?= __('First Submitted') . ': ' ?></th>
			<td><?= $submitted_time ?></td>
174
175
		</tr>
		<tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
176
177
			<th><?= __('Last Updated') . ': ' ?></th>
			<td><?= $updated_time ?></td>
178
179
180
181
182
		</tr>
	</table>

	<div id="metadata">
		<div id="pkgdeps" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
183
			<h3><?= __('Dependencies') . " (" . count($deps) . ")"?></h3>
184
185
186
187
188
189
190
<?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])):
?>
Lukas Fleischer's avatar
Lukas Fleischer committed
191
				<li><a href="<?= htmlspecialchars(get_pkg_uri($darr[0]), ENT_QUOTES); ?>" title="<?= __('View packages details for').' '.$darr[0].$darr[1]?>"><?= $darr[0].$darr[1]?></a></li>
192
		<?php else: ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
193
				<li><a href="http://www.archlinux.org/packages/?q=<?= urlencode($darr[0])?>" title="<?= __('View packages details for').' '.$darr[0].$darr[1] ?>"><?= $darr[0].$darr[1] ?></a></li>
194
195
196
197
		<?php endif; ?>
	<?php endwhile; ?>
			</ul>
<?php endif; ?>
198
		</div>
199
		<div id="pkgreqs" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
200
			<h3><?= __('Required by') . " (" . count($requiredby) . ")"?></h3>
201
202
203
204
205
<?php if (count($requiredby) > 0): ?>
			<ul>
<?php
	# darr: (PackageName, PackageID)
	while (list($k, $darr) = each($requiredby)):
206
?>
Lukas Fleischer's avatar
Lukas Fleischer committed
207
				<li><a href="<?= htmlspecialchars(get_pkg_uri($darr[0]), ENT_QUOTES); ?>" title="<?= __('View packages details for').' '.$darr[0]?>"><?= $darr[0] ?></a></li>
208
209
210
211
212
	<?php endwhile; ?>
			</ul>
<?php endif; ?>
		</div>
		<div id="pkgfiles" class="listing">
Lukas Fleischer's avatar
Lukas Fleischer committed
213
			<h3><?= __('Sources') ?></h3>
214
215
		</div>
<?php if (count($sources) > 0): ?>
216
		<div>
217
218
219
220
221
			<ul>
<?php
	while (list($k, $src) = each($sources)):
		$src = explode('::', $src);
		$parsed_url = parse_url($src[0]);
222

223
224
225
		# It is an external source
		if (isset($parsed_url['scheme']) || isset($src[1])):
?>
Lukas Fleischer's avatar
Lukas Fleischer committed
226
				<li><a href="<?= htmlspecialchars((isset($src[1]) ? $src[1] : $src[0]), ENT_QUOTES) ?>"><?= htmlspecialchars($src[0]) ?> </a></li>
227
228
229
230
231
<?php
		else:
			# It is presumably an internal source
			$src = $src[0];
?>
Lukas Fleischer's avatar
Lukas Fleischer committed
232
				<li><?= htmlspecialchars($src) ?></li>
233
234
235
236
237
		<?php endif; ?>
	<?php endwhile; ?>
			</ul>
		</div>
<?php endif; ?>
238
239
	</div>
</div>