Lines 76-81
BEGIN {
Link Here
|
76 |
&GetMarcISSN |
76 |
&GetMarcISSN |
77 |
&GetMarcSubjects |
77 |
&GetMarcSubjects |
78 |
&GetMarcBiblio |
78 |
&GetMarcBiblio |
|
|
79 |
&GetMarcBiblioForOpac |
79 |
&GetMarcAuthors |
80 |
&GetMarcAuthors |
80 |
&GetMarcSeries |
81 |
&GetMarcSeries |
81 |
&GetMarcHosts |
82 |
&GetMarcHosts |
Lines 137-142
BEGIN {
Link Here
|
137 |
&TransformHtmlToMarc |
138 |
&TransformHtmlToMarc |
138 |
&TransformHtmlToXml |
139 |
&TransformHtmlToXml |
139 |
prepare_host_field |
140 |
prepare_host_field |
|
|
141 |
&RemoveHiddenSubfields |
140 |
); |
142 |
); |
141 |
} |
143 |
} |
142 |
|
144 |
|
Lines 899-914
sub GetBiblioFromItemNumber {
Link Here
|
899 |
|
901 |
|
900 |
=head2 GetISBDView |
902 |
=head2 GetISBDView |
901 |
|
903 |
|
902 |
$isbd = &GetISBDView($biblionumber); |
904 |
$isbd = &GetISBDView($biblionumber, [$template]); |
903 |
|
905 |
|
904 |
Return the ISBD view which can be included in opac and intranet |
906 |
Returns the ISBD view which can be included in opac and intranet. |
|
|
907 |
|
908 |
C<$template> - 'opac' or 'intranet', default 'intranet' |
905 |
|
909 |
|
906 |
=cut |
910 |
=cut |
907 |
|
911 |
|
908 |
sub GetISBDView { |
912 |
sub GetISBDView { |
909 |
my ( $biblionumber, $template ) = @_; |
913 |
my $biblionumber = shift; |
910 |
my $record = GetMarcBiblio($biblionumber, 1); |
914 |
my $template = shift || 'intranet'; |
|
|
915 |
|
916 |
my $record = ($template eq 'opac') ? GetMarcBiblioForOpac($biblionumber, 1) : GetMarcBiblio($biblionumber, 1); |
911 |
return unless defined $record; |
917 |
return unless defined $record; |
|
|
918 |
|
912 |
my $itemtype = &GetFrameworkCode($biblionumber); |
919 |
my $itemtype = &GetFrameworkCode($biblionumber); |
913 |
my ( $holdingbrtagf, $holdingbrtagsubf ) = &GetMarcFromKohaField( "items.holdingbranch", $itemtype ); |
920 |
my ( $holdingbrtagf, $holdingbrtagsubf ) = &GetMarcFromKohaField( "items.holdingbranch", $itemtype ); |
914 |
my $tagslib = &GetMarcStructure( 1, $itemtype ); |
921 |
my $tagslib = &GetMarcStructure( 1, $itemtype ); |
Lines 1239-1276
sub GetMarcSubfieldStructureFromKohaField {
Link Here
|
1239 |
|
1246 |
|
1240 |
=head2 GetMarcBiblio |
1247 |
=head2 GetMarcBiblio |
1241 |
|
1248 |
|
1242 |
my $record = GetMarcBiblio($biblionumber, [$embeditems]); |
1249 |
my $record = GetMarcBiblio($biblionumber, [$embeditems], [$template], [$withouthidden]); |
|
|
1250 |
|
1251 |
Returns MARC::Record representing bib. If no bib exists, returns undef. |
1252 |
|
1253 |
C<$biblionumber> - the biblionumber of the biblio |
1243 |
|
1254 |
|
1244 |
Returns MARC::Record representing bib identified by |
1255 |
C<$embeditems> - if set to true items data are included, default false |
1245 |
C<$biblionumber>. If no bib exists, returns undef. |
1256 |
|
1246 |
C<$embeditems>. If set to true, items data are included. |
1257 |
C<$template> - 'opac' or 'intranet', default 'intranet' |
1247 |
The MARC record contains biblio data, and items data if $embeditems is set to true. |
1258 |
|
|
|
1259 |
C<$withouthidden> - if set to true hidden subfields are not included, default false |
1248 |
|
1260 |
|
1249 |
=cut |
1261 |
=cut |
1250 |
|
1262 |
|
1251 |
sub GetMarcBiblio { |
1263 |
sub GetMarcBiblio { |
1252 |
my $biblionumber = shift; |
1264 |
my $biblionumber = shift; |
1253 |
my $embeditems = shift || 0; |
1265 |
my $embeditems = shift || 0; |
|
|
1266 |
my $template = shift || 'intranet'; |
1267 |
my $withouthidden = shift || 0; |
1268 |
|
1254 |
my $dbh = C4::Context->dbh; |
1269 |
my $dbh = C4::Context->dbh; |
1255 |
my $sth = $dbh->prepare("SELECT marcxml FROM biblioitems WHERE biblionumber=? "); |
1270 |
my $sth = $dbh->prepare("SELECT marcxml FROM biblioitems WHERE biblionumber=? "); |
1256 |
$sth->execute($biblionumber); |
1271 |
$sth->execute($biblionumber); |
1257 |
my $row = $sth->fetchrow_hashref; |
1272 |
my $row = $sth->fetchrow_hashref; |
1258 |
my $marcxml = StripNonXmlChars( $row->{'marcxml'} ); |
1273 |
my $marcxml = StripNonXmlChars( $row->{'marcxml'} ); |
|
|
1274 |
return unless $marcxml; |
1275 |
|
1259 |
MARC::File::XML->default_record_format( C4::Context->preference('marcflavour') ); |
1276 |
MARC::File::XML->default_record_format( C4::Context->preference('marcflavour') ); |
1260 |
my $record = MARC::Record->new(); |
1277 |
my $record = MARC::Record->new(); |
|
|
1278 |
$record = eval { MARC::Record::new_from_xml( $marcxml, "utf8", C4::Context->preference('marcflavour') ) }; |
1279 |
if ($@) { warn " problem with :$biblionumber : $@ \n$marcxml"; } |
1280 |
return unless $record; |
1261 |
|
1281 |
|
1262 |
if ($marcxml) { |
1282 |
C4::Biblio::_koha_marc_update_bib_ids($record, '', $biblionumber, $biblionumber); |
1263 |
$record = eval { MARC::Record::new_from_xml( $marcxml, "utf8", C4::Context->preference('marcflavour') ) }; |
1283 |
C4::Biblio::EmbedItemsInMarcBiblio($record, $biblionumber) if ($embeditems); |
1264 |
if ($@) { warn " problem with :$biblionumber : $@ \n$marcxml"; } |
|
|
1265 |
return unless $record; |
1266 |
|
1267 |
C4::Biblio::_koha_marc_update_bib_ids($record, '', $biblionumber, $biblionumber); |
1268 |
C4::Biblio::EmbedItemsInMarcBiblio($record, $biblionumber) if ($embeditems); |
1269 |
|
1284 |
|
1270 |
return $record; |
1285 |
if ($withouthidden) { |
1271 |
} else { |
1286 |
my $frameworkcode = GetFrameworkCode( $biblionumber ); |
1272 |
return; |
1287 |
RemoveHiddenSubfields($record, $frameworkcode, $template); |
1273 |
} |
1288 |
} |
|
|
1289 |
|
1290 |
return $record; |
1291 |
} |
1292 |
|
1293 |
=head2 GetMarcBiblioForOpac |
1294 |
|
1295 |
my $record = GetMarcBiblioForOpac($biblionumber, [$embeditems]); |
1296 |
|
1297 |
Returns MARC::Record representing bib. If no bib exists, returns undef. |
1298 |
The record does not contain subfields hidden at OPAC. |
1299 |
|
1300 |
C<$biblionumber> - the biblionumber of the biblio |
1301 |
|
1302 |
C<$embeditems> - if set to true items data are included, default false |
1303 |
|
1304 |
=cut |
1305 |
|
1306 |
sub GetMarcBiblioForOpac { |
1307 |
my $biblionumber = shift; |
1308 |
my $embeditems = shift || 0; |
1309 |
return GetMarcBiblio($biblionumber, $embeditems, 'opac', 1); |
1274 |
} |
1310 |
} |
1275 |
|
1311 |
|
1276 |
=head2 GetXmlBiblio |
1312 |
=head2 GetXmlBiblio |
Lines 3659-3664
sub RemoveAllNsb {
Link Here
|
3659 |
return $record; |
3695 |
return $record; |
3660 |
} |
3696 |
} |
3661 |
|
3697 |
|
|
|
3698 |
=head2 RemoveHiddenSubfields |
3699 |
|
3700 |
RemoveHiddenSubfields( $record, [$frameworkcode], [$template] ); |
3701 |
|
3702 |
Removes from record all subfields marked as hidden. |
3703 |
|
3704 |
=cut |
3705 |
|
3706 |
sub RemoveHiddenSubfields { |
3707 |
my $record = shift; |
3708 |
my $frameworkcode = shift || ''; |
3709 |
my $template = shift || 'intranet'; |
3710 |
|
3711 |
my $tagslib = GetMarcStructure( 1, $frameworkcode ); |
3712 |
|
3713 |
foreach my $tag ( keys %$tagslib ) { |
3714 |
my @fields = $record->field($tag); |
3715 |
next unless @fields; |
3716 |
|
3717 |
my @subfields_to_remove; |
3718 |
foreach my $subfield ( keys %{ $tagslib->{$tag} } ) { |
3719 |
# skip tag infos |
3720 |
next unless ( ref( $tagslib->{$tag}->{$subfield} ) eq "HASH" ); |
3721 |
if ( $template eq 'opac' ) { |
3722 |
push @subfields_to_remove, $subfield |
3723 |
if $tagslib->{$tag}->{$subfield}->{'hidden'} > 0; |
3724 |
} |
3725 |
else { |
3726 |
push @subfields_to_remove, $subfield |
3727 |
if $tagslib->{$tag}->{$subfield}->{'hidden'} =~ |
3728 |
/-7|-4|-3|-2|2|3|5|8/; |
3729 |
} |
3730 |
} |
3731 |
if ( @subfields_to_remove ) { |
3732 |
foreach my $field (@fields) { |
3733 |
if ( $tag < 10 ) { |
3734 |
# control field so delete entire field |
3735 |
$record->delete_field($field); |
3736 |
} |
3737 |
else { |
3738 |
$field->delete_subfield( code => \@subfields_to_remove ); |
3739 |
# delete field if no subfield anymore |
3740 |
$record->delete_field($field) |
3741 |
unless ( $field->subfields() ); |
3742 |
} |
3743 |
} |
3744 |
} |
3745 |
} |
3746 |
} |
3747 |
|
3662 |
1; |
3748 |
1; |
3663 |
|
3749 |
|
3664 |
|
3750 |
|