- 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.
Signed-off-by: Claire Hernandez <claire.hernandez@biblibre.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
- my $record = GetMarcBiblio($biblionumber);
+ my $record = GetMarcBiblio($biblionumber, [$embeditems]);
Returns MARC::Record representing bib identified by
C<$biblionumber>. If no bib exists, returns undef.
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;
=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);
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare("SELECT marcxml FROM biblioitems WHERE biblionumber=? ");
$sth->execute($biblionumber);
if ($@) { warn " problem with :$biblionumber : $@ \n$marcxml"; }
return unless $record;
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 {
# $record = MARC::Record::new_from_usmarc( $marc) if $marc;
return $record;
} else {
- 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
This function sets the PERL UTF8 flag for data.
It is required when using new_from_usmarc
When editing unicode marc records fields and subfields, you
would end up in double encoding without using this function.
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.
FIXME
In my opinion, this function belongs to MARC::Record and not
to this package.
return unless ($record && $record->fields());
foreach my $field ($record->fields()){
if ($field->tag()>=10){
my @subfields;
foreach my $subfield ($field->subfields()){
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(),
}
my $newfield=MARC::Field->new(
$field->tag(),
my $output;
# Getting the record
my $output;
# Getting the record
- my $record = GetMarcBiblio($biblio);
+ my $record = GetMarcBiblio($biblio, 1);
next unless $record;
# Getting the framework
my $frameworkcode = GetFrameworkCode($biblio);
next unless $record;
# Getting the framework
my $frameworkcode = GetFrameworkCode($biblio);
foreach my $biblio (@bibs) {
foreach my $biblio (@bibs) {
- my $record = GetMarcBiblio($biblio);
+ my $record = GetMarcBiblio($biblio, 1);
if ($format eq 'iso2709') {
$output .= $record->as_usmarc();
if ($format eq 'iso2709') {
$output .= $record->as_usmarc();
my $format=$query->param("format");
if ($op eq "export") {
my $biblionumber = $query->param("bib");
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);
if ($format =~ /endnote/) {
$marc = marc2endnote($marc);
$marc = $marc->as_usmarc();
}
elsif ($format =~ /utf8/) {
$marc = $marc->as_usmarc();
}
elsif ($format =~ /utf8/) {
+ C4::Charset::SetUTF8Flag($marc, 1);
+ $marc = $marc->as_usmarc();
}
print $query->header(
-type => 'application/octet-stream',
-attachment=>"bib-$biblionumber.$format");
print $marc;
}
}
print $query->header(
-type => 'application/octet-stream',
-attachment=>"bib-$biblionumber.$format");
print $marc;
}
} else {
foreach my $biblio (@bibs) {
} else {
foreach my $biblio (@bibs) {
- my $record = GetMarcBiblio($biblio);
+ my $record = GetMarcBiblio($biblio, 1);
next unless $record;
if ($format eq 'iso2709') {
next unless $record;
if ($format eq 'iso2709') {
foreach my $biblio (@$items) {
my $biblionumber = $biblio->{biblionumber};
foreach my $biblio (@$items) {
my $biblionumber = $biblio->{biblionumber};
- my $record = GetMarcBiblio($biblionumber);
+ my $record = GetMarcBiblio($biblionumber, 1);
next unless $record;
if ($format eq 'iso2709') {
next unless $record;
if ($format eq 'iso2709') {
my $format=$query->param("format");
if ($op eq "export") {
my $biblionumber = $query->param("bib");
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);
if ($format =~ /endnote/) {
$marc = marc2endnote($marc);
}
elsif ($format =~ /bibtex/) {
$marc = marc2bibtex(C4::Biblio::GetMarcBiblio($biblionumber),$biblionumber);
}
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");
$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/) {
}
elsif ($format =~ /utf8/) {
+ 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;
foreach my $biblio (@$items) {
my $biblionumber = $biblio->{biblionumber};
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();
if ($format eq 'iso2709') {
$output .= $record->as_usmarc();