[open-ils-commits] r7858 - trunk/Open-ILS/src/perlmods/OpenILS/WWW
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Oct 3 14:20:08 EDT 2007
Author: miker
Date: 2007-10-03 14:09:15 -0400 (Wed, 03 Oct 2007)
New Revision: 7858
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/WWW/Exporter.pm
Log:
add simple form for 1-rec or CSV file input
Modified: trunk/Open-ILS/src/perlmods/OpenILS/WWW/Exporter.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/WWW/Exporter.pm 2007-10-03 17:24:37 UTC (rev 7857)
+++ trunk/Open-ILS/src/perlmods/OpenILS/WWW/Exporter.pm 2007-10-03 18:09:15 UTC (rev 7858)
@@ -13,6 +13,7 @@
use Apache2::RequestUtil;
use CGI;
use Data::Dumper;
+use Text::CSV;
use OpenSRF::EX qw(:try);
use OpenSRF::Utils qw/:datetime/;
@@ -51,16 +52,35 @@
sub handler {
my $r = shift;
my $cgi = new CGI;
-
- my @records = $cgi->param('id');
- my $path_rec = $cgi->path_info();
- if (!@records && $path_rec) {
- @records = map { $_ ? ($_) : () } split '/', $path_rec;
+ # find some IDs ...
+ my @records;
+
+ @records = $cgi->param('id');
+
+ if (!@records) { # try for a file
+ my $file = $cgi->param('idfile');
+ if ($file) {
+ my $col = $cgi->param('idcolumn') || 0;
+ my $csv = new Text::CSV;
+
+ while (<$file>) {
+ $csv->parse($_);
+ my @data = $csv->fields;
+ push @records, $data[$col];
+ }
+ }
}
- return 200 unless (@records);
+ if (!@records) { # try pathinfo
+ my $path_rec = $cgi->path_info();
+ if ($path_rec) {
+ @records = map { $_ ? ($_) : () } split '/', $path_rec;
+ }
+ }
+ return show_template($r) unless (@records);
+
my $type = $cgi->param('rectype') || 'biblio';
if ($type ne 'biblio' && $type ne 'authority') {
die "Bad record type: $type";
@@ -240,4 +260,49 @@
}
+sub show_template {
+ my $r = shift;
+
+ $r->content_type('text/html');
+ $r->print(<<HTML);
+
+<html>
+ <head>
+ <title>Record Export</title>
+ </head>
+ <body>
+ <form method="POST" enctype="multipart/form-data">
+ Use field <input type="text" size="2" maxlength="2" name="idcolumn" value="0"/>
+ from CSV file <input type="file" name="idfile"/>
+ <br/><br/> <b>or</b> <br/><br/>
+ Record ID <input type="text" size="12" maxlength="12" name="id"/>
+ <br/><br/> Record Type:
+ <select name="type">
+ <option value="biblio">Bibliographic Records</option>
+ <option value="authority">Authority Records</option>
+ </select>
+ <br/><br/> Record Fromat:
+ <select name="format">
+ <option value="USMARC"/>
+ <option value="UNIMARC"/>
+ <option value="XML">MARC XML</option>
+ <option value="BRE">Evergreen BRE</option>
+ </select>
+ <br/><br/> Record Encoding:
+ <select name="encoding">
+ <option value="UTF8"/>
+ <option value="MARC8"/>
+ </select>
+ <br/><br/> Include holdings in Bibliographic Records:
+ <input type="checkbox" name="holdings" value="1">
+ <br/><input type="submit" value="Retrieve Records"/>
+ </form>
+ </body>
+</html>
+
+HTML
+
+ return 200;
+}
+
1;
More information about the open-ils-commits
mailing list