1 %# $Id: found.mc,v 1.27 2007-02-22 11:49:46 mike Exp $
4 my($params, $cond, $caption, $skip) = @_;
7 print(' <a href="', navlink($params, $caption, $skip),
8 '"', ">$caption</a>\n");
10 print qq[ <span class="disabled">$caption</span>\n];
15 my($params, $caption, $skip) = @_;
16 local $params->{_skip} = $skip;
17 my $url = "?" . join("&", map { "$_=" . $params->{$_} } sort keys %$params);
18 $url = xml_encode($url);
22 # Identical to the same-named function in full.mc
23 # So maybe this should go into IRSpy::Utils.pm?
25 sub calc_reliability {
28 my @allpings = $xc->findnodes("i:status/i:probe");
30 return "[untested]" if $nall == 0;
31 my @okpings = $xc->findnodes('i:status/i:probe[@ok = "1"]');
33 return "$nok/$nall = " . int(100*$nok/$nall) . "%";
37 # Just make this once; forge the connection on first use
41 my %params = map { ( $_, $r->param($_)) } grep { $r->param($_) } $r->param();
43 if ($params{_query}) {
44 $query = $params{_query};
47 foreach my $key (keys %params) {
49 my $val = $params{$key};
51 $query .= " and " if $query ne "";
52 $query .= "$key = ($val)";
55 $query = 'cql.allRecords=1' if $query eq "";
57 my $sort = $params{"_sort"};
60 if ($sort =~ s/(\/.*)//) {
63 $query .= " or $sort=/sort";
64 $query .= "-desc" if $params{_desc};
69 my $tried_to_open = 0;
72 $conn = new ZOOM::Connection("localhost:8018/IR-Explain---1");
73 $conn->option(elementSetName => "zeerex");
77 eval { $rs = $conn->search(new ZOOM::Query::CQL($query)) };
78 if ($@ && ref $@ && $@->isa('ZOOM::Exception') &&
79 $@->code() == ZOOM::Error::CONNECTION_LOST && !$tried_to_open) {
88 my $skip = $params{"_skip"} || 0;
89 my $count = $params{"_count"} || 10;
92 my $last = $first+$count-1;
93 $last = $n if $last > $n;
95 <form method="get" action=""><p>
96 <input type="text" name="_query" size="60" value="<% xml_encode($query) %>"/>
97 <input type="submit" name="_search" value="Search"/>
102 % } elsif ($first > $n) {
104 Past end of <% $n %> records
106 Records <% $first %> to <% $last %> of <% $n %><br/>
108 print_navlink(\%params, $skip > 0, "Prev", $count < $skip ? $skip-$count : 0);
109 print_navlink(\%params, $last < $n, "Next", $skip+$count);
113 % if ($n > 0 && $first <= $n) {
126 % foreach my $i ($first .. $last) {
128 my $xc = irspy_xpath_context($rs->record($i-1));
129 my $title = $xc->find("e:databaseInfo/e:title") || "[UNTITLED]";
130 my $reliability = calc_reliability($xc);
131 my $host = $xc->find("e:serverInfo/e:host");
132 my $port = $xc->find("e:serverInfo/e:port");
133 my $db = $xc->find("e:serverInfo/e:database");
134 my $id = $xc->find("concat(e:serverInfo/e:host, ':',
135 e:serverInfo/e:port, '/',
136 e:serverInfo/e:database)");
139 <tr style="background: <% ($i % 2) ? '#ffffc0' : 'white' %>">
141 <td><a href="<% xml_encode("/full.html?id=" . uri_escape($id))
142 %>"><% xml_encode($title) %></a></td>
143 <td><% xml_encode($reliability, "", { nbsp => 1 }) %></td>
144 <td><% xml_encode($host, "") %></td>
145 <td><% xml_encode($port, "") %></td>
146 <td><% xml_encode($db, "") %></td>
148 <a href="<% xml_encode("/admin/check.html?id=" . uri_escape($id))
149 %>" title="Test this target">Test</a
150 > <a href="<% xml_encode("/admin/edit.html?op=edit&id=" .
152 %>" title="Edit this target's record">Edit</a
153 > <a href="<% xml_encode("/raw.html?id=" . uri_escape($id))
154 %>" title="Raw XML record">XML</a>
160 print_navlink(\%params, $skip > 0, "Prev", $count < $skip ? $skip-$count : 0);
161 print_navlink(\%params, $last < $n, "Next", $skip+$count);
164 <a href="<% "/admin/check.html?" .
165 xml_encode(join("&", map { "id=" . uri_escape($_) } @ids))
166 %>">[Test all targets on this list]</a>
169 <a href="<% "/stats.html?query=" . xml_encode(uri_escape($query))
170 %>">[Statistics for targets on this list]</a>