From 9f9daa3b73802b7f8691a48b2f8b0e7e6a17e7d9 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 10 Feb 2015 20:30:23 -0300 Subject: [PATCH] Bug 13695: Add ISBD export option for the OPAC cart and lists This patch adds the option to download records from the cart, and lists in the ISBD format from the OPAC. To test (cart): - Apply the patch - Add several records to your OPAC cart. - Go to your cart, and choose 'Download' => SUCCESS: There's an ISBD option - Dowload and open the exported records => SUCCESS: The file contains the ISBD format for the records on the cart To test (lists): - Add several records to a list (i did it from the cart ;-)) - Open the list - Choose 'Download list' => SUCCESS: There's an ISBD option - Download and open the exported records => SUCCESS: The file contains the ISBD format for the records on the list. - Sign off :-D Sponsored-by: Orex Digital Signed-off-by: Brendan Gallagher --- .../bootstrap/en/modules/opac-downloadcart.tt | 1 + .../bootstrap/en/modules/opac-downloadshelf.tt | 1 + opac/opac-downloadcart.pl | 16 ++++++++++++---- opac/opac-downloadshelf.pl | 14 +++++++++++--- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadcart.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadcart.tt index 8536c46..9f1f65d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadcart.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadcart.tt @@ -14,6 +14,7 @@ + [% FOREACH csv_profile IN csv_profiles %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt index 128cec2..a9c53f9 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt @@ -53,6 +53,7 @@ + [% FOREACH csv_profile IN csv_profiles %] diff --git a/opac/opac-downloadcart.pl b/opac/opac-downloadcart.pl index 98a7f3c..5164c2e 100755 --- a/opac/opac-downloadcart.pl +++ b/opac/opac-downloadcart.pl @@ -52,8 +52,10 @@ if ($bib_list && $format) { my @bibs = split( /\//, $bib_list ); - my $marcflavour = C4::Context->preference('marcflavour'); + my $marcflavour = C4::Context->preference('marcflavour'); my $output; + my $extension; + my $type; # CSV if ($format =~ /^\d+$/) { @@ -76,6 +78,11 @@ if ($bib_list && $format) { elsif ($format eq 'bibtex') { $output .= marc2bibtex($record, $biblio); } + elsif ( $format eq 'isbd' ) { + $output .= GetISBDView($biblio, "opac"); + $extension = "txt"; + $type = "text/plain"; + } } } @@ -83,9 +90,10 @@ if ($bib_list && $format) { $format = "csv" if ($format =~ m/^\d+$/); print $query->header( - -type => 'application/octet-stream', - -'Content-Transfer-Encoding' => 'binary', - -attachment=>"cart.$format"); + -type => ($type) ? $type : 'application/octet-stream', + -'Content-Transfer-Encoding' => 'binary', + -attachment => ($extension) ? "cart.$format.$extension" : "cart.$format" + ); print $output; } else { diff --git a/opac/opac-downloadshelf.pl b/opac/opac-downloadshelf.pl index 7a6b1dd..0230eba 100755 --- a/opac/opac-downloadshelf.pl +++ b/opac/opac-downloadshelf.pl @@ -57,6 +57,8 @@ if ( ShelfPossibleAction( (defined($borrowernumber) ? $borrowernumber : -1), $sh my ($items, $totitems) = GetShelfContents($shelfid); my $marcflavour = C4::Context->preference('marcflavour'); my $output; + my $extension; + my $type; # CSV if ($format =~ /^\d+$/) { @@ -83,6 +85,11 @@ if ( ShelfPossibleAction( (defined($borrowernumber) ? $borrowernumber : -1), $sh elsif ($format eq 'bibtex') { $output .= marc2bibtex($record, $biblionumber); } + elsif ( $format eq 'isbd' ) { + $output .= GetISBDView($biblionumber, "opac"); + $extension = "txt"; + $type = "text/plain"; + } } } @@ -90,9 +97,10 @@ if ( ShelfPossibleAction( (defined($borrowernumber) ? $borrowernumber : -1), $sh $format = "csv" if ($format =~ m/^\d+$/); print $query->header( - -type => 'application/octet-stream', - -'Content-Transfer-Encoding' => 'binary', - -attachment=>"shelf.$format"); + -type => ($type) ? $type : 'application/octet-stream', + -'Content-Transfer-Encoding' => 'binary', + -attachment => ($extension) ? "shelf.$format.$extension" : "shelf.$format" + ); print $output; } else { -- 1.7.10.4