Commit b4a62c49 authored by Callan Barrett's avatar Callan Barrett Committed by Loui Chang
Browse files

Move package search results to a template



Logic is separated from html as much as possible, all html in a template
Signed-off-by: default avatarCallan Barrett <wizzomafizzo@gmail.com>
Signed-off-by: default avatarLoui Chang <louipc.ist@gmail.com>
parent 6415b65a
...@@ -767,219 +767,26 @@ function pkg_search_page($SID="") { ...@@ -767,219 +767,26 @@ function pkg_search_page($SID="") {
$result = db_query($q, $dbh); $result = db_query($q, $dbh);
$total = mysql_result(db_query('SELECT FOUND_ROWS() AS Total', $dbh), 0); $total = mysql_result(db_query('SELECT FOUND_ROWS() AS Total', $dbh), 0);
print "<form action='packages.php?".$_SERVER['QUERY_STRING']."' method='post'>\n"; if ($result && $total > 0) {
print "<center>\n"; if ($_REQUEST["SO"] == "d"){
print "<table cellspacing='3' class='boxSoft'>\n"; $SO_next="a";
print "<tr>\n"; $SO = 'd';
print " <td class='boxSoftTitle' align='right'>\n"; } else {
print " <span class='f3'>".__("Package Listing")."</span>\n"; $SO_next="d";
print " </td>\n"; $SO = 'a';
print "</tr>\n"; }
print "<tr>\n"; }
print " <td class='boxSoft'>\n";
print "<table width='100%' cellspacing='0' cellpadding='2'>\n";
if (!$result) {
print "<div class='pgboxbody'>";
print __("Error retrieving package list.");
print "</div>";
} elseif ($total == 0) {
print "<div class='pgboxbody'>";
print __("No packages matched your search criteria.");
print "</div>";
} else {
// print out package search results
//
// SO_next used to change sort order on header click
if ($_REQUEST["SO"] == "d"){
$SO_next="a";
$SO = 'd';
} else {
$SO_next="d";
$SO = 'a';
}
print "<tr>\n";
if ($SID) {
print " <th style='border-bottom: #666 1px solid; vertical-align:";
print " bottom'>&nbsp;</th>\n";
}
print " <th style='border-bottom: #666 1px solid; vertical-align:";
print " bottom'><span class='f2'>";
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=l&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Location")."</a>";
print "</span></th>\n";
print " <th style='border-bottom: #666 1px solid; vertical-align:";
print " bottom'><span class='f2'>";
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=c&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Category")."</a>";
print "</span></th>\n";
print " <th style='border-bottom: #666 1px solid; vertical-align:";
print " bottom'><span class='f2'>";
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=n&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Name")."</a>";
print "</span></th>\n";
print " <th style='border-bottom: #666 1px solid; vertical-align:";
print " bottom'><span class='f2'>";
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=v&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Votes")."</a>";
print "</span></th>\n";
if ($SID) {
print " <th style='border-bottom: #666 1px solid; vertical-align:";
print " bottom'><span class='f2'>".__("Voted")."</span></th>\n";
}
if ($SID) {
print " <th style='border-bottom: #666 1px solid; vertical-align:";
print " bottom'><span class='f2'>".__("Notify")."</span></th>\n";
}
print " <th style='border-bottom: #666 1px solid; vertical-align:";
print " bottom'><span class='f2'>".__("Description")."</a>";
print "</span></th>\n";
print " <th style='border-bottom: #666 1px solid; vertical-align:";
print " bottom'><span class='f2'>";
print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=m&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Maintainer")."</a>";
print "</span></th>\n";
print "</tr>\n";
for ($i=0; $row = mysql_fetch_assoc($result); $i++) {
(($i % 2) == 0) ? $c = "data1" : $c = "data2";
print "<tr>\n";
if ($SID) {
if ($row["OutOfDate"]) {
$c = "outofdate";
}
print " <td class='".$c."'>";
print "<input type='checkbox' name='IDs[".$row["ID"]."]' value='1'>";
if ($row["OutOfDate"]) {
print "</span>";
}
print "</td>\n";
}
print " <td class='".$c."'><span class='f5'><span class='blue'>";
print $row["Location"]."</span></span></td>\n";
print " <td class='".$c."'><span class='f5'><span class='blue'>";
print $row["Category"]."</span></span></td>\n";
print " <td class='".$c."'><span class='f4'>";
$url = "<a href='packages.php?";
$url .= "ID=";
$url .= $row["ID"];
$url.= "'>";
$url.="<span class='black'>";
$url.=$row["Name"];
$url.= " ".$row["Version"]."</span></a>";
print $url."</span></td>\n";
print " <td class='".$c."'><span class='f5'><span class='blue'>";
print "&nbsp;&nbsp;&nbsp;".$row["NumVotes"]."</span></span></td>\n";
if ($SID) {
print " <td class='".$c."'><span class='f5'><span class='blue'>";
if (isset($row["Voted"])) {
print "&nbsp;&nbsp;".__("Yes")."</span></td>\n";
} else {
print "&nbsp;</span></td>\n";
}
print " <td class='".$c."'><span class='f5'><span class='blue'>";
if (isset($row["Notify"])) {
print "&nbsp;&nbsp;".__("Yes")."</span></td>\n";
} else {
print "&nbsp;</span></td>\n";
}
}
print " <td class='".$c."'><span class='f4'><span class='blue'>";
print $row["Description"]."</span></span></td>\n";
print " <td class='".$c."'><span class='f5'><span class='blue'>";
if (isset($row["Maintainer"])) {
print "<a href='packages.php?K=".$row['Maintainer']."&SeB=m'>".$row['Maintainer']."</a>";
} else {
print "<span style='color: blue; font-style: italic;'>";
print __("orphan");
print "</span>";
}
print "</span></span></td>\n";
print "</tr>\n";
}
print "</table>\n";
print " </td>\n";
print "</tr>\n";
print "</table>\n";
if ($SID) {
// The 'Actions' box
//
print "<div style='text-align: right; padding: 5px 5% 5px 0'>";
print "<select name='action'>";
print "<option>" . __("Actions") . "</option>";
print "<option value='do_Flag'>".__("Flag Out-of-date")."</option>\n";
print "<option value='do_UnFlag'>".__("Unflag Out-of-date")."</option>\n";
print "<option value='do_Adopt'>".__("Adopt Packages")."</option>\n";
print "<option value='do_Disown'>".__("Disown Packages")."</option>\n";
if (account_from_sid($SID) == "Trusted User" || account_from_sid($SID) == "Developer") {
print "<option value='do_Delete'>".__("Delete Packages")."</option>\n";
}
print "<option value='do_Notify'>".__("Notify")."</option>\n";
print "<option value='do_UnNotify'>".__("UnNotify")."</option>\n";
print "</select>";
print "<input type='submit' class='button' style='width: 80px' value='" . __("Go") . "' />";
print "</div>";
}
print "<table width='90%' cellspacing='0' cellpadding='2'>\n";
print "<tr>\n";
print " <td>\n";
print " <table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";
print " <tr>\n";
// figure out the results to use
$first = $O + 1;
if (($PP+$O) > $total) { // figure out the results to use
$last = $total; $first = $O + 1;
} else {
$last = $PP + $O;
}
// print number of results if (($PP+$O) > $total) {
// ok this styling sucks $last = $total;
// patches welcome! } else {
print "<tr><td align='center' colspan='0'><span class='f4'><span class='blue'>"; $last = $PP + $O;
print __("Showing results %s - %s of %s", array($first, $last, $total));
print "</span></span></td></tr>";
// first print the legend
print " <td colspan='2' align='center'>";
print " <span class='f5'>\n";
if ($SID) {
print ' <span class="outofdate">'.__("Out of Date").' </span>'."&nbsp;&nbsp;&nbsp;&nbsp;";
}
print " </span></td>\n";
print " </tr>";
// now print the forward and back buttons on the bottom
// LEFT
print " <tr>";
print " <td align='left'>";
if (($O-$PP) >= 0) {
print "<a href='packages.php?O=" . ($O - $PP) . "&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=$SB&SO=$SO&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]. "'>" . __("Less") . "</a>";
} else if ($O<$PP && $O>0) {
print "<a href='packages.php?O=0&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=$SB&SO=$SO&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]. "'>" . __("Less") . "</a>";
}
print " </td>";
// RIGHT
print " <td align='right'>";
if ($total - $PP - $O > 0) {
print "<a href='packages.php?O=" . ($O + $PP) .
"&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"]) .
"&K=$K&SB=$SB&SO=$SO&PP=$PP&SeB=".$_REQUEST["SeB"] .
"&do_Orphans=".$_REQUEST["do_Orphans"]."'>" .
__("More") . "</a>";
}
print " </td>\n";
print " </tr>\n";
} }
print " </table>\n";
print " </td>\n"; include('pkg_search_results.php');
print "</tr>\n";
print "</table>\n";
print "</center>\n";
print "</form>\n";
return; return;
} }
......
<form action='packages.php?<?php print $_SERVER['QUERY_STRING'] ?>' method='post'>
<center>
<table cellspacing='3' class='boxSoft'>
<tr>
<td class='boxSoftTitle' align='right'>
<span class='f3'><?php print __("Package Listing") ?></span>
</td>
</tr>
<tr>
<td class='boxSoft'>
<table width='100%' cellspacing='0' cellpadding='2'>
<?php if (!$result) { ?>
<div class='pgboxbody'><?php print __("Error retrieving package list.") ?></div>
<?php } elseif ($total == 0) { ?>
<div class='pgboxbody'><?php print __("No packages matched your search criteria.") ?></div>
<?php } else { ?>
<tr>
<?php if ($SID): ?>
<th style='border-bottom: #666 1px solid; vertical-align: bottom'>&nbsp;</th>
<?php endif; ?>
<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'>
<?php print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=l&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Location")."</a>"; ?>
</span></th>
<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'>
<?php print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=c&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Category")."</a>"; ?>
</span></th>
<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'>
<?php print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=n&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Name")."</a>"; ?>
</span></th>
<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'>
<?php print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=v&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Votes")."</a>"; ?>
</span></th>
<?php if ($SID): ?>
<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Voted") ?></span></th>
<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Notify") ?></span></th>
<?php endif; ?>
<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Description") ?></a></span></th>
<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'>
<?php print "<a href='?O=$O&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=m&SO=$SO_next&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]."'>".__("Maintainer")."</a>"; ?>
</span></th>
</tr>
<?php for ($i=0; $row = mysql_fetch_assoc($result); $i++) { (($i % 2) == 0) ? $c = "data1" : $c = "data2"; ?>
<tr>
<?php if ($SID): if ($row["OutOfDate"]): $c = "outofdate"; endif; ?>
<td class='<?php print $c ?>'><input type='checkbox' name='IDs[<?php print $row["ID"] ?>]' value='1'></td>
<?php endif; ?>
<td class='<?php print $c ?>'><span class='f5'><span class='blue'><?php print $row["Location"] ?></span></span></td>
<td class='<?php print $c ?>'><span class='f5'><span class='blue'><?php print $row["Category"] ?></span></span></td>
<td class='<?php print $c ?>'><span class='f4'><a href='packages.php?ID=<?php print $row["ID"] ?>'><span class='black'><?php print $row["Name"] ?> <?php print $row["Version"] ?></span></a></span></td>
<td class='<?php print $c ?>'><span class='f5'><span class='blue'>&nbsp;&nbsp;&nbsp;<?php print $row["NumVotes"] ?></span></span></td>
<?php if ($SID): ?>
<td class='<?php print $c ?>'><span class='f5'><span class='blue'>
<?php if (isset($row["Voted"])): ?>
&nbsp;&nbsp;<?php print __("Yes") ?></span></td>
<?php else: ?>
&nbsp;</span></td>
<?php endif; ?>
<td class='<?php print $c ?>'><span class='f5'><span class='blue'>
<?php if (isset($row["Notify"])): ?>
&nbsp;&nbsp;<?php print __("Yes") ?></span></td>
<?php else: ?>
&nbsp;</span></td>
<?php endif; ?>
<?php endif; ?>
<td class='<?php print $c ?>'><span class='f4'><span class='blue'>
<?php print $row["Description"] ?></span></span></td>
<td class='<?php print $c ?>'><span class='f5'><span class='blue'>
<?php if (isset($row["Maintainer"])): ?>
<a href='packages.php?K=<?php print $row['Maintainer'] ?>&amp;SeB=m'><?php print $row['Maintainer'] ?></a>
<?php else: ?>
<span style='color: blue; font-style: italic;'><?php print __("orphan") ?></span>
<?php endif; ?>
</span></span></td>
</tr>
<?php } ?>
</table>
</td>
</tr>
</table>
<?php if ($SID): ?>
<div style='text-align: right; padding: 5px 5% 5px 0'>
<select name='action'>
<option><?php print __("Actions") ?></option>
<option value='do_Flag'><?php print __("Flag Out-of-date") ?></option>
<option value='do_UnFlag'><?php print __("Unflag Out-of-date") ?></option>
<option value='do_Adopt'><?php print __("Adopt Packages") ?></option>
<option value='do_Disown'><?php print __("Disown Packages") ?></option>
<?php if (account_from_sid($SID) == "Trusted User" || account_from_sid($SID) == "Developer"): ?>
<option value='do_Delete'><?php print __("Delete Packages") ?></option>
<?php endif; ?>
<option value='do_Notify'><?php print __("Notify") ?></option>
<option value='do_UnNotify'><?php print __("UnNotify") ?></option>
</select>
<input type='submit' class='button' style='width: 80px' value='<?php print __("Go") ?>' />
</div>
<?php endif; ?>
<table width='90%' cellspacing='0' cellpadding='2'>
<tr>
<td>
<table border='0' cellpadding='0' cellspacing='0' width='100%'>
<tr>
<tr><td align='center' colspan='0'><span class='f4'><span class='blue'>
<?php print __("Showing results %s - %s of %s", $first, $last, $total) ?>
</span></span></td></tr>
<td colspan='2' align='center'>
<span class='f5'>
<?php if ($SID): ?>
<span class="outofdate"><?php print __("Out of Date") ?></span>&nbsp;&nbsp;&nbsp;&nbsp;
<?php endif; ?>
</span></td>
</tr>
<tr>
<td align='left'>
<?php if (($O-$PP) >= 0): ?>
<?php print "<a href='packages.php?O=" . ($O - $PP) . "&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=$SB&SO=$SO&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]. "'>" . __("Less") . "</a>" ?>
<?php elseif ($O<$PP && $O>0): ?>
<?php print "<a href='packages.php?O=0&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"])."&K=$K&SB=$SB&SO=$SO&PP=$PP&SeB=".$_REQUEST["SeB"]."&do_Orphans=".$_REQUEST["do_Orphans"]. "'>" . __("Less") . "</a>" ?>
<?php endif; ?>
</td>
<td align='right'>
<?php if ($total - $PP - $O > 0): ?>
<?php print "<a href='packages.php?O=" . ($O + $PP) . "&L=".intval($_REQUEST["L"])."&C=".intval($_REQUEST["C"]) . "&K=$K&SB=$SB&SO=$SO&PP=$PP&SeB=".$_REQUEST["SeB"] . "&do_Orphans=".$_REQUEST["do_Orphans"]."'>" . __("More") . "</a>" ?>
<?php endif; ?>
</td>
</tr>
<?php } ?>
</table>
</td>
</tr>
</table>
</center>
</form>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment