1 %# $Id: found.mc,v 1.12 2006-10-17 14:49:58 mike Exp $
4 use XML::LibXML::XPathContext;
8 my($params, $cond, $caption, $skip) = @_;
11 print(' <a href="', navlink($params, $caption, $skip),
12 '"', ">$caption</a>\n");
14 print qq[ <span class="disabled">$caption</span>\n];
19 my($params, $caption, $skip) = @_;
20 local $params->{_skip} = $skip;
21 my $url = "?" . join("&", map { "$_=" . $params->{$_} } sort keys %$params);
22 $url = xml_encode($url);
26 # Just make this once; forge the connection on first use
30 my %params = map { ( $_, $r->param($_)) } grep { $r->param($_) } $r->param();
32 foreach my $key (keys %params) {
34 my $val = $params{$key};
36 $query .= " and " if $query ne "";
37 $query .= "$key = ($val)";
39 $query = 'cql.allRecords=x' if $query eq "";
41 my $sort = $params{"_sort"};
44 if ($sort =~ s/(\/.*)//) {
47 $query .= " or $sort=/sort";
48 $query .= "-desc" if $params{_desc};
54 $conn = new ZOOM::Connection("localhost:3313/IR-Explain---1");
56 $conn->option(elementSetName => "zeerex");
57 my $parser = new XML::LibXML();
59 my $rs = $conn->search(new ZOOM::Query::CQL($query));
62 my $skip = $params{"_skip"} || 0;
63 my $count = $params{"_count"} || 10;
66 my $last = $first+$count-1;
67 $last = $n if $last > $n;
69 <h2><% xml_encode($query) %></h2>
73 % } elsif ($first > $n) {
75 Past end of <% $n %> records
77 Records <% $first %> to <% $last %> of <% $n %><br/>
79 print_navlink(\%params, $skip > 0, "Prev", $count < $skip ? $skip-$count : 0);
80 print_navlink(\%params, $last < $n, "Next", $skip+$count);
84 % if ($n > 0 && $first <= $n) {
97 % foreach my $i ($first .. $last) {
99 my $rec = $rs->record($i-1);
100 my $xml = $rec->render();
101 my $doc = $parser->parse_string($xml);
102 my $root = $doc->getDocumentElement();
103 my $xc = XML::LibXML::XPathContext->new($root);
104 $xc->registerNs(e => 'http://explain.z3950.org/dtd/2.0/');
105 my $title = $xc->find("e:databaseInfo/e:title");
106 my $author = $xc->find("e:databaseInfo/e:author");
107 my $host = $xc->find("e:serverInfo/e:host");
108 my $port = $xc->find("e:serverInfo/e:port");
109 my $db = $xc->find("e:serverInfo/e:database");
110 my $id = $xc->find("concat(e:serverInfo/e:host, ':',
111 e:serverInfo/e:port, '/',
112 e:serverInfo/e:database)");
115 <tr style="background: <% ($i % 2) ? '#ffffc0' : 'white' %>">
117 <td><% xml_encode($title) %></td>
118 <td><% xml_encode($author) %></td>
119 <td><% xml_encode($host) %></td>
120 <td><% xml_encode($port) %></td>
121 <td><% xml_encode($db) %></td>
122 <td><a href="<% xml_encode("/check.html?id=" . uri_escape($id))
124 <td><a href="<% xml_encode("/raw.html?id=" . uri_escape($id))
130 print_navlink(\%params, $skip > 0, "Prev", $count < $skip ? $skip-$count : 0);
131 print_navlink(\%params, $last < $n, "Next", $skip+$count);
134 <a href="<% "/check.html?" .
135 xml_encode(join("&", map { "id=" . uri_escape($_) } @ids))
136 %>">[Test all targets on this list]</a>