From 62aa26fc2157ca107108dad32d75fc8d45feadfd Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 3 Oct 2007 18:09:15 +0000 Subject: [PATCH] add simple form for 1-rec or CSV file input git-svn-id: svn://svn.open-ils.org/ILS/trunk@7858 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/WWW/Exporter.pm | 77 ++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/Exporter.pm b/Open-ILS/src/perlmods/OpenILS/WWW/Exporter.pm index a7e612a419..80e7f41ede 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/Exporter.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/Exporter.pm @@ -13,6 +13,7 @@ use Apache2::RequestIO (); use Apache2::RequestUtil; use CGI; use Data::Dumper; +use Text::CSV; use OpenSRF::EX qw(:try); use OpenSRF::Utils qw/:datetime/; @@ -51,15 +52,34 @@ sub child_init { 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') { @@ -240,4 +260,49 @@ sub handler { } +sub show_template { + my $r = shift; + + $r->content_type('text/html'); + $r->print(< + + Record Export + + +
+ Use field + from CSV file +

or

+ Record ID +

Record Type: + +

Record Fromat: + +

Record Encoding: + +

Include holdings in Bibliographic Records: + +
+
+ + + +HTML + + return 200; +} + 1; -- 2.11.0