1 %# $Id: edit.mc,v 1.15 2006-11-16 12:26:26 mike Exp $
6 my $conn = new ZOOM::Connection("localhost:3313/IR-Explain---1", 0,
7 user => "admin", password => "fruitbat");
8 my $rec = '<explain xmlns="http://explain.z3950.org/dtd/2.0/"/>';
9 if (defined $id && $id ne "") {
10 $conn->option(elementSetName => "zeerex");
13 my $query = qq[rec.id="$qid"];
14 my $rs = $conn->search(new ZOOM::Query::CQL($query));
19 $rec = $rs->record(0);
23 my $xc = irspy_xpath_context($rec);
26 [ protocol => [ qw(Z39.50 SRW SRU SRW/U) ],
27 "Protocol", "e:serverInfo/\@protocol" ],
28 [ host => 0, "Host", "e:serverInfo/e:host" ],
29 [ port => 0, "Port", "e:serverInfo/e:port" ],
30 [ dbname => 0, "Database Name", "e:serverInfo/e:database",
32 [ type => [ qw(Academic Public Corporate Special National Education Other) ],
33 "Type of Library", "i:status/i:libraryType" ],
34 [ country => 0, "Country", "i:status/i:country" ],
35 [ username => 0, "Username (if needed)", "e:serverInfo/e:authentication/e:user",
37 [ password => 0, "Password (if needed)", "e:serverInfo/e:authentication/e:password",
39 [ title => 0, "Title", "e:databaseInfo/e:title",
41 [ description => 5, "Description", "e:databaseInfo/e:description",
43 [ author => 0, "Author", "e:databaseInfo/e:author",
44 qw(e:title e:description) ],
45 [ hosturl => 0, "URL to Hosting Organisation", "i:status/i:hostURL" ],
46 [ contact => 0, "Contact", "e:databaseInfo/e:contact",
47 qw(e:title e:description) ],
48 [ extent => 3, "Extent", "e:databaseInfo/e:extent",
49 qw(e:title e:description) ],
50 [ history => 5, "History", "e:databaseInfo/e:history",
51 qw(e:title e:description) ],
52 [ language => 0, "Language of Records", "e:databaseInfo/e:langUsage",
53 qw(e:title e:description) ],
54 [ restrictions => 2, "Restrictions", "e:databaseInfo/e:restrictions",
55 qw(e:title e:description) ],
56 [ subjects => 2, "Subjects", "e:databaseInfo/e:subjects",
57 qw(e:title e:description) ],
61 my $update = $r->param("update");
62 if (defined $update) {
63 # Update record with submitted data
64 my %fieldsByKey = map { ( $_->[0], $_) } @fields;
66 foreach my $key ($r->param()) {
67 next if grep { $key eq $_ } qw(id update new copy);
68 $data{$key} = $r->param($key);
71 $nchanges = modify_xml_document($xc, \%fieldsByKey, \%data);
73 ### Set e:metaInfo/e:dateModified
75 ZOOM::IRSpy::_really_rewrite_record($conn, $xc->getContextNode());
78 <h2><% xml_encode($xc->find("e:databaseInfo/e:title"), "[Untitled]") %></h2>
80 <p style="font-weight: bold">
81 The record has been <% $r->param("new") ? "created" : "updated" %>.<br/>
82 Changed <% $nchanges %> field<% $nchanges == 1 ? "" : "s" %>.
85 <form method="get" action="">
86 <table class="fullrecord" border="1" cellspacing="0" cellpadding="5" width="100%">
88 foreach my $ref (@fields) {
89 my($name, $nlines, $caption, $xpath, @addAfter) = @$ref;
92 <th><% $caption %></th>
94 % my $rawdata = $xc->findvalue($xpath);
95 % my $data = xml_encode($rawdata, "");
97 <select name="<% $name %>" size="1">
98 % foreach my $val (@$nlines) {
99 <option value="<% $val %>"
100 % print ' selected="selected"' if $rawdata eq $val;
104 % } elsif ($nlines) {
105 <textarea name="<% $name %>" rows="<% $nlines %>" cols="51"><% $data %></textarea>
107 <input name="<% $name %>" type="text" size="60" value="<% $data %>"/>
113 <td align="right" colspan="2">
114 <input type="submit" name="update" value="Update"/>
116 <input type="hidden" name="id" value="<% xml_encode($id) %>"/>
118 <input type="hidden" name="new" value="1"/>
125 if ($nchanges && 0) {
126 my $x = $xc->getContextNode()->toString();
128 #$x =~ s/$/<br\/>/gm;
129 print "<pre>$x</pre>\n";