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 138-143
BEGIN {
Link Here
|
138 |
&TransformHtmlToXml |
139 |
&TransformHtmlToXml |
139 |
&GetNoZebraIndexes |
140 |
&GetNoZebraIndexes |
140 |
prepare_host_field |
141 |
prepare_host_field |
|
|
142 |
&RemoveHiddenSubfields |
141 |
); |
143 |
); |
142 |
} |
144 |
} |
143 |
|
145 |
|
Lines 908-923
sub GetBiblioFromItemNumber {
Link Here
|
908 |
|
910 |
|
909 |
=head2 GetISBDView |
911 |
=head2 GetISBDView |
910 |
|
912 |
|
911 |
$isbd = &GetISBDView($biblionumber); |
913 |
$isbd = &GetISBDView($biblionumber, [$template]); |
912 |
|
914 |
|
913 |
Return the ISBD view which can be included in opac and intranet |
915 |
Returns the ISBD view which can be included in opac and intranet. |
|
|
916 |
|
917 |
C<$template> - 'opac' or 'intranet', default 'intranet' |
914 |
|
918 |
|
915 |
=cut |
919 |
=cut |
916 |
|
920 |
|
917 |
sub GetISBDView { |
921 |
sub GetISBDView { |
918 |
my ( $biblionumber, $template ) = @_; |
922 |
my $biblionumber = shift; |
919 |
my $record = GetMarcBiblio($biblionumber, 1); |
923 |
my $template = shift || 'intranet'; |
|
|
924 |
|
925 |
my $record = ($template eq 'opac') ? GetMarcBiblioForOpac($biblionumber, 1) : GetMarcBiblio($biblionumber, 1); |
920 |
return unless defined $record; |
926 |
return unless defined $record; |
|
|
927 |
|
921 |
my $itemtype = &GetFrameworkCode($biblionumber); |
928 |
my $itemtype = &GetFrameworkCode($biblionumber); |
922 |
my ( $holdingbrtagf, $holdingbrtagsubf ) = &GetMarcFromKohaField( "items.holdingbranch", $itemtype ); |
929 |
my ( $holdingbrtagf, $holdingbrtagsubf ) = &GetMarcFromKohaField( "items.holdingbranch", $itemtype ); |
923 |
my $tagslib = &GetMarcStructure( 1, $itemtype ); |
930 |
my $tagslib = &GetMarcStructure( 1, $itemtype ); |
Lines 1248-1285
sub GetMarcSubfieldStructureFromKohaField {
Link Here
|
1248 |
|
1255 |
|
1249 |
=head2 GetMarcBiblio |
1256 |
=head2 GetMarcBiblio |
1250 |
|
1257 |
|
1251 |
my $record = GetMarcBiblio($biblionumber, [$embeditems]); |
1258 |
my $record = GetMarcBiblio($biblionumber, [$embeditems], [$template], [$withouthidden]); |
|
|
1259 |
|
1260 |
Returns MARC::Record representing bib. If no bib exists, returns undef. |
1261 |
|
1262 |
C<$biblionumber> - the biblionumber of the biblio |
1252 |
|
1263 |
|
1253 |
Returns MARC::Record representing bib identified by |
1264 |
C<$embeditems> - if set to true items data are included, default false |
1254 |
C<$biblionumber>. If no bib exists, returns undef. |
1265 |
|
1255 |
C<$embeditems>. If set to true, items data are included. |
1266 |
C<$template> - 'opac' or 'intranet', default 'intranet' |
1256 |
The MARC record contains biblio data, and items data if $embeditems is set to true. |
1267 |
|
|
|
1268 |
C<$withouthidden> - if set to true hidden subfields are not included, default false |
1257 |
|
1269 |
|
1258 |
=cut |
1270 |
=cut |
1259 |
|
1271 |
|
1260 |
sub GetMarcBiblio { |
1272 |
sub GetMarcBiblio { |
1261 |
my $biblionumber = shift; |
1273 |
my $biblionumber = shift; |
1262 |
my $embeditems = shift || 0; |
1274 |
my $embeditems = shift || 0; |
|
|
1275 |
my $template = shift || 'intranet'; |
1276 |
my $withouthidden = shift || 0; |
1277 |
|
1263 |
my $dbh = C4::Context->dbh; |
1278 |
my $dbh = C4::Context->dbh; |
1264 |
my $sth = $dbh->prepare("SELECT marcxml FROM biblioitems WHERE biblionumber=? "); |
1279 |
my $sth = $dbh->prepare("SELECT marcxml FROM biblioitems WHERE biblionumber=? "); |
1265 |
$sth->execute($biblionumber); |
1280 |
$sth->execute($biblionumber); |
1266 |
my $row = $sth->fetchrow_hashref; |
1281 |
my $row = $sth->fetchrow_hashref; |
1267 |
my $marcxml = StripNonXmlChars( $row->{'marcxml'} ); |
1282 |
my $marcxml = StripNonXmlChars( $row->{'marcxml'} ); |
|
|
1283 |
return unless $marcxml; |
1284 |
|
1268 |
MARC::File::XML->default_record_format( C4::Context->preference('marcflavour') ); |
1285 |
MARC::File::XML->default_record_format( C4::Context->preference('marcflavour') ); |
1269 |
my $record = MARC::Record->new(); |
1286 |
my $record = MARC::Record->new(); |
|
|
1287 |
$record = eval { MARC::Record::new_from_xml( $marcxml, "utf8", C4::Context->preference('marcflavour') ) }; |
1288 |
if ($@) { warn " problem with :$biblionumber : $@ \n$marcxml"; } |
1289 |
return unless $record; |
1270 |
|
1290 |
|
1271 |
if ($marcxml) { |
1291 |
C4::Biblio::_koha_marc_update_bib_ids($record, '', $biblionumber, $biblionumber); |
1272 |
$record = eval { MARC::Record::new_from_xml( $marcxml, "utf8", C4::Context->preference('marcflavour') ) }; |
1292 |
C4::Biblio::EmbedItemsInMarcBiblio($record, $biblionumber) if ($embeditems); |
1273 |
if ($@) { warn " problem with :$biblionumber : $@ \n$marcxml"; } |
|
|
1274 |
return unless $record; |
1275 |
|
1276 |
C4::Biblio::_koha_marc_update_bib_ids($record, '', $biblionumber, $biblionumber); |
1277 |
C4::Biblio::EmbedItemsInMarcBiblio($record, $biblionumber) if ($embeditems); |
1278 |
|
1293 |
|
1279 |
return $record; |
1294 |
if ($withouthidden) { |
1280 |
} else { |
1295 |
my $frameworkcode = GetFrameworkCode( $biblionumber ); |
1281 |
return; |
1296 |
RemoveHiddenSubfields($record, $frameworkcode, $template); |
1282 |
} |
1297 |
} |
|
|
1298 |
|
1299 |
return $record; |
1300 |
} |
1301 |
|
1302 |
=head2 GetMarcBiblioForOpac |
1303 |
|
1304 |
my $record = GetMarcBiblioForOpac($biblionumber, [$embeditems]); |
1305 |
|
1306 |
Returns MARC::Record representing bib. If no bib exists, returns undef. |
1307 |
The record does not contain subfields hidden at OPAC. |
1308 |
|
1309 |
C<$biblionumber> - the biblionumber of the biblio |
1310 |
|
1311 |
C<$embeditems> - if set to true items data are included, default false |
1312 |
|
1313 |
=cut |
1314 |
|
1315 |
sub GetMarcBiblioForOpac { |
1316 |
my $biblionumber = shift; |
1317 |
my $embeditems = shift || 0; |
1318 |
return GetMarcBiblio($biblionumber, $embeditems, 'opac', 1); |
1283 |
} |
1319 |
} |
1284 |
|
1320 |
|
1285 |
=head2 GetXmlBiblio |
1321 |
=head2 GetXmlBiblio |
Lines 4002-4007
sub RemoveAllNsb {
Link Here
|
4002 |
return $record; |
4038 |
return $record; |
4003 |
} |
4039 |
} |
4004 |
|
4040 |
|
|
|
4041 |
=head2 RemoveHiddenSubfields |
4042 |
|
4043 |
RemoveHiddenSubfields( $biblionumber, [$frameworkcode], [$template] ); |
4044 |
|
4045 |
Removes from record all subfields marked as hidden. |
4046 |
|
4047 |
=cut |
4048 |
|
4049 |
sub RemoveHiddenSubfields { |
4050 |
my $record = shift; |
4051 |
my $frameworkcode = shift || ''; |
4052 |
my $template = shift || 'intranet'; |
4053 |
|
4054 |
my $tagslib = GetMarcStructure( 0, $frameworkcode ); |
4055 |
|
4056 |
foreach my $tag ( keys %$tagslib ) { |
4057 |
my @fields = $record->field($tag); |
4058 |
next unless @fields; |
4059 |
|
4060 |
my @subfields_to_remove; |
4061 |
foreach my $subfield ( keys %{ $tagslib->{$tag} } ) { |
4062 |
# skip tag infos |
4063 |
next unless ( ref( $tagslib->{$tag}->{$subfield} ) eq "HASH" ); |
4064 |
if ( $template eq 'opac' ) { |
4065 |
push @subfields_to_remove, $subfield |
4066 |
if $tagslib->{$tag}->{$subfield}->{'hidden'} > 0; |
4067 |
} |
4068 |
else { |
4069 |
push @subfields_to_remove, $subfield |
4070 |
if $tagslib->{$tag}->{$subfield}->{'hidden'} =~ |
4071 |
/-7|-4|-3|-2|2|3|5|8/; |
4072 |
} |
4073 |
} |
4074 |
if ( @subfields_to_remove ) { |
4075 |
foreach my $field (@fields) { |
4076 |
if ( $tag < 10 ) { |
4077 |
# control field so delete entire field |
4078 |
$record->delete_field($field); |
4079 |
} |
4080 |
else { |
4081 |
$field->delete_subfield( code => \@subfields_to_remove ); |
4082 |
# delete field if no subfield anymore |
4083 |
$record->delete_field($field) |
4084 |
unless ( $field->subfields() ); |
4085 |
} |
4086 |
} |
4087 |
} |
4088 |
} |
4089 |
} |
4090 |
|
4005 |
1; |
4091 |
1; |
4006 |
|
4092 |
|
4007 |
|
4093 |
|