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 |
&TransformHtmlToXml |
138 |
&TransformHtmlToXml |
138 |
&GetNoZebraIndexes |
139 |
&GetNoZebraIndexes |
139 |
prepare_host_field |
140 |
prepare_host_field |
|
|
141 |
&RemoveHiddenSubfields |
140 |
); |
142 |
); |
141 |
} |
143 |
} |
142 |
|
144 |
|
Lines 916-931
sub GetBiblioFromItemNumber {
Link Here
|
916 |
|
918 |
|
917 |
=head2 GetISBDView |
919 |
=head2 GetISBDView |
918 |
|
920 |
|
919 |
$isbd = &GetISBDView($biblionumber); |
921 |
$isbd = &GetISBDView($biblionumber, [$template]); |
920 |
|
922 |
|
921 |
Return the ISBD view which can be included in opac and intranet |
923 |
Returns the ISBD view which can be included in opac and intranet. |
|
|
924 |
|
925 |
C<$template> - 'opac' or 'intranet', default 'intranet' |
922 |
|
926 |
|
923 |
=cut |
927 |
=cut |
924 |
|
928 |
|
925 |
sub GetISBDView { |
929 |
sub GetISBDView { |
926 |
my ( $biblionumber, $template ) = @_; |
930 |
my $biblionumber = shift; |
927 |
my $record = GetMarcBiblio($biblionumber, 1); |
931 |
my $template = shift || 'intranet'; |
|
|
932 |
|
933 |
my $record = ($template eq 'opac') ? GetMarcBiblioForOpac($biblionumber, 1) : GetMarcBiblio($biblionumber, 1); |
928 |
return unless defined $record; |
934 |
return unless defined $record; |
|
|
935 |
|
929 |
my $itemtype = &GetFrameworkCode($biblionumber); |
936 |
my $itemtype = &GetFrameworkCode($biblionumber); |
930 |
my ( $holdingbrtagf, $holdingbrtagsubf ) = &GetMarcFromKohaField( "items.holdingbranch", $itemtype ); |
937 |
my ( $holdingbrtagf, $holdingbrtagsubf ) = &GetMarcFromKohaField( "items.holdingbranch", $itemtype ); |
931 |
my $tagslib = &GetMarcStructure( 1, $itemtype ); |
938 |
my $tagslib = &GetMarcStructure( 1, $itemtype ); |
Lines 1216-1253
sub GetMarcFromKohaField {
Link Here
|
1216 |
|
1223 |
|
1217 |
=head2 GetMarcBiblio |
1224 |
=head2 GetMarcBiblio |
1218 |
|
1225 |
|
1219 |
my $record = GetMarcBiblio($biblionumber, [$embeditems]); |
1226 |
my $record = GetMarcBiblio($biblionumber, [$embeditems], [$template], [$withouthidden]); |
|
|
1227 |
|
1228 |
Returns MARC::Record representing bib. If no bib exists, returns undef. |
1229 |
|
1230 |
C<$biblionumber> - the biblionumber of the biblio |
1220 |
|
1231 |
|
1221 |
Returns MARC::Record representing bib identified by |
1232 |
C<$embeditems> - if set to true items data are included, default false |
1222 |
C<$biblionumber>. If no bib exists, returns undef. |
1233 |
|
1223 |
C<$embeditems>. If set to true, items data are included. |
1234 |
C<$template> - 'opac' or 'intranet', default 'intranet' |
1224 |
The MARC record contains biblio data, and items data if $embeditems is set to true. |
1235 |
|
|
|
1236 |
C<$withouthidden> - if set to true hidden subfields are not included, default false |
1225 |
|
1237 |
|
1226 |
=cut |
1238 |
=cut |
1227 |
|
1239 |
|
1228 |
sub GetMarcBiblio { |
1240 |
sub GetMarcBiblio { |
1229 |
my $biblionumber = shift; |
1241 |
my $biblionumber = shift; |
1230 |
my $embeditems = shift || 0; |
1242 |
my $embeditems = shift || 0; |
|
|
1243 |
my $template = shift || 'intranet'; |
1244 |
my $withouthidden = shift || 0; |
1245 |
|
1231 |
my $dbh = C4::Context->dbh; |
1246 |
my $dbh = C4::Context->dbh; |
1232 |
my $sth = $dbh->prepare("SELECT marcxml FROM biblioitems WHERE biblionumber=? "); |
1247 |
my $sth = $dbh->prepare("SELECT marcxml FROM biblioitems WHERE biblionumber=? "); |
1233 |
$sth->execute($biblionumber); |
1248 |
$sth->execute($biblionumber); |
1234 |
my $row = $sth->fetchrow_hashref; |
1249 |
my $row = $sth->fetchrow_hashref; |
1235 |
my $marcxml = StripNonXmlChars( $row->{'marcxml'} ); |
1250 |
my $marcxml = StripNonXmlChars( $row->{'marcxml'} ); |
|
|
1251 |
return unless $marcxml; |
1252 |
|
1236 |
MARC::File::XML->default_record_format( C4::Context->preference('marcflavour') ); |
1253 |
MARC::File::XML->default_record_format( C4::Context->preference('marcflavour') ); |
1237 |
my $record = MARC::Record->new(); |
1254 |
my $record = MARC::Record->new(); |
|
|
1255 |
$record = eval { MARC::Record::new_from_xml( $marcxml, "utf8", C4::Context->preference('marcflavour') ) }; |
1256 |
if ($@) { warn " problem with :$biblionumber : $@ \n$marcxml"; } |
1257 |
return unless $record; |
1238 |
|
1258 |
|
1239 |
if ($marcxml) { |
1259 |
C4::Biblio::_koha_marc_update_bib_ids($record, '', $biblionumber, $biblionumber); |
1240 |
$record = eval { MARC::Record::new_from_xml( $marcxml, "utf8", C4::Context->preference('marcflavour') ) }; |
1260 |
C4::Biblio::EmbedItemsInMarcBiblio($record, $biblionumber) if ($embeditems); |
1241 |
if ($@) { warn " problem with :$biblionumber : $@ \n$marcxml"; } |
|
|
1242 |
return unless $record; |
1243 |
|
1244 |
C4::Biblio::_koha_marc_update_bib_ids($record, '', $biblionumber, $biblionumber); |
1245 |
C4::Biblio::EmbedItemsInMarcBiblio($record, $biblionumber) if ($embeditems); |
1246 |
|
1261 |
|
1247 |
return $record; |
1262 |
if ($withouthidden) { |
1248 |
} else { |
1263 |
my $frameworkcode = GetFrameworkCode( $biblionumber ); |
1249 |
return; |
1264 |
RemoveHiddenSubfields($record, $frameworkcode, $template); |
1250 |
} |
1265 |
} |
|
|
1266 |
|
1267 |
return $record; |
1268 |
} |
1269 |
|
1270 |
=head2 GetMarcBiblioForOpac |
1271 |
|
1272 |
my $record = GetMarcBiblioForOpac($biblionumber, [$embeditems]); |
1273 |
|
1274 |
Returns MARC::Record representing bib. If no bib exists, returns undef. |
1275 |
The record does not contain subfields hidden at OPAC. |
1276 |
|
1277 |
C<$biblionumber> - the biblionumber of the biblio |
1278 |
|
1279 |
C<$embeditems> - if set to true items data are included, default false |
1280 |
|
1281 |
=cut |
1282 |
sub GetMarcBiblioForOpac { |
1283 |
my $biblionumber = shift; |
1284 |
my $embeditems = shift || 0; |
1285 |
return GetMarcBiblio($biblionumber, $embeditems, 'opac', 1); |
1251 |
} |
1286 |
} |
1252 |
|
1287 |
|
1253 |
=head2 GetXmlBiblio |
1288 |
=head2 GetXmlBiblio |
Lines 3963-3968
sub RemoveAllNsb {
Link Here
|
3963 |
return $record; |
3998 |
return $record; |
3964 |
} |
3999 |
} |
3965 |
|
4000 |
|
|
|
4001 |
=head2 RemoveHiddenSubfields |
4002 |
|
4003 |
RemoveHiddenSubfields( $biblionumber, [$frameworkcode], [$template] ); |
4004 |
|
4005 |
Removes from record all subfields marked as hidden. |
4006 |
|
4007 |
=cut |
4008 |
|
4009 |
sub RemoveHiddenSubfields { |
4010 |
my $record = shift; |
4011 |
my $frameworkcode = shift || ''; |
4012 |
my $template = shift || 'intranet'; |
4013 |
|
4014 |
my $tagslib = GetMarcStructure( 0, $frameworkcode ); |
4015 |
|
4016 |
foreach my $tag ( keys %$tagslib ) { |
4017 |
my @fields = $record->field($tag); |
4018 |
next unless @fields; |
4019 |
|
4020 |
my @subfields_to_remove; |
4021 |
foreach my $subfield ( keys %{ $tagslib->{$tag} } ) { |
4022 |
# skip tag infos |
4023 |
next unless ( ref( $tagslib->{$tag}->{$subfield} ) eq "HASH" ); |
4024 |
if ( $template eq 'opac' ) { |
4025 |
push @subfields_to_remove, $subfield |
4026 |
if $tagslib->{$tag}->{$subfield}->{'hidden'} > 0; |
4027 |
} |
4028 |
else { |
4029 |
push @subfields_to_remove, $subfield |
4030 |
if $tagslib->{$tag}->{$subfield}->{'hidden'} =~ |
4031 |
/-7|-4|-3|-2|2|3|5|8/; |
4032 |
} |
4033 |
} |
4034 |
if ( @subfields_to_remove ) { |
4035 |
foreach my $field (@fields) { |
4036 |
if ( $tag < 10 ) { |
4037 |
# control field so delete entire field |
4038 |
$record->delete_field($field); |
4039 |
} |
4040 |
else { |
4041 |
$field->delete_subfield( code => \@subfields_to_remove ); |
4042 |
# delete field if no subfield anymore |
4043 |
$record->delete_field($field) |
4044 |
unless ( $field->subfields() ); |
4045 |
} |
4046 |
} |
4047 |
} |
4048 |
} |
4049 |
} |
4050 |
|
3966 |
1; |
4051 |
1; |
3967 |
|
4052 |
|
3968 |
|
4053 |
|