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 327-341 sub _add_rowdata { Link Here
327
        author => 'biblio.author',
328
        author => 'biblio.author',
328
        isbn =>'biblioitems.isbn',
329
        isbn =>'biblioitems.isbn',
329
        lccn =>'biblioitems.lccn', #LC control number (not call number)
330
        lccn =>'biblioitems.lccn', #LC control number (not call number)
330
        edition =>'biblioitems.editionstatement',
331
        edition =>'biblioitems.editionstatement'
331
        date => 'biblio.copyrightdate', #MARC21
332
        date2 => 'biblioitems.publicationyear', #UNIMARC
333
    );
332
    );
333
    $fetch{date} = C4::Context->preference('marcflavour') eq "MARC21" ? 'biblio.copyrightdate' : 'biblioitems.publicationyear';
334
334
    foreach my $k (keys %fetch) {
335
    foreach my $k (keys %fetch) {
335
        $row->{$k} = C4::Biblio::TransformMarcToKohaOneField( $fetch{$k}, $record );
336
        $row->{$k} = C4::Biblio::TransformMarcToKohaOneField( $fetch{$k}, $record );
336
    }
337
    }
337
    $row->{date}//= $row->{date2};
338
    $row->{date}//= $row->{date2};
338
    $row->{isbn}=_isbn_replace($row->{isbn});
339
    $row->{isbn}=_isbn_replace($row->{isbn});
340
341
    $row = _add_custom_field_rowdata($row, $record);
342
343
    return $row;
344
}
345
346
sub _add_custom_field_rowdata
347
{
348
    my ( $row, $record ) = @_;
349
    my $pref_newtags = C4::Context->preference('AdditionalFieldsInZ3950ResultSearch');
350
351
    $pref_newtags =~ s/^\s+|\s+$//g;
352
    $pref_newtags =~ s/\h+/ /g;
353
354
    my @addnumberfields;
355
356
    foreach my $field (split /\,/, $pref_newtags) {
357
        $field =~ s/^\s+|\s+$//g ;  # trim whitespace
358
        my ($tag, $subtags) = split(/\$/, $field);
359
360
        if ( $record->field($tag) ) {
361
            my @content = ();
362
363
            for my $marcfield ($record->field($tag)) {
364
                if ( $subtags ) {
365
                    my $str = '';
366
                    for my $code (split //, $subtags) {
367
                        if ( $marcfield->subfield($code) ) {
368
                            $str .= $marcfield->subfield($code) . ' ';
369
                        }
370
                    }
371
                    if ( not $str eq '') {
372
                        push @content, $str;
373
                    }
374
                } elsif ( $tag <= 10 ) {
375
                    push @content, $marcfield->data();
376
                } else {
377
                    push @content, $marcfield->as_string();
378
                }
379
            }
380
381
            if ( @content ) {
382
                $row->{$field} = \@content;
383
                push( @addnumberfields, $field );
384
            }
385
        }
386
    }
387
388
    $row->{'addnumberfields'} = \@addnumberfields;
389
339
    return $row;
390
    return $row;
340
}
391
}
341
392
(-)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 (-2 / +17 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="#">
Lines 246-249 Link Here
246
    [% INCLUDE 'z3950_search.inc' %]
261
    [% INCLUDE 'z3950_search.inc' %]
247
[% END %]
262
[% END %]
248
263
249
[% INCLUDE 'intranet-bottom.inc' popup_window=1 %]
264
[% INCLUDE 'intranet-bottom.inc' popup_window=1 %]
(-)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 => 7;
51
    plan tests => 7;
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 186-188 sub test_do_xslt { Link Here
186
    is ( $res[0]->subfield('245','a') eq 'Just a title', 1,
193
    is ( $res[0]->subfield('245','a') eq 'Just a title', 1,
187
        'At least the title is the same :)' );
194
        'At least the title is the same :)' );
188
}
195
}
189
- 
196
197
sub test_add_rowdata {
198
    t::lib::Mocks::mock_preference('AdditionalFieldsInZ3950ResultSearch','');
199
200
    my $row = {
201
       biblionumber => 0,
202
       server => "testServer",
203
       breedingid => 0
204
   };
205
206
    my $biblio = MARC::Record->new();
207
    $biblio->append_fields(
208
        MARC::Field->new('245', ' ', ' ', a => 'Just a title'), #title
209
    );
210
211
    my $returned_row = C4::Breeding::_add_rowdata($row, $biblio);
212
213
    is($returned_row->{title}, "Just a title", "_add_rowdata returns the title of a biblio");
214
    is($returned_row->{addnumberfields}[0], undef, "_add_rowdata returns undef if it has no additionnal field");
215
216
    t::lib::Mocks::mock_preference('AdditionalFieldsInZ3950ResultSearch',"245\$a, 035\$a");
217
218
    $row = {
219
       biblionumber => 0,
220
       server => "testServer",
221
       breedingid => 0
222
   };
223
   $biblio = MARC::Record->new();
224
   $biblio->append_fields(
225
        MARC::Field->new('245', ' ', ' ', a => 'Just a title'), #title
226
        MARC::Field->new('035', ' ', ' ', a => 'First 035'),
227
        MARC::Field->new('035', ' ', ' ', a => 'Second 035')
228
   );
229
   $returned_row = C4::Breeding::_add_rowdata($row, $biblio);
230
231
   is($returned_row->{title}, "Just a title", "_add_rowdata returns the title of a biblio");
232
   is($returned_row->{addnumberfields}[0], "245\$a", "_add_rowdata returns the field number chosen in the AdditionalFieldsInZ3950ResultSearch preference");
233
234
   # Test repeatble tags,the trailing whitespace is a normal side-effect of _add_custom_row_data
235
   is_deeply(\$returned_row->{"035\$a"}, \["First 035 ", "Second 035 "],"_add_rowdata supports repeatable tags");
236
}

Return to bug 12747