-%# $Id: found.mc,v 1.6 2006-09-20 11:25:42 mike Exp $
+%# $Id: found.mc,v 1.11 2006-09-25 16:52:30 mike Exp $
<%once>
use XML::LibXML;
use XML::LibXML::XPathContext;
+use URI::Escape;
+
+sub print_navlink {
+ my($params, $cond, $caption, $skip) = @_;
+
+ if ($cond) {
+ print(' <a href="', navlink($params, $caption, $skip),
+ '"', ">$caption</a>\n");
+ } else {
+ print qq[ <span class="disabled">$caption</span>\n];
+ }
+}
+
+sub navlink {
+ my($params, $caption, $skip) = @_;
+ local $params->{_skip} = $skip;
+ my $url = "?" . join("&", map { "$_=" . $params->{$_} } sort keys %$params);
+ $url = xml_encode($url);
+ return $url;
+}
+
</%once>
<%perl>
my %params = map { ( $_, $r->param($_)) } grep { $r->param($_) } $r->param();
### 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");
+my $conn = new ZOOM::Connection("localhost:3313/IR-Explain---1");
$conn->option(elementSetName => "zeerex");
my $parser = new XML::LibXML();
my $last = $first+$count-1;
$last = $n if $last > $n;
</%perl>
- <h2><% $query %></h2>
+ <h2><% xml_encode($query) %></h2>
<p>
% if ($n == 0) {
No matches
% } else {
Records <% $first %> to <% $last %> of <% $n %><br/>
<%perl>
-if ($skip > 0) {
- $params{_skip} = $count < $skip ? $skip-$count : 0;
- my $prev = "?" . join("&", map { "$_=" . $params{$_} } sort keys %params);
- print qq[ <a href="$prev">Prev</a>\n];
-} else {
- print qq[ <span class="disabled">Prev</span>\n];
-}
-if ($last < $n) {
- $params{_skip} = $skip+$count;
- my $next = "?" . join("&", map { "$_=" . $params{$_} } sort keys %params);
- print qq[ <a href="$next">Next</a>\n];
-} else {
- print qq[ <span class="disabled">Next</span>\n];
-}
+print_navlink(\%params, $skip > 0, "Prev", $count < $skip ? $skip-$count : 0);
+print_navlink(\%params, $last < $n, "Next", $skip+$count);
</%perl>
% }
</p>
<th></th>
<th></th>
</tr>
+% my @ids;
% foreach my $i ($first .. $last) {
<%perl>
my $rec = $rs->record($i-1);
my $id = $xc->find("concat(e:serverInfo/e:host, ':',
e:serverInfo/e:port, '/',
e:serverInfo/e:database)");
+push @ids, $id;
</%perl>
<tr style="background: <% ($i % 2) ? '#ffffc0' : 'white' %>">
<td><% $i %></td>
- <td><% $title %></td>
- <td><% $author %></td>
- <td><% $host %></td>
- <td><% $port %></td>
- <td><% $db %></td>
- <td><a href="<% "/check.html?id=$id" %>">[Check]</a></td>
- <td><a href="<% "/raw.html?id=$id" %>">[Raw]</a></td>
+ <td><% xml_encode($title) %></td>
+ <td><% xml_encode($author) %></td>
+ <td><% xml_encode($host) %></td>
+ <td><% xml_encode($port) %></td>
+ <td><% xml_encode($db) %></td>
+ <td><a href="<% xml_encode("/check.html?id=" . uri_escape($id))
+ %>">[Test]</a></td>
+ <td><a href="<% xml_encode("/raw.html?id=" . uri_escape($id))
+ %>">[Raw]</a></td>
</tr>
-%}
+% }
</table>
+<%perl>
+print_navlink(\%params, $skip > 0, "Prev", $count < $skip ? $skip-$count : 0);
+print_navlink(\%params, $last < $n, "Next", $skip+$count);
+</%perl>
+ <p>
+ <a href="<% "/check.html?" .
+ xml_encode(join("&", map { "id=" . uri_escape($_) } @ids))
+ %>">[Test all targets on this list]</a>
+ </p>
% }