1 %# $Id: edit.mc,v 1.9 2006-11-09 16:32:54 mike Exp $
9 my $conn = new ZOOM::Connection("localhost:3313/IR-Explain---1", 0,
10 user => "admin", password => "fruitbat");
11 $conn->option(elementSetName => "zeerex");
14 my $query = qq[rec.id="$qid"];
15 my $rs = $conn->search(new ZOOM::Query::CQL($query));
18 $m->comp("/details/error.mc",
19 title => "Error", message => "No such ID '$id'");
21 my $rec = $rs->record(0);
22 my $xc = irspy_xpath_context($rec);
25 [ protocol => 0, "Protocol", "e:serverInfo/\@protocol" ],
26 [ host => 0, "Host", "e:serverInfo/e:host" ],
27 [ port => 0, "Port", "e:serverInfo/e:port" ],
28 [ dbname => 0, "Database Name", "e:serverInfo/e:database",
30 [ username => 0, "Username (if needed)", "e:serverInfo/e:authentication/e:user",
32 [ password => 0, "Password (if needed)", "e:serverInfo/e:authentication/e:password",
34 [ title => 0, "title", "e:databaseInfo/e:title",
36 [ description => 5, "Description", "e:databaseInfo/e:description",
38 [ author => 0, "Author", "e:databaseInfo/e:author",
39 qw(e:title e:description) ],
40 [ contact => 0, "Contact", "e:databaseInfo/e:contact",
41 qw(e:title e:description) ],
42 [ extent => 3, "Extent", "e:databaseInfo/e:extent",
43 qw(e:title e:description) ],
44 [ history => 5, "History", "e:databaseInfo/e:history",
45 qw(e:title e:description) ],
46 [ language => 0, "Language of Records", "e:databaseInfo/e:langUsage",
47 qw(e:title e:description) ],
48 [ restrictions => 2, "Restrictions", "e:databaseInfo/e:restrictions",
49 qw(e:title e:description) ],
50 [ subjects => 2, "Subjects", "e:databaseInfo/e:subjects",
51 qw(e:title e:description) ],
55 my $update = $r->param("update");
56 if (defined $update) {
57 # Update record with submitted data
58 my %fieldsByKey = map { ( $_->[0], $_) } @fields;
60 foreach my $key ($r->param()) {
61 next if grep { $key eq $_ } qw(id update);
62 $data{$key} = $r->param($key);
65 $nchanges = modify_xml_document($xc, \%fieldsByKey, \%data);
67 ### Set e:metaInfo/e:dateModified
69 ZOOM::IRSpy::_really_rewrite_record($conn, $xc->getContextNode());
72 <h2><% xml_encode($xc->find("e:databaseInfo/e:title")) %></h2>
74 <p style="font-weight: bold">
75 The record has been updated.<br/>
76 Changed <% $nchanges %> field<% $nchanges == 1 ? "" : "s" %>.
79 <form method="get" action="">
80 <table class="fullrecord" border="1" cellspacing="0" cellpadding="5" width="100%">
82 foreach my $ref (@fields) {
83 my($name, $nlines, $caption, $xpath, @addAfter) = @$ref;
86 <th><% $caption %></th>
88 % my $data = xml_encode($xc->find($xpath));
90 <textarea name="<% $name %>" rows="<% $nlines %>" cols="61"><% $data %></textarea>
92 <input name="<% $name %>" type="text" size="60" value="<% $data %>">
98 <td align="right" colspan="2">
99 <input type="submit" name="update" value="Update"/>
100 <input type="hidden" name="id" value="<% xml_encode($id) %>"/>
106 if ($nchanges && 0) {
107 my $x = $xc->getContextNode()->toString();
109 #$x =~ s/$/<br\/>/gm;
110 print "<pre>$x</pre>\n";