Bug 15451: Koha::CsvProfiles - Remove GetCsvProfile
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> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
bea95dace6
commit
0e80c75aee
13
C4/Csv.pm
13
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 {
|
||||
|
||||
|
|
|
|||
13
C4/Record.pm
13
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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue