@@ -, +, @@
- Before the patch:
- After the patch:
- Before the patch:
- After the patch:
---
C4/Biblio.pm | 41 +++++++++++++++---
.../prog/en/modules/admin/preferences/opac.pref | 2 +-
opac/opac-ISBDdetail.pl | 5 ++-
opac/opac-MARCdetail.pl | 5 ++-
opac/opac-detail.pl | 7 ++-
t/db_dependent/Biblio.t | 44 +++++++++++++++++++-
6 files changed, 90 insertions(+), 14 deletions(-)
--- a/C4/Biblio.pm
+++ a/C4/Biblio.pm
@@ -70,6 +70,7 @@ BEGIN {
&GetMarcControlnumber
&GetMarcNotes
&GetMarcISBN
+ &GetMarcISSN
&GetMarcSubjects
&GetMarcBiblio
&GetMarcAuthors
@@ -1374,9 +1375,9 @@ Get the control number / record Identifier from the MARC record and return it.
sub GetMarcControlnumber {
my ( $record, $marcflavour ) = @_;
my $controlnumber = "";
- # Control number or Record identifier are the same field in MARC21 and UNIMARC
+ # Control number or Record identifier are the same field in MARC21, UNIMARC and NORMARC
# Keep $marcflavour for possible later use
- if ($marcflavour eq "MARC21" || $marcflavour eq "UNIMARC") {
+ if ($marcflavour eq "MARC21" || $marcflavour eq "UNIMARC" || $marcflavour eq "NORMARC") {
my $controlnumberField = $record->field('001');
if ($controlnumberField) {
$controlnumber = $controlnumberField->data();
@@ -1390,7 +1391,7 @@ sub GetMarcControlnumber {
$marcisbnsarray = GetMarcISBN( $record, $marcflavour );
Get all ISBNs from the MARC record and returns them in an array.
-ISBNs stored in differents places depending on MARC flavour
+ISBNs stored in different fields depending on MARC flavour
=cut
@@ -1425,12 +1426,38 @@ sub GetMarcISBN {
return \@marcisbns;
} # end GetMarcISBN
+
+=head2 GetMarcISSN
+
+ $marcissnsarray = GetMarcISSN( $record, $marcflavour );
+
+Get all valid ISSNs from the MARC record and returns them in an array.
+ISSNs are stored in different fields depending on MARC flavour
+
+=cut
+
+sub GetMarcISSN {
+ my ( $record, $marcflavour ) = @_;
+ my $scope;
+ if ( $marcflavour eq "UNIMARC" ) {
+ $scope = '011';
+ }
+ else { # assume MARC21 or NORMARC
+ $scope = '022';
+ }
+ my @marcissns;
+ foreach my $field ( $record->field($scope) ) {
+ push @marcissns, $field->subfield( 'a' );
+ }
+ return \@marcissns;
+} # end GetMarcISSN
+
=head2 GetMarcNotes
$marcnotesarray = GetMarcNotes( $record, $marcflavour );
Get all notes from the MARC record and returns them in an array.
-The note are stored in differents places depending on MARC flavour
+The note are stored in different fields depending on MARC flavour
=cut
@@ -1470,7 +1497,7 @@ sub GetMarcNotes {
$marcsubjcts = GetMarcSubjects($record,$marcflavour);
Get all subjects from the MARC record and returns them in an array.
-The subjects are stored in differents places depending on MARC flavour
+The subjects are stored in different fields depending on MARC flavour
=cut
@@ -1545,7 +1572,7 @@ sub GetMarcSubjects {
authors = GetMarcAuthors($record,$marcflavour);
Get all authors from the MARC record and returns them in an array.
-The authors are stored in differents places depending on MARC flavour
+The authors are stored in different fields depending on MARC flavour
=cut
@@ -1682,7 +1709,7 @@ sub GetMarcUrls {
$marcseriesarray = GetMarcSeries($record,$marcflavour);
Get all series from the MARC record and returns them in an array.
-The series are stored in differents places depending on MARC flavour
+The series are stored in different fields depending on MARC flavour
=cut
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
@@ -173,7 +173,7 @@ OPAC:
class: code
-
- 'Include a "More Searches" box on the detail pages of items on the OPAC, with the following HTML (leave blank to disable):'
- - '
Note: The placeholders {BIBLIONUMBER}, {CONTROLNUMBER}, {TITLE}, {ISBN} and {AUTHOR} will be replaced with information from the displayed record.'
+ - '
Note: The placeholders {BIBLIONUMBER}, {CONTROLNUMBER}, {TITLE}, {ISBN}, {ISSN} and {AUTHOR} will be replaced with information from the displayed record.'
- pref: OPACSearchForTitleIn
type: textarea
class: code
--- a/opac/opac-ISBDdetail.pl
+++ a/opac/opac-ISBDdetail.pl
@@ -165,7 +165,9 @@ my @export_options = split(/\|/,$OpacExportOptions);
$template->{VARS}->{'export_options'} = \@export_options;
#Search for title in links
-my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
+my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
+my $marcissns = GetMarcISSN ( $record, $marcflavour );
+my $issn = $marcissns->[0] || '';
if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
$dat->{author} ? $search_for_title =~ s/{AUTHOR}/$dat->{author}/g : $search_for_title =~ s/{AUTHOR}//g;
@@ -173,6 +175,7 @@ if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
$dat->{title} =~ s/\s+$//; # remove trailing space
$dat->{title} ? $search_for_title =~ s/{TITLE}/$dat->{title}/g : $search_for_title =~ s/{TITLE}//g;
$isbn ? $search_for_title =~ s/{ISBN}/$isbn/g : $search_for_title =~ s/{ISBN}//g;
+ $issn ? $search_for_title =~ s/{ISSN}/$issn/g : $search_for_title =~ s/{ISSN}//g;
$marccontrolnumber ? $search_for_title =~ s/{CONTROLNUMBER}/$marccontrolnumber/g : $search_for_title =~ s/{CONTROLNUMBER}//g;
$search_for_title =~ s/{BIBLIONUMBER}/$biblionumber/g;
$template->param('OPACSearchForTitleIn' => $search_for_title);
--- a/opac/opac-MARCdetail.pl
+++ a/opac/opac-MARCdetail.pl
@@ -279,7 +279,9 @@ $template->{VARS}->{'export_options'} = \@export_options;
my $marcflavour = C4::Context->preference("marcflavour");
my $dat = TransformMarcToKoha( $dbh, $record );
my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
-my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
+my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
+my $marcissns = GetMarcISSN( $record, $marcflavour );
+my $issn = $marcissns->[0] || '';
if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
$dat->{author} ? $search_for_title =~ s/{AUTHOR}/$dat->{author}/g : $search_for_title =~ s/{AUTHOR}//g;
@@ -287,6 +289,7 @@ if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
$dat->{title} =~ s/\s+$//; # remove trailing space
$dat->{title} ? $search_for_title =~ s/{TITLE}/$dat->{title}/g : $search_for_title =~ s/{TITLE}//g;
$isbn ? $search_for_title =~ s/{ISBN}/$isbn/g : $search_for_title =~ s/{ISBN}//g;
+ $issn ? $search_for_title =~ s/{ISSN}/$issn/g : $search_for_title =~ s/{ISSN}//g;
$marccontrolnumber ? $search_for_title =~ s/{CONTROLNUMBER}/$marccontrolnumber/g : $search_for_title =~ s/{CONTROLNUMBER}//g;
$search_for_title =~ s/{BIBLIONUMBER}/$biblionumber/g;
$template->param('OPACSearchForTitleIn' => $search_for_title);
--- a/opac/opac-detail.pl
+++ a/opac/opac-detail.pl
@@ -896,7 +896,9 @@ my @export_options = split(/\|/,$OpacExportOptions);
$template->{VARS}->{'export_options'} = \@export_options;
#Search for title in links
-my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
+my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
+my $marcissns = GetMarcISSN ( $record, $marcflavour );
+my $issn = $marcissns->[0] || '';
if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
$dat->{author} ? $search_for_title =~ s/{AUTHOR}/$dat->{author}/g : $search_for_title =~ s/{AUTHOR}//g;
@@ -904,9 +906,10 @@ if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
$dat->{title} =~ s/\s+$//; # remove trailing space
$dat->{title} ? $search_for_title =~ s/{TITLE}/$dat->{title}/g : $search_for_title =~ s/{TITLE}//g;
$isbn ? $search_for_title =~ s/{ISBN}/$isbn/g : $search_for_title =~ s/{ISBN}//g;
+ $issn ? $search_for_title =~ s/{ISSN}/$issn/g : $search_for_title =~ s/{ISSN}//g;
$marccontrolnumber ? $search_for_title =~ s/{CONTROLNUMBER}/$marccontrolnumber/g : $search_for_title =~ s/{CONTROLNUMBER}//g;
$search_for_title =~ s/{BIBLIONUMBER}/$biblionumber/g;
- $template->param('OPACSearchForTitleIn' => $search_for_title);
+ $template->param('OPACSearchForTitleIn' => $search_for_title);
}
# We try to select the best default tab to show, according to what
--- a/t/db_dependent/Biblio.t
+++ a/t/db_dependent/Biblio.t
@@ -5,12 +5,12 @@
use strict;
use warnings;
-use Test::More tests => 9;
+use Test::More tests => 17;
use MARC::Record;
use C4::Biblio;
BEGIN {
- use_ok('C4::Biblio');
+ use_ok('C4::Biblio');
}
my $isbn = '0590353403';
@@ -69,5 +69,45 @@ eval {
};
ok($success, "ModBiblio handles 655 with no subfields");
+# Testing GetMarcISSN
+my $issns;
+$issns = GetMarcISSN( $marc_record, 'MARC21' );
+is( $issns->[0], undef,
+ 'GetMarcISSN handles records without 022 (list is empty)' );
+is( scalar @$issns, 0, 'GetMarcISSN handles records without 022 (number of elements correct)' );
+
+my $issn = '1234-1234';
+$field = MARC::Field->new( '022', '', '', 'a', => $issn );
+$marc_record->append_fields($field);
+$issns = GetMarcISSN( $marc_record, 'MARC21' );
+is( $issns->[0], $issn,
+ 'GetMarcISSN handles records with single 022 (first element is correct)' );
+is( scalar @$issns, 1, 'GetMARCISSN handles records with single 022 (number of elements correct)'
+);
+
+my @more_issns = qw/1111-1111 2222-2222 3333-3333/;
+foreach (@more_issns) {
+ $field = MARC::Field->new( '022', '', '', 'a', => $_ );
+ $marc_record->append_fields($field);
+}
+$issns = GetMarcISSN( $marc_record, 'MARC21' );
+is( scalar @$issns, 4, 'GetMARCISSN handles records with multiple 022 (number of elements correct)'
+);
+
+# Testing GetMarcControlnumber
+my $controlnumber;
+$controlnumber = GetMarcControlnumber( $marc_record, 'MARC21' );
+is( $controlnumber, '', 'GetMarcControlnumber handles records without 001' );
+
+$field = MARC::Field->new( '001', '' );
+$marc_record->append_fields($field);
+$controlnumber = GetMarcControlnumber( $marc_record, 'MARC21' );
+is( $controlnumber, '', 'GetMarcControlnumber handles records with empty 001' );
+
+$field = $marc_record->field('001');
+$field->update('123456789X');
+$controlnumber = GetMarcControlnumber( $marc_record, 'MARC21' );
+is( $controlnumber, '123456789X', 'GetMarcControlnumber handles records with 001' );
+
# clean up after ourselves
DelBiblio($biblionumber);
--