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 (+18 lines)
Lines 5-10 Link Here
5
<title>Koha &rsaquo; Acquisitions &rsaquo; [% IF ( opsearch ) %]Order from external source[% ELSE %]Order from external source &rsaquo; Search results[% END %]</title>
5
<title>Koha &rsaquo; Acquisitions &rsaquo; [% IF ( opsearch ) %]Order from external source[% ELSE %]Order from external source &rsaquo; Search results[% END %]</title>
6
[% Asset.css("css/datatables.css") | $raw %]
6
[% Asset.css("css/datatables.css") | $raw %]
7
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'doc-head-close.inc' %]
8
[% INCLUDE 'datatables.inc' %]
9
[% USE Koha %]
10
8
<style type="text/css">
11
<style type="text/css">
9
.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;}
12
.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;}
10
.linktools a { font-size : 85%; text-decoration:none; padding:.3em;;background-color:#FFF; display:block;float:left;border-right:1px solid #DDD;}
13
.linktools a { font-size : 85%; text-decoration:none; padding:.3em;;background-color:#FFF; display:block;float:left;border-right:1px solid #DDD;}
Lines 103-108 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
103
        <th>Author</th>
106
        <th>Author</th>
104
        <th>ISBN</th>
107
        <th>ISBN</th>
105
        <th>LCCN</th>
108
        <th>LCCN</th>
109
        [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
110
        <th>Additional fields</th>
111
        [% END %]
106
        <th>Preview</th>
112
        <th>Preview</th>
107
		<th>&nbsp;</th>
113
		<th>&nbsp;</th>
108
    </tr></thead>
114
    </tr></thead>
Lines 115-120 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
115
            <td>[% breeding_loo.author | html %]</td>
121
            <td>[% breeding_loo.author | html %]</td>
116
            <td>[% breeding_loo.isbn | html %]</td>
122
            <td>[% breeding_loo.isbn | html %]</td>
117
            <td>[% breeding_loo.lccn | html %]</td>
123
            <td>[% breeding_loo.lccn | html %]</td>
124
            [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
125
            <td>
126
               <dl>
127
                  [% FOREACH addnumberfield IN breeding_loo.addnumberfields %]
128
                    [% FOREACH string IN breeding_loo.$addnumberfield %]
129
                        <dt>[% addnumberfield | html %]:</dt>
130
                        <dd>[% string | html %]</dd>
131
                    [% END %]
132
                  [% END %]
133
               </dl>
134
            </td>
135
            [% END %]
118
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid | html %]" title="MARC" class="previewData">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid | html %]" title="Card" class="previewData">Card</a></td>
136
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid | html %]" title="MARC" class="previewData">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid | html %]" title="Card" class="previewData">Card</a></td>
119
            <td><a href="/cgi-bin/koha/acqui/neworderempty.pl?frameworkcode=[% frameworkcode | uri %]&amp;breedingid=[% breeding_loo.breedingid | html %]&amp;booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]">Order</a></td>
137
            <td><a href="/cgi-bin/koha/acqui/neworderempty.pl?frameworkcode=[% frameworkcode | uri %]&amp;breedingid=[% breeding_loo.breedingid | html %]&amp;booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]">Order</a></td>
120
138
(-)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-6 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% SET footerjs = 1 %]
3
[% SET footerjs = 1 %]
4
[% USE Koha %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Z39.50/SRU search results</title>
6
<title>Koha &rsaquo; Z39.50/SRU search results</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'doc-head-close.inc' %]
Lines 102-107 Link Here
102
        <th>Edition</th>
103
        <th>Edition</th>
103
        <th>ISBN</th>
104
        <th>ISBN</th>
104
        <th>LCCN</th>
105
        <th>LCCN</th>
106
        [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
107
        <th>Additional fields</th>
108
        [% END %]
105
        <th>Actions</th>
109
        <th>Actions</th>
106
    </tr></thead>
110
    </tr></thead>
107
    <tbody>[% FOREACH breeding_loo IN breeding_loop %]
111
    <tbody>[% FOREACH breeding_loo IN breeding_loop %]
Lines 115-121 Link Here
115
            <td>[% breeding_loo.edition | html %]</td>
119
            <td>[% breeding_loo.edition | html %]</td>
116
            <td>[% breeding_loo.isbn | html %]</td>
120
            <td>[% breeding_loo.isbn | html %]</td>
117
            <td>[% breeding_loo.lccn | html %]</td>
121
            <td>[% breeding_loo.lccn | html %]</td>
118
122
            [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
123
            <td>
124
               <dl>
125
                  [% FOREACH addnumberfield IN breeding_loo.addnumberfields %]
126
                    [% FOREACH string IN breeding_loo.$addnumberfield %]
127
                        <dt>[% addnumberfield | html %]:</dt>
128
                        <dd>[% string | html %]</dd>
129
                    [% END %]
130
                  [% END %]
131
               </dl>
132
            </td>
133
            [% END %]
119
            <td>
134
            <td>
120
                <div class="dropdown">
135
                <div class="dropdown">
121
                    <a class="btn btn-default btn-xs dropdown-toggle" id="cataloguesearchactions[% breeding_loo.breedingid | html %]" role="button" data-toggle="dropdown" href="#">
136
                    <a class="btn btn-default btn-xs dropdown-toggle" id="cataloguesearchactions[% breeding_loo.breedingid | html %]" 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