Add link to upload a new target.
[irspy-moved-to-github.git] / web / htdocs / chrome / layout.mc
index 6b9ec12..dad8463 100644 (file)
@@ -1,15 +1,17 @@
-%# $Id: layout.mc,v 1.25 2007-03-29 11:20:56 mike Exp $
+%# $Id: layout.mc,v 1.35 2007-06-28 13:36:46 mike Exp $
 <%args>
 $debug => undef
 $title
 $component
 </%args>
 <%once>
-use URI::Escape;
+use URI::Escape qw(uri_escape uri_escape_utf8);
 use ZOOM;
 use ZOOM::IRSpy::Web;
-use ZOOM::IRSpy::Utils qw(isodate xml_encode cql_target
-                          irspy_xpath_context modify_xml_document
+use ZOOM::IRSpy::Utils qw(utf8param isodate xml_encode cql_target cql_quote
+                          irspy_xpath_context irspy_make_identifier
+                         irspy_record2identifier
+                         irspy_identifier2target modify_xml_document
                          bib1_access_point);
 </%once>
 % $r->content_type("text/html; charset=utf-8");
@@ -25,13 +27,19 @@ use ZOOM::IRSpy::Utils qw(isodate xml_encode cql_target
  <body>
   <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr class="banner">
-    <td align="left">
-     <br/>
-     <h1><a class="logo" href="/">IRSpy</a></h1>
-    </td>
-    <td align="right">
-     <br/>
-     <h1 class="title"><% xml_encode($title) %></h1>
+    <td>
+     <table width="100%">
+      <tr>
+       <td align="left">
+       <br/>
+       <h1><a class="logo" href="/">IRSpy</a></h1>
+       </td>
+       <td align="right">
+       <br/>
+       <h1 class="title"><% xml_encode($title) %></h1>
+       </td>
+      </tr>
+     </table>
     </td>
    </tr>
   </table>
@@ -58,6 +66,7 @@ use ZOOM::IRSpy::Utils qw(isodate xml_encode cql_target
       <a href="/admin/all.html">Test&nbsp;all&nbsp;targets</a><br/>
       <a href="/find.html">Find a target</a><br/>
       <a href="/admin/edit.html?op=new">Add a target</a><br/>
+      <a href="/admin/upload.html">Upload a target</a><br/>
       <a href="/stats.html">Statistics</a><br/>
      </p>
      <p>
@@ -66,29 +75,30 @@ use ZOOM::IRSpy::Utils qw(isodate xml_encode cql_target
 % foreach my $i ('a' .. 'z') {
       <a href="/find.html?dc.title=^<% $i %>*&amp;_sort=dc.title&amp;_count=9999&amp;_search=Search"><tt><% uc($i) %></tt></a>
 % }
-      <a href="/find.html?cql.allRecords=1+not+dc.title+=/regexp/firstInField+[a-z].*&amp;_sort=dc.title&amp;_count=9999&amp;_search=Search"">[Others]</a>
+      <a href="/find.html?cql.allRecords=1+not+dc.title+=/regexp/firstInField+[a-z].*&amp;_sort=dc.title&amp;_count=9999&amp;_search=Search">[Others]</a>
      </p>
 <%perl>
-my $id = $r->param("id");
+# Find the identifier to use in the record-specific menu, if any.  If
+# the identifier components are all present (e.g. because a record has
+# just been edited or copied) we make an ID from those; otherwise we
+# use the "id" parameter, if specified.
+my $id = utf8param($r, "id");
 {
-    # Make up ID for newly created records.  It would be more
-    # rigorously correct, but insanely inefficient, to submit the
-    # record to Zebra and then search for it; but since we know the
-    # formula for IDs anyway, we just build one by hand.
-    my $id = $r->param("id");
-    my $host = $r->param("host");
-    my $port = $r->param("port");
-    my $dbname = $r->param("dbname");
-    #warn "id='$id', host='$host', port='$port', dbname='$dbname'";
+    # Make up ID for newly created records.
+    my $protocol = utf8param($r, "protocol");
+    my $host = utf8param($r, "host");
+    my $port = utf8param($r, "port");
+    my $dbname = utf8param($r, "dbname");
+    #warn "id='$id', protocol='$protocol' host='$host', port='$port', dbname='$dbname'";
     #warn "%ARGS = {\n" . join("", map { "\t'$_' => '" . $ARGS{$_} . ",'\n" } sort keys %ARGS) . "}\n";
-    if ((!defined $id || $id eq "") &&
-       defined $host && defined $port && defined $dbname) {
-       $id = "$host:$port/$dbname";
+    if (defined $protocol && defined $host &&
+       defined $port && defined $dbname) {
+       $id = irspy_make_identifier($protocol, $host, $port, $dbname);
        #warn "id set to '$id'";
     }
 }
 </%perl>
-% if (defined $id && $r->param("op") ne "copy") {
+% if (defined $id) {
      <div class="panel2">
       <b>This Target</b>
       <br/>