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

(-)a/C4/Biblio.pm (-20 lines)
Lines 66-72 BEGIN { Link Here
66
        TransformHtmlToMarc
66
        TransformHtmlToMarc
67
        TransformHtmlToXml
67
        TransformHtmlToXml
68
        prepare_host_field
68
        prepare_host_field
69
        SplitKohaField
70
    );
69
    );
71
70
72
    # Internal functions
71
    # Internal functions
Lines 3420-3444 sub RemoveAllNsb { Link Here
3420
    return $record;
3419
    return $record;
3421
}
3420
}
3422
3421
3423
=head2 SplitKohaField
3424
3425
    $subtitles = SplitKohaField($biblio->subtitle());
3426
3427
Splits a Koha field with multiple values to an array. Multiple matches for a
3428
Koha field (according to the bibliographic framework) are concatenated with
3429
' | ', but in many cases it's not optimal for display and an array is
3430
preferred.
3431
3432
=cut
3433
3434
sub SplitKohaField {
3435
    my $field = shift;
3436
3437
    my @parts = split(/ \| /, $field // '' );
3438
3439
    return \@parts;
3440
}
3441
3442
1;
3422
1;
3443
3423
3444
3424
(-)a/catalogue/detail.pl (+1 lines)
Lines 78-83 my $biblionumber = $query->param('biblionumber'); Link Here
78
$biblionumber = HTML::Entities::encode($biblionumber);
78
$biblionumber = HTML::Entities::encode($biblionumber);
79
my $record       = GetMarcBiblio({ biblionumber => $biblionumber });
79
my $record       = GetMarcBiblio({ biblionumber => $biblionumber });
80
my $biblio = Koha::Biblios->find( $biblionumber );
80
my $biblio = Koha::Biblios->find( $biblionumber );
81
$template->param( 'biblio', $biblio );
81
82
82
if ( not defined $record ) {
83
if ( not defined $record ) {
83
    # biblionumber invalid -> report and exit
84
    # biblionumber invalid -> report and exit
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-title-head.inc (-1 / +12 lines)
Lines 7-10 Link Here
7
[% FOREACH subtitle IN biblio.subtitle.split(' \| ') %][% IF Koha.Preference('marcflavour')=='UNIMARC' %],[% END %]
7
[% FOREACH subtitle IN biblio.subtitle.split(' \| ') %][% IF Koha.Preference('marcflavour')=='UNIMARC' %],[% END %]
8
    [% subtitle | html %]
8
    [% subtitle | html %]
9
[% END %]
9
[% END %]
10
[% biblio.part_number | html %] [% biblio.part_name | html %]
10
[% part_numbers = biblio.part_number.split(' \\| ') %]
11
[% part_names = biblio.part_name.split(' \\| ') %]
12
[% i = 0 %]
13
[% WHILE ( part_numbers.$i.defined || part_names.$i.defined ) %]
14
    [% IF ( part_numbers.$i.defined ) %]
15
        [% part_numbers.$i | html %]
16
    [% END %]
17
    [% IF ( part_names.$i.defined ) %]
18
        [% part_names.$i | html %]
19
    [% END %]
20
    [% i = i + 1 %]
21
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-title.inc (-5 / +11 lines)
Lines 9-17 Link Here
9
[% FOREACH subtitle IN biblio.subtitle.split(' \\| ') %][% IF Koha.Preference('marcflavour')=='UNIMARC' %],[% END %]
9
[% FOREACH subtitle IN biblio.subtitle.split(' \\| ') %][% IF Koha.Preference('marcflavour')=='UNIMARC' %],[% END %]
10
    <span class="subtitle">[% subtitle | html %]</span>
10
    <span class="subtitle">[% subtitle | html %]</span>
11
[% END %]
11
[% END %]
12
[% IF ( biblio.part_number ) %]
12
[% part_numbers = biblio.part_number.split(' \\| ') %]
13
    <span class="part-number">[% biblio.part_number | html %]</span>
13
[% part_names = biblio.part_name.split(' \\| ') %]
14
[% END %]
14
[% i = 0 %]
15
[% IF ( biblio.part_name ) %]
15
[% WHILE ( part_numbers.$i.defined || part_names.$i.defined ) %]
16
    <span class="part-name">[% biblio.part_name | html %]</span>
16
    [% IF ( part_numbers.$i.defined ) %]
17
        <span class="part-number">[% part_numbers.$i | html %]</span>
18
    [% END %]
19
    [% IF ( part_names.$i.defined ) %]
20
        <span class="part-name">[% part_names.$i | html %]</span>
21
    [% END %]
22
    [% i = i + 1 %]
17
[% END %]
23
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-3 / +2 lines)
Lines 6-12 Link Here
6
[% USE Branches %]
6
[% USE Branches %]
7
[% USE Biblio %]
7
[% USE Biblio %]
8
[% USE ColumnsSettings %]
8
[% USE ColumnsSettings %]
9
[% USE Stash %]
10
[% SET AdlibrisEnabled = Koha.Preference('AdlibrisCoversEnabled') %]
9
[% SET AdlibrisEnabled = Koha.Preference('AdlibrisCoversEnabled') %]
11
[% SET AdlibrisURL = Koha.Preference('AdlibrisCoversURL') %]
10
[% SET AdlibrisURL = Koha.Preference('AdlibrisCoversURL') %]
12
11
Lines 35-41 Link Here
35
  [% IF ( unknownbiblionumber ) %]
34
  [% IF ( unknownbiblionumber ) %]
36
    Unknown record
35
    Unknown record
37
  [% ELSE %]
36
  [% ELSE %]
38
    Details for [% INCLUDE 'biblio-title-head.inc' biblio=Stash.stash() %]
37
    Details for [% INCLUDE 'biblio-title-head.inc' %]
39
  [% END %]
38
  [% END %]
40
</title>
39
</title>
41
[% INCLUDE 'doc-head-close.inc' %]
40
[% INCLUDE 'doc-head-close.inc' %]
Lines 50-56 Link Here
50
  [% IF ( unknownbiblionumber ) %]
49
  [% IF ( unknownbiblionumber ) %]
51
    Unknown record
50
    Unknown record
52
  [% ELSE %]
51
  [% ELSE %]
53
    Details for <i>[% INCLUDE 'biblio-title.inc' biblio=Stash.stash() %]</i>
52
    Details for <i>[% INCLUDE 'biblio-title.inc' %]</i>
54
  [% END %]
53
  [% END %]
55
</div>
54
</div>
56
55
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/biblio-title-head.inc (-1 / +12 lines)
Lines 6-9 Link Here
6
[% FOREACH subtitle IN biblio.subtitle.split(' \| ') %][% IF Koha.Preference('marcflavour')=='UNIMARC' %],[% END %]
6
[% FOREACH subtitle IN biblio.subtitle.split(' \| ') %][% IF Koha.Preference('marcflavour')=='UNIMARC' %],[% END %]
7
    [% subtitle | html %]
7
    [% subtitle | html %]
8
[% END %]
8
[% END %]
9
[% biblio.part_number | html %] [% biblio.part_name | html %]
9
[% part_numbers = biblio.part_number.split(' \\| ') %]
10
[% part_names = biblio.part_name.split(' \\| ') %]
11
[% i = 0 %]
12
[% WHILE ( part_numbers.$i.defined || part_names.$i.defined ) %]
13
    [% IF ( part_numbers.$i.defined ) %]
14
        [% part_numbers.$i | html %]
15
    [% END %]
16
    [% IF ( part_names.$i.defined ) %]
17
        [% part_names.$i | html %]
18
    [% END %]
19
    [% i = i + 1 %]
20
[% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/biblio-title.inc (-5 / +11 lines)
Lines 6-14 Link Here
6
[% FOREACH subtitle IN biblio.subtitle.split(' \| ') %][% IF Koha.Preference('marcflavour')=='UNIMARC' %],[% END %]
6
[% FOREACH subtitle IN biblio.subtitle.split(' \| ') %][% IF Koha.Preference('marcflavour')=='UNIMARC' %],[% END %]
7
    <span class="subtitle">[% subtitle | html %]</span>
7
    <span class="subtitle">[% subtitle | html %]</span>
8
[% END %]
8
[% END %]
9
[% IF ( biblio.part_number ) %]
9
[% part_numbers = biblio.part_number.split(' \\| ') %]
10
    <span class="part-number">[% biblio.part_number | html %]</span>
10
[% part_names = biblio.part_name.split(' \\| ') %]
11
[% END %]
11
[% i = 0 %]
12
[% IF ( biblio.part_name ) %]
12
[% WHILE ( part_numbers.$i.defined || part_names.$i.defined ) %]
13
    <span class="part-name">[% biblio.part_name | html %]</span>
13
    [% IF ( part_numbers.$i.defined ) %]
14
        <span class="part-number">[% part_numbers.$i | html %]</span>
15
    [% END %]
16
    [% IF ( part_names.$i.defined ) %]
17
        <span class="part-name">[% part_names.$i | html %]</span>
18
    [% END %]
19
    [% i = i + 1 %]
14
[% END %]
20
[% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt (-4 / +3 lines)
Lines 6-12 Link Here
6
[% USE Branches %]
6
[% USE Branches %]
7
[% USE ColumnsSettings %]
7
[% USE ColumnsSettings %]
8
[% USE AuthorisedValues %]
8
[% USE AuthorisedValues %]
9
[% USE Stash %]
10
[% SET TagsShowEnabled = ( ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsShowOnDetail ) %]
9
[% SET TagsShowEnabled = ( ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsShowOnDetail ) %]
11
[% SET TagsInputEnabled = ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsInputOnDetail ) %]
10
[% SET TagsInputEnabled = ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsInputOnDetail ) %]
12
[% IF Koha.Preference('AmazonAssocTag') %]
11
[% IF Koha.Preference('AmazonAssocTag') %]
Lines 31-37 Link Here
31
[% END %]
30
[% END %]
32
31
33
[% INCLUDE 'doc-head-open.inc' %]
32
[% INCLUDE 'doc-head-open.inc' %]
34
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo; Details for: [% INCLUDE 'biblio-title-head.inc' biblio=Stash.stash() %]</title>
33
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo; Details for: [% INCLUDE 'biblio-title-head.inc' %]</title>
35
[% INCLUDE 'doc-head-close.inc' %]
34
[% INCLUDE 'doc-head-close.inc' %]
36
    [% Asset.css("lib/emoji-picker/css/emoji.css") | $raw %]
35
    [% Asset.css("lib/emoji-picker/css/emoji.css") | $raw %]
37
</head>
36
</head>
Lines 42-48 Link Here
42
<div class="main">
41
<div class="main">
43
    <ul class="breadcrumb">
42
    <ul class="breadcrumb">
44
        <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
43
        <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
45
        <li><a href="#"><span>Details for: </span>[% INCLUDE 'biblio-title.inc' biblio=Stash.stash() %]</a></li>
44
        <li><a href="#"><span>Details for: </span>[% INCLUDE 'biblio-title.inc' %]</a></li>
46
    </ul>
45
    </ul>
47
46
48
    <div class="container-fluid">
47
    <div class="container-fluid">
Lines 113-119 Link Here
113
                    [% IF ( OPACXSLTDetailsDisplay ) %]
112
                    [% IF ( OPACXSLTDetailsDisplay ) %]
114
                        [% XSLTBloc | $raw %]
113
                        [% XSLTBloc | $raw %]
115
                    [% ELSE %]
114
                    [% ELSE %]
116
                        <h1 class="title">[% INCLUDE 'biblio-title.inc' biblio=Stash.stash() %]</h1>
115
                        <h1 class="title">[% INCLUDE 'biblio-title.inc' %]</h1>
117
                        [% IF ( author ) %]<h5 class="author">by <a href="/cgi-bin/koha/opac-search.pl?q=au:[% author |url %]">[% author | html %]</a></h5>[% END %]
116
                        [% IF ( author ) %]<h5 class="author">by <a href="/cgi-bin/koha/opac-search.pl?q=au:[% author |url %]">[% author | html %]</a></h5>[% END %]
118
117
119
                        <span class="results_summary">[% UNLESS ( item_level_itypes ) %]
118
                        <span class="results_summary">[% UNLESS ( item_level_itypes ) %]
(-)a/svc/checkouts (-1 / +2 lines)
Lines 174-183 while ( my $c = $sth->fetchrow_hashref() ) { Link Here
174
        my $av = Koha::AuthorisedValues->search({ category => 'DAMAGED', authorised_value => $c->{damaged} });
174
        my $av = Koha::AuthorisedValues->search({ category => 'DAMAGED', authorised_value => $c->{damaged} });
175
        $damaged = $av->count ? $av->next->lib : '';
175
        $damaged = $av->count ? $av->next->lib : '';
176
    }
176
    }
177
    my @subtitles = split(/ \| /, $c->{'subtitle'} // '' );
177
    my $checkout = {
178
    my $checkout = {
178
        DT_RowId             => $c->{itemnumber} . '-' . $c->{borrowernumber},
179
        DT_RowId             => $c->{itemnumber} . '-' . $c->{borrowernumber},
179
        title                => $c->{title},
180
        title                => $c->{title},
180
        subtitle             => C4::Biblio::SplitKohaField($c->{'subtitle'}),
181
        subtitle             => \@subtitles,
181
        medium               => $c->{medium} // '',
182
        medium               => $c->{medium} // '',
182
        part_number          => $c->{part_number} // '',
183
        part_number          => $c->{part_number} // '',
183
        part_name            => $c->{part_name} // '',
184
        part_name            => $c->{part_name} // '',
(-)a/svc/holds (-2 / +2 lines)
Lines 23-29 use CGI; Link Here
23
use JSON qw(to_json);
23
use JSON qw(to_json);
24
24
25
use C4::Auth qw(check_cookie_auth);
25
use C4::Auth qw(check_cookie_auth);
26
use C4::Biblio qw(SplitKohaField);
27
use C4::Charset;
26
use C4::Charset;
28
use C4::Circulation qw(GetTransfers);
27
use C4::Circulation qw(GetTransfers);
29
use C4::Context;
28
use C4::Context;
Lines 86-96 while ( my $h = $holds_rs->next() ) { Link Here
86
    }
85
    }
87
86
88
    my $biblio = $h->biblio();
87
    my $biblio = $h->biblio();
88
    my @subtitles = split(/ \| /, $biblio->subtitle() // '');
89
    my $hold = {
89
    my $hold = {
90
        DT_RowId       => $h->reserve_id(),
90
        DT_RowId       => $h->reserve_id(),
91
        biblionumber   => $biblionumber,
91
        biblionumber   => $biblionumber,
92
        title          => $biblio->title(),
92
        title          => $biblio->title(),
93
        subtitle       => C4::Biblio::SplitKohaField($biblio->subtitle()),
93
        subtitle       => \@subtitles,
94
        medium         => $biblio->medium() // '',
94
        medium         => $biblio->medium() // '',
95
        part_number    => $biblio->part_number() // '',
95
        part_number    => $biblio->part_number() // '',
96
        part_name      => $biblio->part_name() // '',
96
        part_name      => $biblio->part_name() // '',
(-)a/t/Biblio.t (-1 / +1 lines)
Lines 21-27 use Test::More; Link Here
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
24
plan tests => 45;
24
plan tests => 43;
25
25
26
use_ok('C4::Biblio');
26
use_ok('C4::Biblio');
27
27
(-)a/t/Biblio2.t (-17 lines)
Lines 52-71 sub _koha_marc_update_bib_ids_control { Link Here
52
    is($r->field('004')->data(), 20, 'Biblioitemnumber to control field');
52
    is($r->field('004')->data(), 20, 'Biblioitemnumber to control field');
53
}
53
}
54
54
55
subtest 'SplitKohaField' => sub {
56
    plan tests => 4;
57
58
    my $res = C4::Biblio::SplitKohaField(undef);
59
    is_deeply($res, [], 'undef returned as an array');
60
61
    $res = C4::Biblio::SplitKohaField('');
62
    is_deeply($res, [], 'Empty string returned as an array');
63
64
    $res = C4::Biblio::SplitKohaField('Single');
65
    is_deeply($res, ['Single'], 'Single subtitle returned as an array');
66
67
    $res = C4::Biblio::SplitKohaField('First | Second');
68
    is_deeply($res, ['First', 'Second'], 'Two subtitles returned as an array');
69
};
70
71
done_testing();
55
done_testing();
72
- 

Return to bug 11529