Bugzilla – Attachment 53628 Details for
Bug 15451
Move the CSV related code to Koha::CsvProfile[s]
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15451: Koha::CsvProfiles - Remove GetCsvProfile
Bug-15451-KohaCsvProfiles---Remove-GetCsvProfile.patch (text/plain), 4.29 KB, created by
Marcel de Rooy
on 2016-07-22 07:26:34 UTC
(
hide
)
Description:
Bug 15451: Koha::CsvProfiles - Remove GetCsvProfile
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2016-07-22 07:26:34 UTC
Size:
4.29 KB
patch
obsolete
>From 44f8573ad1c81766061ae8fa84a1e7bf785d4c87 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 30 Dec 2015 18:26:17 +0000 >Subject: [PATCH] Bug 15451: Koha::CsvProfiles - Remove GetCsvProfile >Content-Type: text/plain; charset=utf-8 > >This subroutine just returned a csv profile for a given id. >It is replaced in this patch by a call to Koha::CsvProfiles->find. > >There is nothing to test here, these changes have been tested in >previous patches. > >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Csv.pm | 13 ------------- > C4/Record.pm | 13 +++++++------ > serials/lateissues-export.pl | 12 +++++++----- > 3 files changed, 14 insertions(+), 24 deletions(-) > >diff --git a/C4/Csv.pm b/C4/Csv.pm >index cc88c01..2cd6430 100644 >--- a/C4/Csv.pm >+++ b/C4/Csv.pm >@@ -31,23 +31,10 @@ use vars qw(@ISA @EXPORT); > # only export API methods > > @EXPORT = qw( >- &GetCsvProfile > &GetMarcFieldsForCsv > ); > > >-# Returns all informations about a given csv profile >-sub GetCsvProfile { >- my ($id) = @_; >- my $dbh = C4::Context->dbh; >- my $query = "SELECT * FROM export_format WHERE export_format_id=?"; >- >- $sth = $dbh->prepare($query); >- $sth->execute($id); >- >- return ($sth->fetchrow_hashref); >-} >- > # Returns fields to extract for the given csv profile > sub GetMarcFieldsForCsv { > >diff --git a/C4/Record.pm b/C4/Record.pm >index a3c1e8e..dbbde57 100644 >--- a/C4/Record.pm >+++ b/C4/Record.pm >@@ -37,6 +37,7 @@ use Template; > use Text::CSV::Encoded; #marc2csv > use Koha::SimpleMARC qw(read_field); > use Koha::XSLT_Handler; >+use Koha::CsvProfiles; > use Carp; > > use vars qw(@ISA @EXPORT); >@@ -475,14 +476,14 @@ sub marcrecord2csv { > my $frameworkcode = GetFrameworkCode($biblio); > > # Getting information about the csv profile >- my $profile = GetCsvProfile($id); >+ my $profile = Koha::CsvProfiles->find($id); > > # Getting output encoding >- my $encoding = $profile->{encoding} || 'utf8'; >+ my $encoding = $profile->encoding || 'utf8'; > # Getting separators >- my $csvseparator = $profile->{csv_separator} || ','; >- my $fieldseparator = $profile->{field_separator} || '#'; >- my $subfieldseparator = $profile->{subfield_separator} || '|'; >+ my $csvseparator = $profile->csv_separator || ','; >+ my $fieldseparator = $profile->field_separator || '#'; >+ my $subfieldseparator = $profile->subfield_separator || '|'; > > # TODO: Be more generic (in case we have to handle other protected chars or more separators) > if ($csvseparator eq '\t') { $csvseparator = "\t" } >@@ -496,7 +497,7 @@ sub marcrecord2csv { > $csv->sep_char($csvseparator); > > # Getting the marcfields >- my $marcfieldslist = $profile->{content}; >+ my $marcfieldslist = $profile->content; > > # Getting the marcfields as an array > my @marcfieldsarray = split('\|', $marcfieldslist); >diff --git a/serials/lateissues-export.pl b/serials/lateissues-export.pl >index d9fc473..e38f6bc 100755 >--- a/serials/lateissues-export.pl >+++ b/serials/lateissues-export.pl >@@ -22,7 +22,9 @@ use C4::Serials; > use C4::Acquisition; > use C4::Output; > use C4::Context; >-use C4::Csv qw( GetCsvProfile ); >+use C4::Csv; >+ >+use Koha::CsvProfiles; > > use Text::CSV_XS; > >@@ -32,17 +34,17 @@ my @serialids = $query->multi_param('serialid'); > my $op = $query->param('op') || q{}; > > my $csv_profile_id = $query->param('csv_profile'); >-my $csv_profile = C4::Csv::GetCsvProfile( $csv_profile_id ); >+my $csv_profile = Koha::CsvProfiles->find( $csv_profile_id ); > die "There is no valid csv profile given" unless $csv_profile; > > my $csv = Text::CSV_XS->new({ > 'quote_char' => '"', > 'escape_char' => '"', >- 'sep_char' => $csv_profile->{csv_separator}, >+ 'sep_char' => $csv_profile->csv_separator, > 'binary' => 1 > }); > >-my $content = $csv_profile->{content}; >+my $content = $csv_profile->content; > my ( @headers, @fields ); > while ( $content =~ / > ([^=]+) # header >@@ -75,7 +77,7 @@ print $query->header( > -attachment => "serials-claims.csv", > ); > >-print join( $csv_profile->{csv_separator}, @headers ) . "\n"; >+print join( $csv_profile->csv_separator, @headers ) . "\n"; > > for my $row ( @rows ) { > $csv->combine(@$row); >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15451
:
46108
|
46109
|
46110
|
46111
|
46112
|
46113
|
46114
|
46306
|
50178
|
50179
|
50180
|
50181
|
50182
|
50183
|
50184
|
50185
|
50860
|
50861
|
50862
|
50863
|
50864
|
50865
|
50866
|
50867
|
50868
|
50985
|
53623
|
53624
|
53625
|
53626
|
53627
| 53628 |
53629
|
53630
|
53631
|
53641