1 %# $Id: edit.mc,v 1.17 2006-11-16 17:27:15 mike Exp $
6 my $conn = new ZOOM::Connection("localhost:3313/IR-Explain---1", 0,
7 user => "admin", password => "fruitbat",
8 elementSetName => "zeerex");
9 my $rec = '<explain xmlns="http://explain.z3950.org/dtd/2.0/"/>';
10 if (defined $id && $id ne "") {
12 my $query = 'rec.id="' . cql_quote($id) . '"';
13 my $rs = $conn->search(new ZOOM::Query::CQL($query));
18 $rec = $rs->record(0);
23 my $host = $r->param("host");
24 my $port = $r->param("port");
25 my $dbname = $r->param("dbname");
26 if (!defined $host || $host eq "" ||
27 !defined $port || $port eq "" ||
28 !defined $dbname || $dbname eq "") {
29 print qq[<p class="error">You must specify host, port and database name.</p>\n];
30 $r->param(update => 0);
33 my $query = cql_target($host, $port, $dbname);
36 my $xc = irspy_xpath_context($rec);
39 [ protocol => [ qw(Z39.50 SRW SRU SRW/U) ],
40 "Protocol", "e:serverInfo/\@protocol" ],
41 [ host => 0, "Host", "e:serverInfo/e:host" ],
42 [ port => 0, "Port", "e:serverInfo/e:port" ],
43 [ dbname => 0, "Database Name", "e:serverInfo/e:database",
45 [ type => [ qw(Academic Public Corporate Special National Education Other) ],
46 "Type of Library", "i:status/i:libraryType" ],
47 [ country => 0, "Country", "i:status/i:country" ],
48 [ username => 0, "Username (if needed)", "e:serverInfo/e:authentication/e:user",
50 [ password => 0, "Password (if needed)", "e:serverInfo/e:authentication/e:password",
52 [ title => 0, "Title", "e:databaseInfo/e:title",
54 [ description => 5, "Description", "e:databaseInfo/e:description",
56 [ author => 0, "Author", "e:databaseInfo/e:author",
57 qw(e:title e:description) ],
58 [ hosturl => 0, "URL to Hosting Organisation", "i:status/i:hostURL" ],
59 [ contact => 0, "Contact", "e:databaseInfo/e:contact",
60 qw(e:title e:description) ],
61 [ extent => 3, "Extent", "e:databaseInfo/e:extent",
62 qw(e:title e:description) ],
63 [ history => 5, "History", "e:databaseInfo/e:history",
64 qw(e:title e:description) ],
65 [ language => 0, "Language of Records", "e:databaseInfo/e:langUsage",
66 qw(e:title e:description) ],
67 [ restrictions => 2, "Restrictions", "e:databaseInfo/e:restrictions",
68 qw(e:title e:description) ],
69 [ subjects => 2, "Subjects", "e:databaseInfo/e:subjects",
70 qw(e:title e:description) ],
74 my $update = $r->param("update");
76 # Update record with submitted data
77 my %fieldsByKey = map { ( $_->[0], $_) } @fields;
79 foreach my $key ($r->param()) {
80 next if grep { $key eq $_ } qw(id update new copy);
81 $data{$key} = $r->param($key);
84 $nchanges = modify_xml_document($xc, \%fieldsByKey, \%data);
86 ### Set e:metaInfo/e:dateModified
88 ZOOM::IRSpy::_really_rewrite_record($conn, $xc->getContextNode());
91 <h2><% xml_encode($xc->find("e:databaseInfo/e:title"), "[Untitled]") %></h2>
93 <p style="font-weight: bold">
94 The record has been <% $r->param("new") ? "created" : "updated" %>.<br/>
95 Changed <% $nchanges %> field<% $nchanges == 1 ? "" : "s" %>.
98 <form method="get" action="">
99 <table class="fullrecord" border="1" cellspacing="0" cellpadding="5" width="100%">
101 foreach my $ref (@fields) {
102 my($name, $nlines, $caption, $xpath, @addAfter) = @$ref;
105 <th><% $caption %></th>
107 % my $rawdata = $xc->findvalue($xpath);
108 % my $data = xml_encode($rawdata, "");
110 <select name="<% $name %>" size="1">
111 % foreach my $val (@$nlines) {
112 <option value="<% $val %>"
113 % print ' selected="selected"' if $rawdata eq $val;
117 % } elsif ($nlines) {
118 <textarea name="<% $name %>" rows="<% $nlines %>" cols="51"><% $data %></textarea>
120 <input name="<% $name %>" type="text" size="60" value="<% $data %>"/>
126 <td align="right" colspan="2">
127 <input type="submit" name="update" value="Update"/>
129 <input type="hidden" name="id" value="<% xml_encode($id) %>"/>
131 <input type="hidden" name="new" value="1"/>
138 if ($nchanges && 0) {
139 my $x = $xc->getContextNode()->toString();
141 #$x =~ s/$/<br\/>/gm;
142 print "<pre>$x</pre>\n";