1 %# $Id: edit.mc,v 1.6 2006-11-01 10:00:21 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($id) %></h2>
73 % if (defined $update) {
74 <p><b>The record has been updated (nchanges=<% $nchanges %>).</b></p>
77 <p><b>Changed <% $nchanges %> element<% $nchanges == 1 ? "" : "s" %>.</b></p>
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) %>"/>