View | Details | Raw Unified | Return to bug 7576
Collapse All | Expand All

(-)a/C4/Biblio.pm (-2 / +29 lines)
Lines 70-75 BEGIN { Link Here
70
      &GetMarcControlnumber
70
      &GetMarcControlnumber
71
      &GetMarcNotes
71
      &GetMarcNotes
72
      &GetMarcISBN
72
      &GetMarcISBN
73
      &GetMarcISSN
73
      &GetMarcSubjects
74
      &GetMarcSubjects
74
      &GetMarcBiblio
75
      &GetMarcBiblio
75
      &GetMarcAuthors
76
      &GetMarcAuthors
Lines 1374-1382 Get the control number / record Identifier from the MARC record and return it. Link Here
1374
sub GetMarcControlnumber {
1375
sub GetMarcControlnumber {
1375
    my ( $record, $marcflavour ) = @_;
1376
    my ( $record, $marcflavour ) = @_;
1376
    my $controlnumber = "";
1377
    my $controlnumber = "";
1377
    # Control number or Record identifier are the same field in MARC21 and UNIMARC
1378
    # Control number or Record identifier are the same field in MARC21, UNIMARC and NORMARC
1378
    # Keep $marcflavour for possible later use
1379
    # Keep $marcflavour for possible later use
1379
    if ($marcflavour eq "MARC21" || $marcflavour eq "UNIMARC") {
1380
    if ($marcflavour eq "MARC21" || $marcflavour eq "UNIMARC" || $marcflavour eq "NORMARC") {
1380
        my $controlnumberField = $record->field('001');
1381
        my $controlnumberField = $record->field('001');
1381
        if ($controlnumberField) {
1382
        if ($controlnumberField) {
1382
            $controlnumber = $controlnumberField->data();
1383
            $controlnumber = $controlnumberField->data();
Lines 1425-1430 sub GetMarcISBN { Link Here
1425
    return \@marcisbns;
1426
    return \@marcisbns;
1426
}    # end GetMarcISBN
1427
}    # end GetMarcISBN
1427
1428
1429
1430
=head2 GetMarcISSN
1431
1432
  $marcissnsarray = GetMarcISSN( $record, $marcflavour );
1433
1434
Get all valid ISSNs from the MARC record and returns them in an array.
1435
ISSNs are stored in differents fields and subfields depending on MARC flavour
1436
1437
=cut
1438
1439
sub GetMarcISSN {
1440
    my ( $record, $marcflavour ) = @_;
1441
    my $scope;
1442
    if ( $marcflavour eq "UNIMARC" ) {
1443
        $scope = '011';
1444
    }
1445
    else {    # assume MARC21 or NORMARC
1446
        $scope = '022';
1447
    }
1448
    my @marcissns;
1449
    foreach my $field ( $record->field($scope) ) {
1450
        push @marcissns, $field->subfield( 'a' );
1451
    }   
1452
    return \@marcissns;
1453
}    # end GetMarcISSN
1454
1428
=head2 GetMarcNotes
1455
=head2 GetMarcNotes
1429
1456
1430
  $marcnotesarray = GetMarcNotes( $record, $marcflavour );
1457
  $marcnotesarray = GetMarcNotes( $record, $marcflavour );
(-)a/opac/opac-ISBDdetail.pl (-1 / +4 lines)
Lines 165-171 my @export_options = split(/\|/,$OpacExportOptions); Link Here
165
$template->{VARS}->{'export_options'} = \@export_options;
165
$template->{VARS}->{'export_options'} = \@export_options;
166
166
167
#Search for title in links
167
#Search for title in links
168
my $marccontrolnumber   = GetMarcControlnumber   ($record, $marcflavour);
168
my $marccontrolnumber   = GetMarcControlnumber ($record, $marcflavour);
169
my $marcissns = GetMarcISSN ( $record, $marcflavour ); 
170
my $issn = $marcissns->[0] || '';
169
171
170
if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
172
if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
171
    $dat->{author} ? $search_for_title =~ s/{AUTHOR}/$dat->{author}/g : $search_for_title =~ s/{AUTHOR}//g;
173
    $dat->{author} ? $search_for_title =~ s/{AUTHOR}/$dat->{author}/g : $search_for_title =~ s/{AUTHOR}//g;
Lines 173-178 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){ Link Here
173
    $dat->{title} =~ s/\s+$//; # remove trailing space
175
    $dat->{title} =~ s/\s+$//; # remove trailing space
174
    $dat->{title} ? $search_for_title =~ s/{TITLE}/$dat->{title}/g : $search_for_title =~ s/{TITLE}//g;
176
    $dat->{title} ? $search_for_title =~ s/{TITLE}/$dat->{title}/g : $search_for_title =~ s/{TITLE}//g;
175
    $isbn ? $search_for_title =~ s/{ISBN}/$isbn/g : $search_for_title =~ s/{ISBN}//g;
177
    $isbn ? $search_for_title =~ s/{ISBN}/$isbn/g : $search_for_title =~ s/{ISBN}//g;
178
    $issn ? $search_for_title =~ s/{ISSN}/$issn/g : $search_for_title =~ s/{ISSN}//g;
176
    $marccontrolnumber ? $search_for_title =~ s/{CONTROLNUMBER}/$marccontrolnumber/g : $search_for_title =~ s/{CONTROLNUMBER}//g;
179
    $marccontrolnumber ? $search_for_title =~ s/{CONTROLNUMBER}/$marccontrolnumber/g : $search_for_title =~ s/{CONTROLNUMBER}//g;
177
    $search_for_title =~ s/{BIBLIONUMBER}/$biblionumber/g;
180
    $search_for_title =~ s/{BIBLIONUMBER}/$biblionumber/g;
178
 $template->param('OPACSearchForTitleIn' => $search_for_title);
181
 $template->param('OPACSearchForTitleIn' => $search_for_title);
(-)a/opac/opac-MARCdetail.pl (-1 / +4 lines)
Lines 279-285 $template->{VARS}->{'export_options'} = \@export_options; Link Here
279
my $marcflavour  = C4::Context->preference("marcflavour");
279
my $marcflavour  = C4::Context->preference("marcflavour");
280
my $dat = TransformMarcToKoha( $dbh, $record );
280
my $dat = TransformMarcToKoha( $dbh, $record );
281
my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
281
my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
282
my $marccontrolnumber   = GetMarcControlnumber   ($record, $marcflavour);
282
my $marccontrolnumber   = GetMarcControlnumber ($record, $marcflavour);
283
my $marcissns = GetMarcISSN( $record, $marcflavour );
284
my $issn = $marcissns->[0] || '';
283
285
284
if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
286
if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
285
    $dat->{author} ? $search_for_title =~ s/{AUTHOR}/$dat->{author}/g : $search_for_title =~ s/{AUTHOR}//g;
287
    $dat->{author} ? $search_for_title =~ s/{AUTHOR}/$dat->{author}/g : $search_for_title =~ s/{AUTHOR}//g;
Lines 287-292 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){ Link Here
287
    $dat->{title} =~ s/\s+$//; # remove trailing space
289
    $dat->{title} =~ s/\s+$//; # remove trailing space
288
    $dat->{title} ? $search_for_title =~ s/{TITLE}/$dat->{title}/g : $search_for_title =~ s/{TITLE}//g;
290
    $dat->{title} ? $search_for_title =~ s/{TITLE}/$dat->{title}/g : $search_for_title =~ s/{TITLE}//g;
289
    $isbn ? $search_for_title =~ s/{ISBN}/$isbn/g : $search_for_title =~ s/{ISBN}//g;
291
    $isbn ? $search_for_title =~ s/{ISBN}/$isbn/g : $search_for_title =~ s/{ISBN}//g;
292
    $issn ? $search_for_title =~ s/{ISSN}/$issn/g : $search_for_title =~ s/{ISSN}//g;
290
    $marccontrolnumber ? $search_for_title =~ s/{CONTROLNUMBER}/$marccontrolnumber/g : $search_for_title =~ s/{CONTROLNUMBER}//g;
293
    $marccontrolnumber ? $search_for_title =~ s/{CONTROLNUMBER}/$marccontrolnumber/g : $search_for_title =~ s/{CONTROLNUMBER}//g;
291
    $search_for_title =~ s/{BIBLIONUMBER}/$biblionumber/g;
294
    $search_for_title =~ s/{BIBLIONUMBER}/$biblionumber/g;
292
 $template->param('OPACSearchForTitleIn' => $search_for_title);
295
 $template->param('OPACSearchForTitleIn' => $search_for_title);
(-)a/opac/opac-detail.pl (-2 / +5 lines)
Lines 896-902 my @export_options = split(/\|/,$OpacExportOptions); Link Here
896
$template->{VARS}->{'export_options'} = \@export_options;
896
$template->{VARS}->{'export_options'} = \@export_options;
897
897
898
#Search for title in links
898
#Search for title in links
899
my $marccontrolnumber   = GetMarcControlnumber   ($record, $marcflavour);
899
my $marccontrolnumber   = GetMarcControlnumber ($record, $marcflavour);
900
my $marcissns = GetMarcISSN ( $record, $marcflavour ); 
901
my $issn = $marcissns->[0] || '';
900
902
901
if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
903
if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
902
    $dat->{author} ? $search_for_title =~ s/{AUTHOR}/$dat->{author}/g : $search_for_title =~ s/{AUTHOR}//g;
904
    $dat->{author} ? $search_for_title =~ s/{AUTHOR}/$dat->{author}/g : $search_for_title =~ s/{AUTHOR}//g;
Lines 904-912 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){ Link Here
904
    $dat->{title} =~ s/\s+$//; # remove trailing space
906
    $dat->{title} =~ s/\s+$//; # remove trailing space
905
    $dat->{title} ? $search_for_title =~ s/{TITLE}/$dat->{title}/g : $search_for_title =~ s/{TITLE}//g;
907
    $dat->{title} ? $search_for_title =~ s/{TITLE}/$dat->{title}/g : $search_for_title =~ s/{TITLE}//g;
906
    $isbn ? $search_for_title =~ s/{ISBN}/$isbn/g : $search_for_title =~ s/{ISBN}//g;
908
    $isbn ? $search_for_title =~ s/{ISBN}/$isbn/g : $search_for_title =~ s/{ISBN}//g;
909
    $issn ? $search_for_title =~ s/{ISSN}/$issn/g : $search_for_title =~ s/{ISSN}//g;
907
    $marccontrolnumber ? $search_for_title =~ s/{CONTROLNUMBER}/$marccontrolnumber/g : $search_for_title =~ s/{CONTROLNUMBER}//g;
910
    $marccontrolnumber ? $search_for_title =~ s/{CONTROLNUMBER}/$marccontrolnumber/g : $search_for_title =~ s/{CONTROLNUMBER}//g;
908
    $search_for_title =~ s/{BIBLIONUMBER}/$biblionumber/g;
911
    $search_for_title =~ s/{BIBLIONUMBER}/$biblionumber/g;
909
 $template->param('OPACSearchForTitleIn' => $search_for_title);
912
    $template->param('OPACSearchForTitleIn' => $search_for_title);
910
}
913
}
911
914
912
# We try to select the best default tab to show, according to what
915
# We try to select the best default tab to show, according to what
(-)a/t/db_dependent/Biblio.t (-3 / +42 lines)
Lines 5-16 Link Here
5
5
6
use strict;
6
use strict;
7
use warnings;
7
use warnings;
8
use Test::More tests => 9;
8
use Test::More tests => 17;
9
use MARC::Record;
9
use MARC::Record;
10
use C4::Biblio;
10
use C4::Biblio;
11
11
12
BEGIN {
12
BEGIN {
13
	use_ok('C4::Biblio');
13
    use_ok('C4::Biblio');
14
}
14
}
15
15
16
my $isbn = '0590353403';
16
my $isbn = '0590353403';
Lines 69-73 eval { Link Here
69
};
69
};
70
ok($success, "ModBiblio handles 655 with no subfields");
70
ok($success, "ModBiblio handles 655 with no subfields");
71
71
72
# Testing GetMarcISSN
73
my $issns;
74
$issns = GetMarcISSN( $marc_record, 'MARC21' );
75
is( $issns->[0], undef,
76
    'GetMarcISSN handles records without 022 (list is empty)' );
77
is( scalar @$issns, 0, 'GetMarcISSN handles records without 022 (number of elements correct)' );
78
79
my $issn = '1234-1234';
80
$field = MARC::Field->new( '022', '', '', 'a', => $issn );
81
$marc_record->append_fields($field);
82
$issns = GetMarcISSN( $marc_record, 'MARC21' );
83
is( $issns->[0], $issn,
84
    'GetMarcISSN handles records with single 022 (first element is correct)' );
85
is( scalar @$issns, 1, 'GetMARCISSN handles records with single 022 (number of elements correct)'
86
);
87
88
my @more_issns = qw/1111-1111 2222-2222 3333-3333/;
89
foreach (@more_issns) {
90
    $field = MARC::Field->new( '022', '', '', 'a', => $_ );
91
    $marc_record->append_fields($field);
92
}
93
$issns = GetMarcISSN( $marc_record, 'MARC21' );
94
is( scalar @$issns, 4, 'GetMARCISSN handles records with multiple 022 (number of elements correct)'
95
);
96
97
# Testing GetMarcControlnumber
98
my $controlnumber;
99
$controlnumber = GetMarcControlnumber( $marc_record, 'MARC21' );
100
is( $controlnumber, '', 'GetMarcControlnumber handles records without 001' );
101
102
$field = MARC::Field->new( '001', '' );
103
$marc_record->append_fields($field);
104
$controlnumber = GetMarcControlnumber( $marc_record, 'MARC21' );
105
is( $controlnumber, '', 'GetMarcControlnumber handles records with empty 001' );
106
107
$field = $marc_record->field('001');
108
$field->update('123456789X');
109
$controlnumber = GetMarcControlnumber( $marc_record, 'MARC21' );
110
is( $controlnumber, '123456789X', 'GetMarcControlnumber handles records with 001' );
111
72
# clean up after ourselves
112
# clean up after ourselves
73
DelBiblio($biblionumber);
113
DelBiblio($biblionumber);
74
- 

Return to bug 7576