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

(-)a/C4/Breeding.pm (-3 / +54 lines)
Lines 25-30 use C4::Biblio; Link Here
25
use C4::Koha;
25
use C4::Koha;
26
use C4::Charset;
26
use C4::Charset;
27
use MARC::File::USMARC;
27
use MARC::File::USMARC;
28
use MARC::Field;
28
use C4::ImportBatch;
29
use C4::ImportBatch;
29
use C4::AuthoritiesMarc; #GuessAuthTypeCode, FindDuplicateAuthority
30
use C4::AuthoritiesMarc; #GuessAuthTypeCode, FindDuplicateAuthority
30
use C4::Languages;
31
use C4::Languages;
Lines 374-388 sub _add_rowdata { Link Here
374
        author => 'biblio.author',
375
        author => 'biblio.author',
375
        isbn =>'biblioitems.isbn',
376
        isbn =>'biblioitems.isbn',
376
        lccn =>'biblioitems.lccn', #LC control number (not call number)
377
        lccn =>'biblioitems.lccn', #LC control number (not call number)
377
        edition =>'biblioitems.editionstatement',
378
        edition =>'biblioitems.editionstatement'
378
        date => 'biblio.copyrightdate', #MARC21
379
        date2 => 'biblioitems.publicationyear', #UNIMARC
380
    );
379
    );
380
    $fetch{date} = C4::Context->preference('marcflavour') eq "MARC21" ? 'biblio.copyrightdate' : 'biblioitems.publicationyear';
381
381
    foreach my $k (keys %fetch) {
382
    foreach my $k (keys %fetch) {
382
        $row->{$k} = C4::Biblio::TransformMarcToKohaOneField( $fetch{$k}, $record );
383
        $row->{$k} = C4::Biblio::TransformMarcToKohaOneField( $fetch{$k}, $record );
383
    }
384
    }
384
    $row->{date}//= $row->{date2};
385
    $row->{date}//= $row->{date2};
385
    $row->{isbn}=_isbn_replace($row->{isbn});
386
    $row->{isbn}=_isbn_replace($row->{isbn});
387
388
    $row = _add_custom_field_rowdata($row, $record);
389
390
    return $row;
391
}
392
393
sub _add_custom_field_rowdata
394
{
395
    my ( $row, $record ) = @_;
396
    my $pref_newtags = C4::Context->preference('AdditionalFieldsInZ3950ResultSearch');
397
398
    $pref_newtags =~ s/^\s+|\s+$//g;
399
    $pref_newtags =~ s/\h+/ /g;
400
401
    my @addnumberfields;
402
403
    foreach my $field (split /\,/, $pref_newtags) {
404
        $field =~ s/^\s+|\s+$//g ;  # trim whitespace
405
        my ($tag, $subtags) = split(/\$/, $field);
406
407
        if ( $record->field($tag) ) {
408
            my @content = ();
409
410
            for my $marcfield ($record->field($tag)) {
411
                if ( $subtags ) {
412
                    my $str = '';
413
                    for my $code (split //, $subtags) {
414
                        if ( $marcfield->subfield($code) ) {
415
                            $str .= $marcfield->subfield($code) . ' ';
416
                        }
417
                    }
418
                    if ( not $str eq '') {
419
                        push @content, $str;
420
                    }
421
                } elsif ( $tag <= 10 ) {
422
                    push @content, $marcfield->data();
423
                } else {
424
                    push @content, $marcfield->as_string();
425
                }
426
            }
427
428
            if ( @content ) {
429
                $row->{$field} = \@content;
430
                push( @addnumberfields, $field );
431
            }
432
        }
433
    }
434
435
    $row->{'addnumberfields'} = \@addnumberfields;
436
386
    return $row;
437
    return $row;
387
}
438
}
388
439
(-)a/installer/data/mysql/atomicupdate/bug_12747-additional_fields_in_Z3950_search_result.sql (+1 lines)
Line 0 Link Here
1
INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('AdditionalFieldsInZ3950ResultSearch', '', 'NULL', 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free');
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 6-11 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
6
('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'),
6
('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'),
7
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
7
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
8
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
8
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
9
('AdditionalFieldsInZ3950ResultSearch', '', NULL, 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free'),
9
('AddressFormat','us','us|de|fr','Choose format to display postal addresses', 'Choice'),
10
('AddressFormat','us','us|de|fr','Choose format to display postal addresses', 'Choice'),
10
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
11
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
11
('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option.  Example: eng|fre|ita','Textarea'),
12
('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option.  Example: eng|fre|ita','Textarea'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt (-2 / +20 lines)
Lines 4-9 Link Here
4
<title>Koha &rsaquo; Acquisitions &rsaquo; [% IF ( opsearch ) %]Order from external source[% ELSE %]Order from external source &rsaquo; Search results[% END %]</title>
4
<title>Koha &rsaquo; Acquisitions &rsaquo; [% IF ( opsearch ) %]Order from external source[% ELSE %]Order from external source &rsaquo; Search results[% END %]</title>
5
[% Asset.css("css/datatables.css") %]
5
[% Asset.css("css/datatables.css") %]
6
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'datatables.inc' %]
8
[% USE Koha %]
9
7
<style type="text/css">
10
<style type="text/css">
8
.linktools { background-color:#FFF;border-top:1px solid #DDD; border-left: 1px solid #DDD; border-right: 1px solid #666; border-bottom:1px solid #666;display: none; white-space: nowrap;}
11
.linktools { background-color:#FFF;border-top:1px solid #DDD; border-left: 1px solid #DDD; border-right: 1px solid #666; border-bottom:1px solid #666;display: none; white-space: nowrap;}
9
.linktools a { font-size : 85%; text-decoration:none; padding:.3em;;background-color:#FFF; display:block;float:left;border-right:1px solid #DDD;}
12
.linktools a { font-size : 85%; text-decoration:none; padding:.3em;;background-color:#FFF; display:block;float:left;border-right:1px solid #DDD;}
Lines 15-21 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
15
<body id="acq_z3950_search" class="acq">
18
<body id="acq_z3950_search" class="acq">
16
[% INCLUDE 'header.inc' %]
19
[% INCLUDE 'header.inc' %]
17
[% INCLUDE 'acquisitions-search.inc' %]
20
[% INCLUDE 'acquisitions-search.inc' %]
18
21
[% INCLUDE 'z3950_search.inc' %]
19
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% name %]</a> &rsaquo; <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno | uri %]">Basket [% basketno | html %]</a> &rsaquo; [% IF ( opsearch ) %]Order from external source[% ELSE %]<a href="/cgi-bin/koha/acqui/z3950_search.pl?booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]">Order from external source</a> &rsaquo; Search results[% END %]</div>
22
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% name %]</a> &rsaquo; <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno | uri %]">Basket [% basketno | html %]</a> &rsaquo; [% IF ( opsearch ) %]Order from external source[% ELSE %]<a href="/cgi-bin/koha/acqui/z3950_search.pl?booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]">Order from external source</a> &rsaquo; Search results[% END %]</div>
20
23
21
<div class="main container-fluid">
24
<div class="main container-fluid">
Lines 102-107 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
102
        <th>Author</th>
105
        <th>Author</th>
103
        <th>ISBN</th>
106
        <th>ISBN</th>
104
        <th>LCCN</th>
107
        <th>LCCN</th>
108
        [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
109
        <th>Additional fields</th>
110
        [% END %]
105
        <th>Preview</th>
111
        <th>Preview</th>
106
		<th>&nbsp;</th>
112
		<th>&nbsp;</th>
107
    </tr></thead>
113
    </tr></thead>
Lines 114-119 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
114
            <td>[% breeding_loo.author %]</td>
120
            <td>[% breeding_loo.author %]</td>
115
            <td>[% breeding_loo.isbn %]</td>
121
            <td>[% breeding_loo.isbn %]</td>
116
            <td>[% breeding_loo.lccn %]</td>
122
            <td>[% breeding_loo.lccn %]</td>
123
            [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
124
            <td>
125
               <dl>
126
                  [% FOREACH addnumberfield IN breeding_loo.addnumberfields %]
127
                    [% FOREACH string IN breeding_loo.$addnumberfield %]
128
                        <dt>[% addnumberfield %]:</dt>
129
                        <dd>[% string %]</dd>
130
                    [% END %]
131
                  [% END %]
132
               </dl>
133
            </td>
134
            [% END %]
117
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" title="MARC" class="previewData">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid %]" title="Card" class="previewData">Card</a></td>
135
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" title="MARC" class="previewData">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid %]" title="Card" class="previewData">Card</a></td>
118
            <td><a href="/cgi-bin/koha/acqui/neworderempty.pl?frameworkcode=[% frameworkcode | uri %]&amp;breedingid=[% breeding_loo.breedingid %]&amp;booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]">Order</a></td>
136
            <td><a href="/cgi-bin/koha/acqui/neworderempty.pl?frameworkcode=[% frameworkcode | uri %]&amp;breedingid=[% breeding_loo.breedingid %]&amp;booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]">Order</a></td>
119
137
Lines 227-230 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
227
    [% Asset.js("js/z3950_search.js") %]
245
    [% Asset.js("js/z3950_search.js") %]
228
[% END %]
246
[% END %]
229
247
230
[% INCLUDE 'intranet-bottom.inc' %]
248
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (+4 lines)
Lines 246-251 Cataloging: Link Here
246
                  no: "don't"
246
                  no: "don't"
247
            - attempt to match aggressively by trying all variations of the ISBNs in the imported record as a phrase in the ISBN fields of already cataloged records.  Note that this preference has no effect if UseQueryParser is on.
247
            - attempt to match aggressively by trying all variations of the ISBNs in the imported record as a phrase in the ISBN fields of already cataloged records.  Note that this preference has no effect if UseQueryParser is on.
248
        -
248
        -
249
            - Display the MARC field/subfields
250
            - pref: AdditionalFieldsInZ3950ResultSearch
251
            - " in the 'Additional fields' column in the result of a search Z3950 (use comma as delimiter e.g.: \"<code>001, 082$ab, 090$ab</code>\")"
252
        -
249
            - When matching on ISSN with the record import tool,
253
            - When matching on ISSN with the record import tool,
250
            - pref: AggressiveMatchOnISSN
254
            - pref: AggressiveMatchOnISSN
251
              choices:
255
              choices:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt (-1 / +16 lines)
Lines 1-5 Link Here
1
[% USE Asset %]
1
[% USE Asset %]
2
[% SET footerjs = 1 %]
2
[% SET footerjs = 1 %]
3
[% USE Koha %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Z39.50/SRU search results</title>
5
<title>Koha &rsaquo; Z39.50/SRU search results</title>
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
Lines 101-106 Link Here
101
        <th>Edition</th>
102
        <th>Edition</th>
102
        <th>ISBN</th>
103
        <th>ISBN</th>
103
        <th>LCCN</th>
104
        <th>LCCN</th>
105
        [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
106
        <th>Additional fields</th>
107
        [% END %]
104
        <th>Actions</th>
108
        <th>Actions</th>
105
    </tr></thead>
109
    </tr></thead>
106
    <tbody>[% FOREACH breeding_loo IN breeding_loop %]
110
    <tbody>[% FOREACH breeding_loo IN breeding_loop %]
Lines 114-120 Link Here
114
            <td>[% breeding_loo.edition %]</td>
118
            <td>[% breeding_loo.edition %]</td>
115
            <td>[% breeding_loo.isbn %]</td>
119
            <td>[% breeding_loo.isbn %]</td>
116
            <td>[% breeding_loo.lccn %]</td>
120
            <td>[% breeding_loo.lccn %]</td>
117
121
            [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
122
            <td>
123
               <dl>
124
                  [% FOREACH addnumberfield IN breeding_loo.addnumberfields %]
125
                    [% FOREACH string IN breeding_loo.$addnumberfield %]
126
                        <dt>[% addnumberfield %]:</dt>
127
                        <dd>[% string %]</dd>
128
                    [% END %]
129
                  [% END %]
130
               </dl>
131
            </td>
132
            [% END %]
118
            <td>
133
            <td>
119
                <div class="dropdown">
134
                <div class="dropdown">
120
                    <a class="btn btn-default btn-xs dropdown-toggle" id="cataloguesearchactions[% breeding_loo.breedingid %]" role="button" data-toggle="dropdown" href="#">
135
                    <a class="btn btn-default btn-xs dropdown-toggle" id="cataloguesearchactions[% breeding_loo.breedingid %]" role="button" data-toggle="dropdown" href="#">
(-)a/t/db_dependent/Breeding.t (-2 / +49 lines)
Lines 20-28 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use FindBin;
22
use FindBin;
23
use Test::More tests => 3;
23
use Test::More tests => 4;
24
use Test::Warn;
24
use Test::Warn;
25
use t::lib::Mocks qw( mock_preference );
25
26
27
use C4::Context;
26
use C4::Breeding;
28
use C4::Breeding;
27
use Koha::XSLT_Handler;
29
use Koha::XSLT_Handler;
28
30
Lines 49-54 subtest '_do_xslt_proc' => sub { Link Here
49
    plan tests => 6;
51
    plan tests => 6;
50
    test_do_xslt();
52
    test_do_xslt();
51
};
53
};
54
#Group 4: testing _add_rowdata (part of Z3950Search)
55
subtest '_add_rowdata' => sub {
56
    plan tests => 5;
57
    test_add_rowdata();
58
};
52
59
53
#-------------------------------------------------------------------------------
60
#-------------------------------------------------------------------------------
54
61
Lines 189-191 sub test_do_xslt { Link Here
189
    is ( $res[0]->subfield('245','a'), 'Just a title',
196
    is ( $res[0]->subfield('245','a'), 'Just a title',
190
        'At least the title is the same :)' );
197
        'At least the title is the same :)' );
191
}
198
}
192
- 
199
200
sub test_add_rowdata {
201
    t::lib::Mocks::mock_preference('AdditionalFieldsInZ3950ResultSearch','');
202
203
    my $row = {
204
       biblionumber => 0,
205
       server => "testServer",
206
       breedingid => 0
207
   };
208
209
    my $biblio = MARC::Record->new();
210
    $biblio->append_fields(
211
        MARC::Field->new('245', ' ', ' ', a => 'Just a title'), #title
212
    );
213
214
    my $returned_row = C4::Breeding::_add_rowdata($row, $biblio);
215
216
    is($returned_row->{title}, "Just a title", "_add_rowdata returns the title of a biblio");
217
    is($returned_row->{addnumberfields}[0], undef, "_add_rowdata returns undef if it has no additionnal field");
218
219
    t::lib::Mocks::mock_preference('AdditionalFieldsInZ3950ResultSearch',"245\$a, 035\$a");
220
221
    $row = {
222
       biblionumber => 0,
223
       server => "testServer",
224
       breedingid => 0
225
   };
226
   $biblio = MARC::Record->new();
227
   $biblio->append_fields(
228
        MARC::Field->new('245', ' ', ' ', a => 'Just a title'), #title
229
        MARC::Field->new('035', ' ', ' ', a => 'First 035'),
230
        MARC::Field->new('035', ' ', ' ', a => 'Second 035')
231
   );
232
   $returned_row = C4::Breeding::_add_rowdata($row, $biblio);
233
234
   is($returned_row->{title}, "Just a title", "_add_rowdata returns the title of a biblio");
235
   is($returned_row->{addnumberfields}[0], "245\$a", "_add_rowdata returns the field number chosen in the AdditionalFieldsInZ3950ResultSearch preference");
236
237
   # Test repeatble tags,the trailing whitespace is a normal side-effect of _add_custom_row_data
238
   is_deeply(\$returned_row->{"035\$a"}, \["First 035 ", "Second 035 "],"_add_rowdata supports repeatable tags");
239
}

Return to bug 12747