%# $Id: found.mc,v 1.5 2006-09-19 16:35:25 mike Exp $ <%once> use XML::LibXML; use XML::LibXML::XPathContext; %once> <%perl> my %params = map { ( $_, $r->param($_)) } $r->param(); my $query = ""; foreach my $key (keys %params) { next if $key =~ /^_/; my $val = $params{$key}; next if $val eq ""; $query .= " and " if $query ne ""; $query .= "$key = ($val)"; } $query = 'cql.allRecords=x' if $query eq ""; my $sort = $params{"_sort"}; if ($sort) { $query .= " or $sort=/sort"; $query .= "-desc" if $params{_desc}; $query .= " 0"; } ### We can think about keeping the Connection object open to re-use # for multiple requests, but that may not get us much. Same applies # for the XML parser. my $conn = new ZOOM::Connection("localhost:1313/IR-Explain---1"); $conn->option(elementSetName => "zeerex"); my $parser = new XML::LibXML(); my $rs = $conn->search(new ZOOM::Query::CQL($query)); my $n = $rs->size(); my $skip = $params{"_skip"} || 0; my $count = $params{"_count"} || 10; my $first = $skip+1; my $last = $first+$count-1; $last = $n if $last > $n; %perl>
% if ($n == 0) {
No matches
% } elsif ($first > $n) {
%# "Can't happen"
Past end of <% $n %> records
% } else {
Records <% $first %> to <% $last %> of <% $n %>
<%perl>
if ($skip > 0) {
$params{_skip} = $count < $skip ? $skip-$count : 0;
my $prev = "?" . join("&", map { "$_=" . $params{$_} } sort keys %params);
print qq[ Prev\n];
} else {
print qq[ Prev\n];
}
if ($last < $n) {
$params{_skip} = $skip+$count;
my $next = "?" . join("&", map { "$_=" . $params{$_} } sort keys %params);
print qq[ Next\n];
} else {
print qq[ Next\n];
}
%perl>
% }
# | Title | Host | Port | DB | ||
---|---|---|---|---|---|---|
<% $i %> | <% $title %> | <% $host %> | <% $port %> | <% $db %> | ">[Check] | ">[Raw] |