pkg_search_results.php 5.54 KB
Newer Older
1
<?php
2
3
4
5
if ($show_headers) {
	$fmtth = function($title, $sb=false, $so=false, $hint=false) {
		echo '<th>';
		if ($sb) {
6
			echo '<a href="?' . mkurl('SB=' . $sb . '&SO=' . $so) . '">' . $title . '</a>';
7
8
9
10
11
12
13
14
15
16
17
18
19
20
		} else {
			echo $title;
		}
		if ($hint) {
			echo '<span title="' . $hint . '" class="hover-help"><sup>?</sup></span>';
		}
		echo '</th>';
	};
} else {
	$fmtth = function($title, $sb=false, $so=false, $hint=false) {
		echo '<th>' . $title . '</th>';
	};
}

21
if (!$result): ?>
22
	<p><?= __("Error retrieving package list.") ?></p>
23
<?php elseif ($total == 0): ?>
24
	<p><?= __("No packages matched your search criteria.") ?></p>
25
<?php else: ?>
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
	<?php if ($show_headers): ?>
	<div class="pkglist-stats">
		<p>
			<?= _n('%d package found.', '%d packages found.', $total) ?>
			<?= __('Page %d of %d.', $current, $pages) ?>
		</p>
		<?php if (count($templ_pages) > 1): ?>
		<p class="pkglist-nav">
			<?php foreach ($templ_pages as $pagenr => $pagestart): ?>
				<?php if ($pagestart === false): ?>
					<span class="page"><?= $pagenr ?></span>
				<?php elseif ($pagestart + 1 == $first): ?>
					<span class="page"><?= $pagenr ?></span>
				<?php else: ?>
					<a class="page" href="<?= get_uri('/packages/'); ?>?<?= mkurl('O=' . $pagestart) ?>"><?= $pagenr ?></a>
				<?php endif; ?>
			<?php endforeach; ?>
		</p>
Lukas Fleischer's avatar
Lukas Fleischer committed
44
		<?php endif; ?>
45
46
	</div>
	<?php endif; ?>
47

48
49
50
51
52
53
54
	<form id="pkglist-results-form" method="post" action="<?= get_uri('/pkgbase/'); ?>?<?= htmlentities($_SERVER['QUERY_STRING']) ?>">
		<table class="results">
		<thead>
			<tr>
				<?php if ($SID && $show_headers): ?>
				<th>&nbsp;</th>
				<?php endif; ?>
55
56
57
58
				<?php $fmtth(__('Name'), 'n', $SO_next) ?>
				<?php $fmtth(__('Version')) ?>
				<?php $fmtth(__('Votes'), 'v', $SO_next) ?>
				<?php $fmtth(__('Popularity'), 'p', $SO_next, __('Popularity is calculated as the sum of all votes with each vote being weighted with a factor of %.2f per day since its creation.', 0.98)) ?>
59
				<?php if ($SID): ?>
60
61
				<?php $fmtth(__('Voted'), 'w', $SO_next) ?>
				<?php $fmtth(__('Notify'), 'o', $SO_next) ?>
62
				<?php endif; ?>
63
64
				<?php $fmtth(__('Description')) ?>
				<?php $fmtth(__('Maintainer'), 'm', $SO_next) ?>
65
66
67
			</tr>
		</thead>
		<tbody>
68

Lukas Fleischer's avatar
Lukas Fleischer committed
69
	<?php foreach ($searchresults as $indx => $row): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
70
		<tr class="<?= ($indx % 2 == 0) ? 'odd' : 'even' ?>">
Lukas Fleischer's avatar
Lukas Fleischer committed
71
		<?php if ($SID && $show_headers): ?>
72
		<td><input type="checkbox" name="IDs[<?= $row["PackageBaseID"] ?>]" value="1" /></td>
73
		<?php endif; ?>
74
		<td><a href="<?= htmlspecialchars(get_pkg_uri($row["Name"]), ENT_QUOTES); ?>"><?= htmlspecialchars($row["Name"]) ?></a></td>
75
		<td<?php if ($row["OutOfDateTS"]): ?> class="flagged"<?php endif; ?>><?= htmlspecialchars($row["Version"]) ?></td>
Lukas Fleischer's avatar
Lukas Fleischer committed
76
		<td><?= $row["NumVotes"] ?></td>
77
		<td><?= number_format($row["Popularity"], 2) ?></td>
78
79
80
		<?php if ($SID): ?>
		<td>
		<?php if (isset($row["Voted"])): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
81
		<?= __("Yes") ?>
82
83
84
85
		<?php endif; ?>
		</td>
		<td>
		<?php if (isset($row["Notify"])): ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
86
		<?= __("Yes") ?>
87
88
89
		<?php endif; ?>
		</td>
		<?php endif; ?>
90
		<td class="wrap"><?= htmlspecialchars($row['Description'], ENT_QUOTES); ?></td>
91
92
		<td>
		<?php if (isset($row["Maintainer"])): ?>
93
94
95
		<?php if ($SID): ?>
		<a href="<?= get_uri('/account/') . htmlspecialchars($row['Maintainer'], ENT_QUOTES) ?>" title="<?= __('View account information for %s', htmlspecialchars($row['Maintainer'])) ?>"><?= htmlspecialchars($row['Maintainer']) ?></a>
		<?php else: ?>
Lukas Fleischer's avatar
Lukas Fleischer committed
96
		<a href="<?= get_uri('/packages/'); ?>?K=<?= htmlspecialchars($row['Maintainer'], ENT_QUOTES) ?>&amp;SeB=m"><?= htmlspecialchars($row['Maintainer']) ?></a>
97
		<?php endif; ?>
98
		<?php else: ?>
99
		<span class="error"><?= __("orphan") ?></span>
100
101
102
		<?php endif; ?>
		</td>
	</tr>
Lukas Fleischer's avatar
Lukas Fleischer committed
103
	<?php endforeach; ?>
104

105
106
		</tbody>
		</table>
107

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
		<?php if ($show_headers): ?>
		<div class="pkglist-stats">
			<p>
				<?= _n('%d package found.', '%d packages found.', $total) ?>
				<?= __('Page %d of %d.', $current, $pages) ?>
			</p>
			<?php if (count($templ_pages) > 1): ?>
			<p class="pkglist-nav">
				<?php foreach ($templ_pages as $pagenr => $pagestart): ?>
					<?php if ($pagestart === false): ?>
						<span class="page"><?= $pagenr ?></span>
					<?php elseif ($pagestart + 1 == $first): ?>
						<span class="page"><?= $pagenr ?></span>
					<?php else: ?>
						<a class="page" href="<?= get_uri('/packages/'); ?>?<?= mkurl('O=' . $pagestart) ?>"><?= $pagenr ?></a>
					<?php endif; ?>
				<?php endforeach; ?>
			</p>
			<?php endif; ?>
		</div>
128

129
130
131
132
133
134
135
		<?php if ($SID): ?>
			<p>
				<select name="action">
					<option><?= __("Actions") ?></option>
					<option value="do_UnFlag"><?= __("Unflag Out-of-date") ?></option>
					<option value="do_Adopt"><?= __("Adopt Packages") ?></option>
					<option value="do_Disown"><?= __("Disown Packages") ?></option>
Lukas Fleischer's avatar
Lukas Fleischer committed
136
					<?php if (has_credential(CRED_PKGBASE_DELETE)): ?>
137
					<option value="do_Delete"><?= __("Delete Packages") ?></option>
138
					<?php endif; ?>
139
140
141
142
143
144
145
146
147
148
149
150
151
152
					<option value="do_Notify"><?= __("Notify") ?></option>
					<option value="do_UnNotify"><?= __("UnNotify") ?></option>
				</select>
				<?php if (has_credential(CRED_PKGBASE_DELETE)): ?>
					<label for="merge_Into"><?= __("Merge into") ?></label>
					<input type="text" id="merge_Into" name="merge_Into" />
				<?php endif; ?>
				<label class="confirmation"><input type="checkbox" name="confirm" value="1" /> <?= __("Confirm") ?></label>
				<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
				<input type="submit" class="button" style="width: 80px" value="<?= __("Go") ?>" />
			</p>
		<?php endif; # if ($SID) ?>
		<?php endif; ?>
	</form>
153
<?php endif; # search was successful and returned multiple results ?>