1 %# $Id: found.mc,v 1.6 2006-09-20 11:25:42 mike Exp $
4 use XML::LibXML::XPathContext;
7 my %params = map { ( $_, $r->param($_)) } grep { $r->param($_) } $r->param();
9 foreach my $key (keys %params) {
11 my $val = $params{$key};
13 $query .= " and " if $query ne "";
14 $query .= "$key = ($val)";
16 $query = 'cql.allRecords=x' if $query eq "";
18 my $sort = $params{"_sort"};
21 if ($sort =~ s/(\/.*)//) {
24 $query .= " or $sort=/sort";
25 $query .= "-desc" if $params{_desc};
30 ### We can think about keeping the Connection object open to re-use
31 # for multiple requests, but that may not get us much. Same applies
33 my $conn = new ZOOM::Connection("localhost:1313/IR-Explain---1");
34 $conn->option(elementSetName => "zeerex");
35 my $parser = new XML::LibXML();
37 my $rs = $conn->search(new ZOOM::Query::CQL($query));
40 my $skip = $params{"_skip"} || 0;
41 my $count = $params{"_count"} || 10;
44 my $last = $first+$count-1;
45 $last = $n if $last > $n;
51 % } elsif ($first > $n) {
53 Past end of <% $n %> records
55 Records <% $first %> to <% $last %> of <% $n %><br/>
58 $params{_skip} = $count < $skip ? $skip-$count : 0;
59 my $prev = "?" . join("&", map { "$_=" . $params{$_} } sort keys %params);
60 print qq[ <a href="$prev">Prev</a>\n];
62 print qq[ <span class="disabled">Prev</span>\n];
65 $params{_skip} = $skip+$count;
66 my $next = "?" . join("&", map { "$_=" . $params{$_} } sort keys %params);
67 print qq[ <a href="$next">Next</a>\n];
69 print qq[ <span class="disabled">Next</span>\n];
74 % if ($n > 0 && $first <= $n) {
86 % foreach my $i ($first .. $last) {
88 my $rec = $rs->record($i-1);
89 my $xml = $rec->render();
90 my $doc = $parser->parse_string($xml);
91 my $root = $doc->getDocumentElement();
92 my $xc = XML::LibXML::XPathContext->new($root);
93 $xc->registerNs(e => 'http://explain.z3950.org/dtd/2.0/');
94 my $title = $xc->find("e:databaseInfo/e:title");
95 my $author = $xc->find("e:databaseInfo/e:author");
96 my $host = $xc->find("e:serverInfo/e:host");
97 my $port = $xc->find("e:serverInfo/e:port");
98 my $db = $xc->find("e:serverInfo/e:database");
99 my $id = $xc->find("concat(e:serverInfo/e:host, ':',
100 e:serverInfo/e:port, '/',
101 e:serverInfo/e:database)");
103 <tr style="background: <% ($i % 2) ? '#ffffc0' : 'white' %>">
105 <td><% $title %></td>
106 <td><% $author %></td>
110 <td><a href="<% "/check.html?id=$id" %>">[Check]</a></td>
111 <td><a href="<% "/raw.html?id=$id" %>">[Raw]</a></td>