Heading is now database title rather than ID
[irspy-moved-to-github.git] / web / htdocs / details / full.mc
1 %# $Id: full.mc,v 1.6 2006-11-06 11:41:03 mike Exp $
2 <%args>
3 $id
4 </%args>
5 <%once>
6 use ZOOM;
7 </%once>
8 <%perl>
9 my $conn = new ZOOM::Connection("localhost:3313/IR-Explain---1");
10 $conn->option(elementSetName => "zeerex");
11 my $qid = $id;
12 $qid =~ s/"/\\"/g;
13 my $query = qq[rec.id="$qid"];
14 my $rs = $conn->search(new ZOOM::Query::CQL($query));
15 my $n = $rs->size();
16 if ($n == 0) {
17     $m->comp("/details/error.mc",
18              title => "Error", message => "No such ID '$id'");
19 } else {
20     my $rec = $rs->record(0);
21     my $xc = irspy_xpath_context($rec);
22     my @fields = (
23                   [ "Last Checked" => "i:status/i:probe[last()]" ],
24                   [ Protocol => "e:serverInfo/\@protocol" ],
25                   [ Host => "e:serverInfo/e:host" ],
26                   [ Port => "e:serverInfo/e:port" ],
27                   [ "Database Name" => "e:serverInfo/e:database" ],
28                   [ "Username (if needed)" =>
29                     "e:serverInfo/e:authentication/e:user" ],
30                   [ "Password (if needed)" =>
31                     "e:serverInfo/e:authentication/e:password" ],
32                   [ Title => "e:databaseInfo/e:title",
33                     lang => "en", primary => "true" ],
34                   [ Description => "e:databaseInfo/e:description",
35                     lang => "en", primary => "true" ],
36                   [ Author => "e:databaseInfo/e:author" ],
37                   [ Contact => "e:databaseInfo/e:contact" ],
38                   [ Extent => "e:databaseInfo/e:extent" ],
39                   [ History => "e:databaseInfo/e:history" ],
40                   [ "Language of Records" => "e:databaseInfo/e:langUsage" ],
41                   [ Restrictions => "e:databaseInfo/e:restrictions" ],
42                   [ Subjects => "e:databaseInfo/e:subjects" ],
43                   [ "Implementation ID" => "i:status/i:implementationId" ],
44                   [ "Implementation Name" => "i:status/i:implementationName" ],
45                   [ "Implementation Version" => "i:status/i:implementationVersion" ],
46                   [ "Reliability" => sub { "### 97%" } ],
47                   [ "Services" => sub { "### search, present, delSet, concurrentOperations, namedResultSets" } ],
48                   [ "Bib-1 Use attributes" => sub { "### 4-5, 7-8, 12, 21, 31, 54, 58, 63, 1003-1005, 1009, 1011-1012, 1016, 1031" } ],
49                   [ "Operators" => sub { "### and, or, not" } ],
50                   [ "Record syntaxes" => sub { "### SUTRS, USmarc, Danmarc" } ],
51                   [ "Explain" => sub { "### CategoryList, TargetInfo, DatabaseInfo, RecordSyntaxInfo, AttributeSetInfo, AttributeDetails" } ],
52                   );
53 </%perl>
54      <h2><% xml_encode($xc->find("e:databaseInfo/e:title")) %></h2>
55      <table class="fullrecord" border="1" cellspacing="0" cellpadding="5" width="100%">
56 <%perl>
57     foreach my $ref (@fields) {
58         my($caption, $xpath, %attrs) = @$ref;
59         my $data;
60         if (ref $xpath && ref($xpath) eq "CODE") {
61             $data = &$xpath();
62         } else {
63             $data = $xc->find($xpath);
64         }
65         if ($data) {
66 </%perl>
67       <tr>
68        <th><% xml_encode($caption) %></th>
69        <td><% xml_encode($data) %></td>
70       </tr>
71 %       }
72 %   }
73      </table>
74 % }