Bugzilla – Attachment 3780 Details for
Bug 5579
Remove items from biblioitems.marcxml
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
bug 5579 : Fixes several exports to embed items
0001-bug-5579-Fixes-several-exports-to-embed-items.patch (text/plain), 9.42 KB, created by
Matthias Meusburger
on 2011-04-07 10:07:45 UTC
(
hide
)
Description:
bug 5579 : Fixes several exports to embed items
Filename:
MIME Type:
Creator:
Matthias Meusburger
Created:
2011-04-07 10:07:45 UTC
Size:
9.42 KB
patch
obsolete
>From 71c9b9824f2a5f7891bc4b2d7ecea61290956144 Mon Sep 17 00:00:00 2001 >From: Matthias Meusburger <matthias.meusburger@biblibre.com> >Date: Thu, 7 Apr 2011 12:04:43 +0200 >Subject: [PATCH] bug 5579 : Fixes several exports to embed items > > - The following export pages used to embed items when exporting, > this was no longer the case, so they were fixed : > Intranet : > - basket/downloadcart.pl, > - virtualshelves/downloadshelf.pl > - catalogue/export.pl > Opac : > - opac/opac-downloadcart.pl > - opac/opac-downloadshelf.pl > - opac/opac-export.pl > > - Notes : > - GetMarcBiblio used to embed items data, this was no longer the case, > so an optional parameter was added to choose if items should be embedded or not. > This way, previous work on this bug is not broken, and this is a pretty usefull > feature, imho. > - An optional parameter has been added to SetUTF8Flag, to be able to use NFD during > normalization. This was required to make Unicode/UTF-8 export work again. >--- > C4/Biblio.pm | 8 ++++- > C4/Charset.pm | 8 +++-- > C4/Record.pm | 2 +- > basket/downloadcart.pl | 2 +- > catalogue/export.pl | 15 +++------- > opac/opac-downloadcart.pl | 2 +- > opac/opac-downloadshelf.pl | 2 +- > opac/opac-export.pl | 56 ++++++++++++++++++-------------------- > virtualshelves/downloadshelf.pl | 2 +- > 9 files changed, 48 insertions(+), 49 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index c8f3a14..f48184d 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -1023,16 +1023,18 @@ sub GetMarcFromKohaField { > > =head2 GetMarcBiblio > >- my $record = GetMarcBiblio($biblionumber); >+ my $record = GetMarcBiblio($biblionumber, [$embeditems]); > > Returns MARC::Record representing bib identified by > C<$biblionumber>. If no bib exists, returns undef. >-The MARC record contains both biblio & item data. >+C<$embeditems>. If set to true, items data are included. >+The MARC record contains biblio data, and items data if $embeditems is set to true. > > =cut > > sub GetMarcBiblio { > my $biblionumber = shift; >+ my $embeditems = shift || 0; > my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare("SELECT marcxml FROM biblioitems WHERE biblionumber=? "); > $sth->execute($biblionumber); >@@ -1046,6 +1048,8 @@ sub GetMarcBiblio { > if ($@) { warn " problem with :$biblionumber : $@ \n$marcxml"; } > return unless $record; > >+ C4::Biblio::EmbedItemsInMarcBiblio($record, $biblionumber) if ($embeditems); >+ > # $record = MARC::Record::new_from_usmarc( $marc) if $marc; > return $record; > } else { >diff --git a/C4/Charset.pm b/C4/Charset.pm >index 712bd85..04f3c63 100644 >--- a/C4/Charset.pm >+++ b/C4/Charset.pm >@@ -112,7 +112,7 @@ sub IsStringUTF8ish { > > =head2 SetUTF8Flag > >- my $marc_record = SetUTF8Flag($marc_record); >+ my $marc_record = SetUTF8Flag($marc_record, $nfd); > > This function sets the PERL UTF8 flag for data. > It is required when using new_from_usmarc >@@ -120,6 +120,8 @@ since MARC::File::USMARC does not handle PERL UTF8 setting. > When editing unicode marc records fields and subfields, you > would end up in double encoding without using this function. > >+If $nfd is set, string normalization will use NFD instead of NFC >+ > FIXME > In my opinion, this function belongs to MARC::Record and not > to this package. >@@ -128,13 +130,13 @@ But since it handles charset, and MARC::Record, it finds its way in that package > =cut > > sub SetUTF8Flag{ >- my ($record)=@_; >+ my ($record, $nfd)=@_; > return unless ($record && $record->fields()); > foreach my $field ($record->fields()){ > if ($field->tag()>=10){ > my @subfields; > foreach my $subfield ($field->subfields()){ >- push @subfields,($$subfield[0],NormalizeString($$subfield[1])); >+ push @subfields,($$subfield[0],NormalizeString($$subfield[1],$nfd)); > } > my $newfield=MARC::Field->new( > $field->tag(), >diff --git a/C4/Record.pm b/C4/Record.pm >index b313fb8..a9a46dd 100644 >--- a/C4/Record.pm >+++ b/C4/Record.pm >@@ -359,7 +359,7 @@ sub marcrecord2csv { > my $output; > > # Getting the record >- my $record = GetMarcBiblio($biblio); >+ my $record = GetMarcBiblio($biblio, 1); > next unless $record; > # Getting the framework > my $frameworkcode = GetFrameworkCode($biblio); >diff --git a/basket/downloadcart.pl b/basket/downloadcart.pl >index 456f0a4..392a3e4 100755 >--- a/basket/downloadcart.pl >+++ b/basket/downloadcart.pl >@@ -65,7 +65,7 @@ if ($bib_list && $format) { > > foreach my $biblio (@bibs) { > >- my $record = GetMarcBiblio($biblio); >+ my $record = GetMarcBiblio($biblio, 1); > > if ($format eq 'iso2709') { > $output .= $record->as_usmarc(); >diff --git a/catalogue/export.pl b/catalogue/export.pl >index f6f02d7..9bd49de 100755 >--- a/catalogue/export.pl >+++ b/catalogue/export.pl >@@ -15,14 +15,9 @@ my $op=$query->param("op"); > my $format=$query->param("format"); > if ($op eq "export") { > my $biblionumber = $query->param("bib"); >- my $dbh=C4::Context->dbh; >- my $sth; >- if ($biblionumber) { >- $sth=$dbh->prepare("SELECT marc FROM biblioitems WHERE biblionumber =?"); >- $sth->execute($biblionumber); >- } >- while (my ($marc) = $sth->fetchrow) { >- if ($marc){ >+ if ($biblionumber){ >+ >+ my $marc = GetMarcBiblio($biblionumber, 1); > > if ($format =~ /endnote/) { > $marc = marc2endnote($marc); >@@ -44,12 +39,12 @@ if ($op eq "export") { > $marc = $marc->as_usmarc(); > } > elsif ($format =~ /utf8/) { >- #default >+ C4::Charset::SetUTF8Flag($marc, 1); >+ $marc = $marc->as_usmarc(); > } > print $query->header( > -type => 'application/octet-stream', > -attachment=>"bib-$biblionumber.$format"); > print $marc; > } >- } > } >diff --git a/opac/opac-downloadcart.pl b/opac/opac-downloadcart.pl >index 7f2bb32..3a4cdc1 100755 >--- a/opac/opac-downloadcart.pl >+++ b/opac/opac-downloadcart.pl >@@ -64,7 +64,7 @@ if ($bib_list && $format) { > } else { > foreach my $biblio (@bibs) { > >- my $record = GetMarcBiblio($biblio); >+ my $record = GetMarcBiblio($biblio, 1); > next unless $record; > > if ($format eq 'iso2709') { >diff --git a/opac/opac-downloadshelf.pl b/opac/opac-downloadshelf.pl >index ab1fe8d..ee9b0b1 100755 >--- a/opac/opac-downloadshelf.pl >+++ b/opac/opac-downloadshelf.pl >@@ -68,7 +68,7 @@ if ($shelfid && $format) { > foreach my $biblio (@$items) { > my $biblionumber = $biblio->{biblionumber}; > >- my $record = GetMarcBiblio($biblionumber); >+ my $record = GetMarcBiblio($biblionumber, 1); > next unless $record; > > if ($format eq 'iso2709') { >diff --git a/opac/opac-export.pl b/opac/opac-export.pl >index f9d3c25..e8f7ede 100755 >--- a/opac/opac-export.pl >+++ b/opac/opac-export.pl >@@ -35,15 +35,11 @@ my $op=$query->param("op"); > my $format=$query->param("format"); > if ($op eq "export") { > my $biblionumber = $query->param("bib"); >- my $dbh=C4::Context->dbh; >- my $sth; >- if ($biblionumber) { >- $sth=$dbh->prepare("SELECT marc FROM biblioitems WHERE biblionumber =?"); >- $sth->execute($biblionumber); >- } >- my $error; >- while (my ($marc) = $sth->fetchrow) { >- if ($marc){ >+ my $error; >+ >+ if ($biblionumber){ >+ >+ my $marc = GetMarcBiblio($biblionumber, 1); > > if ($format =~ /endnote/) { > $marc = marc2endnote($marc); >@@ -60,32 +56,34 @@ if ($op eq "export") { > } > elsif ($format =~ /bibtex/) { > $marc = marc2bibtex(C4::Biblio::GetMarcBiblio($biblionumber),$biblionumber); >- }elsif ($format =~ /dc/) { >- ($error,$marc) = marc2dcxml($marc,1); >+ } >+ elsif ($format =~ /dc/) { >+ ($error,$marc) = marc2dcxml($marc,1); > $format = "dublin-core.xml"; > } > elsif ($format =~ /marc8/) { > ($error,$marc) = changeEncoding($marc,"MARC","MARC21","MARC-8"); >- if (! $error){ >- $marc = $marc->as_usmarc(); >- } >+ if (! $error){ >+ $marc = $marc->as_usmarc(); >+ } > } > elsif ($format =~ /utf8/) { >- #default >+ C4::Charset::SetUTF8Flag($marc,1); >+ $marc = $marc->as_usmarc(); > } >- if ($error){ >- print $query->header(); >- print $query->start_html(); >- print "<h1>An error occured </h1>"; >- print $error; >- print $query->end_html(); >- } >- else { >- print $query->header( >- -type => 'application/octet-stream', >- -attachment=>"bib-$biblionumber.$format"); >- print $marc; >- } >+ >+ if ($error){ >+ print $query->header(); >+ print $query->start_html(); >+ print "<h1>An error occured </h1>"; >+ print $error; >+ print $query->end_html(); >+ } >+ else { >+ print $query->header( >+ -type => 'application/octet-stream', >+ -attachment=>"bib-$biblionumber.$format"); >+ print $marc; > } >- } >+ } > } >diff --git a/virtualshelves/downloadshelf.pl b/virtualshelves/downloadshelf.pl >index 253eec1..1611f1a 100755 >--- a/virtualshelves/downloadshelf.pl >+++ b/virtualshelves/downloadshelf.pl >@@ -68,7 +68,7 @@ if ($shelfid && $format) { > foreach my $biblio (@$items) { > my $biblionumber = $biblio->{biblionumber}; > >- my $record = GetMarcBiblio($biblionumber); >+ my $record = GetMarcBiblio($biblionumber, 1); > > if ($format eq 'iso2709') { > $output .= $record->as_usmarc(); >-- >1.7.1 >
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 5579
: 3780 |
3797
|
3812
|
3826
|
4264