[Koha-patches] [PATCH 8/9] MT 2116: Addons to the CSV export

Henri-Damien LAURENT henridamien.laurent at biblibre.com
Tue Feb 16 21:46:56 CET 2010


From: Matthias Meusburger <matthias.meusburger at biblibre.com>

Fix encoding selection
---
 C4/Record.pm                    |   14 +++++++-------
 basket/downloadcart.pl          |    1 -
 opac/opac-downloadcart.pl       |    1 -
 opac/opac-downloadshelf.pl      |    1 -
 virtualshelves/downloadshelf.pl |    3 +--
 5 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/C4/Record.pm b/C4/Record.pm
index 65f3f7a..20901b6 100644
--- a/C4/Record.pm
+++ b/C4/Record.pm
@@ -328,12 +328,12 @@ sub marc2endnote {
 	
 }
 
-=head2 marcrecords2csv - Convert several records from UNIMARC to CSV
+=head2 marc2csv - Convert several records from UNIMARC to CSV
 Pre and postprocessing can be done through a YAML file
 
 =over 4
 
-my ($csv) = marcrecords2csv($biblios, $csvprofileid);
+my ($csv) = marc2csv($biblios, $csvprofileid);
 
 Returns a CSV scalar
 
@@ -376,11 +376,11 @@ sub marc2csv {
     return $output;
 }
 
-=head2 marc2csv - Convert a single record from UNIMARC to CSV
+=head2 marcrecord2csv - Convert a single record from UNIMARC to CSV
 
 =over 4
 
-my ($csv) = marc2csv($biblio, $csvprofileid, $header);
+my ($csv) = marcrecord2csv($biblio, $csvprofileid, $header);
 
 Returns a CSV scalar
 
@@ -416,7 +416,6 @@ sub marcrecord2csv {
 
     # Getting output encoding
     my $encoding          = $profile->{encoding} || 'utf8';
-
     # Getting separators
     my $csvseparator      = $profile->{csv_separator}      || ',';
     my $fieldseparator    = $profile->{field_separator}    || '#';
@@ -427,7 +426,8 @@ sub marcrecord2csv {
     if ($fieldseparator eq '\t') { $fieldseparator = "\t" }
     if ($subfieldseparator eq '\t') { $subfieldseparator = "\t" }
 
-    $csv->encoding_out($encoding) if ($encoding ne 'utf8');
+
+    $csv = $csv->encoding_out($encoding) ;
     $csv->sep_char($csvseparator);
 
     # Getting the marcfields
@@ -528,7 +528,7 @@ sub marcrecord2csv {
 
     $csv->combine(@fieldstab);
     $output .= $csv->string() . "\n";
-   
+
     return $output;
 
 }
diff --git a/basket/downloadcart.pl b/basket/downloadcart.pl
index 5c3ff79..b4b999c 100755
--- a/basket/downloadcart.pl
+++ b/basket/downloadcart.pl
@@ -33,7 +33,6 @@ use C4::Record;
 use C4::Ris;
 use C4::Csv;
 use utf8;
-use open qw( :std :utf8);
 my $query = new CGI;
 
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
diff --git a/opac/opac-downloadcart.pl b/opac/opac-downloadcart.pl
index 3e7096b..a670a65 100755
--- a/opac/opac-downloadcart.pl
+++ b/opac/opac-downloadcart.pl
@@ -33,7 +33,6 @@ use C4::Record;
 use C4::Ris;
 use C4::Csv;
 use utf8;
-use open qw( :std :utf8);
 my $query = new CGI;
 
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
diff --git a/opac/opac-downloadshelf.pl b/opac/opac-downloadshelf.pl
index 50b1927..94785be 100755
--- a/opac/opac-downloadshelf.pl
+++ b/opac/opac-downloadshelf.pl
@@ -33,7 +33,6 @@ use C4::Record;
 use C4::Ris;
 use C4::Csv;
 use utf8;
-use open qw( :std :utf8);
 my $query = new CGI;
 
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
diff --git a/virtualshelves/downloadshelf.pl b/virtualshelves/downloadshelf.pl
index 1d3e87c..9af03e0 100755
--- a/virtualshelves/downloadshelf.pl
+++ b/virtualshelves/downloadshelf.pl
@@ -33,7 +33,6 @@ use C4::Record;
 use C4::Ris;
 use C4::Csv;
 use utf8;
-use open qw( :std :utf8);
 my $query = new CGI;
 
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
@@ -82,7 +81,7 @@ if ($shelfid && $format) {
 
     # If it was a CSV export we change the format after the export so the file extension is fine
     $format = "csv" if ($format =~ m/^\d+$/);
-
+    
     print $query->header(
 	-type => 'application/octet-stream',
 	-'Content-Transfer-Encoding' => 'binary',
-- 
1.6.3.3




More information about the Koha-patches mailing list