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

(-)a/C4/AuthoritiesMarc.pm (-13 / +3 lines)
Lines 26-31 use C4::AuthoritiesMarc::MARC21; Link Here
26
use C4::AuthoritiesMarc::UNIMARC;
26
use C4::AuthoritiesMarc::UNIMARC;
27
use C4::Charset;
27
use C4::Charset;
28
use C4::Log;
28
use C4::Log;
29
use Koha::Authority;
29
30
30
use vars qw($VERSION @ISA @EXPORT);
31
use vars qw($VERSION @ISA @EXPORT);
31
32
Lines 848-866 Returns MARC::Record of the authority passed in parameter. Link Here
848
849
849
sub GetAuthority {
850
sub GetAuthority {
850
    my ($authid)=@_;
851
    my ($authid)=@_;
851
    my $dbh=C4::Context->dbh;
852
    my $authority = Koha::Authority->get_from_authid($authid);
852
    my $sth=$dbh->prepare("select authtypecode, marcxml from auth_header where authid=?");
853
    return ($authority->record);
853
    $sth->execute($authid);
854
    my ($authtypecode, $marcxml) = $sth->fetchrow;
855
    my $record=eval {MARC::Record->new_from_xml(StripNonXmlChars($marcxml),'UTF-8',
856
        (C4::Context->preference("marcflavour") eq "UNIMARC"?"UNIMARCAUTH":C4::Context->preference("marcflavour")))};
857
    return undef if ($@);
858
    $record->encoding('UTF-8');
859
    if (C4::Context->preference("marcflavour") eq "MARC21") {
860
      my ($auth_type_tag, $auth_type_subfield) = get_auth_type_location($authtypecode);
861
      C4::AuthoritiesMarc::MARC21::fix_marc21_auth_type_location($record, $auth_type_tag, $auth_type_subfield);
862
    }
863
    return ($record);
864
}
854
}
865
855
866
=head2 GetAuthType 
856
=head2 GetAuthType 
(-)a/C4/Search.pm (-1 / +2 lines)
Lines 477-483 sub getRecords { Link Here
477
                                # avoid first line
477
                                # avoid first line
478
                                my $tag_num = substr($tag, 0, 3);
478
                                my $tag_num = substr($tag, 0, 3);
479
                                my $letters = substr($tag, 3);
479
                                my $letters = substr($tag, 3);
480
                                my $field_pattern = '\n' . $tag_num . ' ([^\n]+)';
480
                                my $field_pattern = '\n' . $tag_num . ' ([^z][^\n]+)';
481
                                $field_pattern = '\n' . $tag_num . ' ([^\n]+)' if (int($tag_num) < 10);
481
                                my @field_tokens = ( $render_record =~ /$field_pattern/g ) ;
482
                                my @field_tokens = ( $render_record =~ /$field_pattern/g ) ;
482
                                foreach my $field_token (@field_tokens) {
483
                                foreach my $field_token (@field_tokens) {
483
                                    my @subf = ( $field_token =~ /\$([a-zA-Z0-9]) ([^\$]+)/g );
484
                                    my @subf = ( $field_token =~ /\$([a-zA-Z0-9]) ([^\$]+)/g );
(-)a/Koha/Authority.pm (+92 lines)
Line 0 Link Here
1
package Koha::Authority;
2
3
# Copyright 2012 C & P Bibliography Services
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
=head1 NAME
21
22
Koha::Authority - class to encapsulate authority records in Koha
23
24
=head1 SYNOPSIS
25
26
Object-oriented class that encapsulates authority records in Koha.
27
28
=head1 DESCRIPTION
29
30
Authority data.
31
32
=cut
33
34
use strict;
35
use warnings;
36
use C4::Context;
37
use MARC::Record;
38
use MARC::File::XML;
39
use C4::Charset;
40
41
use base qw(Class::Accessor);
42
43
__PACKAGE__->mk_accessors(qw( authid authtype record marcflavour ));
44
45
=head2 new
46
47
    my $auth = Koha::Authority->new($record);
48
49
Create a new Koha::Authority object based on the provided record.
50
51
=cut
52
sub new {
53
    my $class = shift;
54
    my $record = shift;
55
56
    my $self = $class->SUPER::new( { record => $record });
57
58
    bless $self, $class;
59
    return $self;
60
}
61
62
=head2 get_from_authid
63
64
    my $auth = Koha::Authority->get_from_authid($authid);
65
66
Create the Koha::Authority object associated with the provided authid.
67
68
=cut
69
sub get_from_authid {
70
    my $class = shift;
71
    my $authid = shift;
72
    my $marcflavour = C4::Context->preference("marcflavour");
73
74
    my $dbh=C4::Context->dbh;
75
    my $sth=$dbh->prepare("select authtypecode, marcxml from auth_header where authid=?");
76
    $sth->execute($authid);
77
    my ($authtypecode, $marcxml) = $sth->fetchrow;
78
    my $record=eval {MARC::Record->new_from_xml(StripNonXmlChars($marcxml),'UTF-8',
79
        (C4::Context->preference("marcflavour") eq "UNIMARC"?"UNIMARCAUTH":C4::Context->preference("marcflavour")))};
80
    return undef if ($@);
81
    $record->encoding('UTF-8');
82
83
    my $self = $class->SUPER::new( { authid => $authid,
84
                                     marcflavour => $marcflavour,
85
                                     authtype => $authtypecode,
86
                                     record => $record });
87
88
    bless $self, $class;
89
    return $self;
90
}
91
92
1;
(-)a/Koha/Filter/MARC/EmbedSeeFromHeadings.pm (+102 lines)
Line 0 Link Here
1
package Koha::Filter::MARC::EmbedSeeFromHeadings;
2
3
# Copyright 2012 C & P Bibliography Services
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
=head1 NAME
21
22
Koha::Filter::MARC::EmbedSeeFromHeadings - embeds see from headings into MARC for indexing
23
24
=head1 SYNOPSIS
25
26
27
=head1 DESCRIPTION
28
29
Filter to embed see from headings into MARC records.
30
31
=cut
32
33
use strict;
34
use warnings;
35
use Carp;
36
use Koha::Authority;
37
38
use base qw(Koha::RecordProcessor::Base);
39
our $NAME = 'EmbedSeeFromHeadings';
40
our $VERSION = '1.0';
41
42
=head2 filter
43
44
    my $newrecord = $filter->filter($record);
45
    my $newrecords = $filter->filter(\@records);
46
47
Embed see from headings into the specified record(s) and return the result.
48
In order to differentiate added headings from actual headings, a 'z' is
49
put in the first indicator.
50
51
=cut
52
sub filter {
53
    my $self = shift;
54
    my $record = shift;
55
    my $newrecord;
56
57
    return undef unless defined $record;
58
59
    if (ref $record eq 'ARRAY') {
60
        my @recarray;
61
        foreach my $thisrec (@$record) {
62
            push @recarray, _processrecord($thisrec);
63
        }
64
        $newrecord = \@recarray;
65
    } elsif (ref $record eq 'MARC::Record') {
66
        $newrecord = _processrecord($record);
67
    }
68
69
    return $newrecord;
70
}
71
72
sub _processrecord {
73
    my $record = shift;
74
75
    foreach my $field ( $record->fields() ) {
76
        next if $field->is_control_field();
77
        my $authid = $field->subfield('9');
78
79
        next unless $authid;
80
81
        my $authority = Koha::Authority->get_from_authid($authid);
82
        next unless $authority;
83
        my $auth_marc = $authority->record;
84
        my @seefrom = $auth_marc->field('4..');
85
        my @newfields;
86
        foreach my $authfield (@seefrom) {
87
            my $tag = substr($field->tag(), 0, 1) . substr($authfield->tag(), 1, 2);
88
            my $newfield = MARC::Field->new($tag,
89
                    'z',
90
                    $authfield->indicator(2) || ' ',
91
                    '9' => '1');
92
            foreach my $sub ($authfield->subfields()) {
93
                my ($code,$val) = @$sub;
94
                $newfield->add_subfields( $code => $val );
95
            }
96
            $newfield->delete_subfield( code => '9' );
97
            push @newfields, $newfield if (scalar($newfield->subfields()) > 0);
98
        }
99
        $record->append_fields(@newfields);
100
    }
101
    return $record;
102
}
(-)a/Koha/Filter/MARC/Null.pm (+55 lines)
Line 0 Link Here
1
package Koha::Filter::MARC::Null;
2
3
# Copyright 2012 C & P Bibliography Services
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
=head1 NAME
21
22
Koha::Filter::MARC::Null - an example filter that does nothing but allow us to run tests
23
24
=head1 SYNOPSIS
25
26
27
=head1 DESCRIPTION
28
29
Filter to allow us to run unit tests and regression tests against the
30
RecordProcessor.
31
32
=cut
33
34
use strict;
35
use warnings;
36
use Carp;
37
38
use base qw(Koha::RecordProcessor::Base);
39
our $NAME = 'Null';
40
our $VERSION = '1.0';
41
42
=head2 filter
43
44
    my $newrecord = $filter->filter($record);
45
    my $newrecords = $filter->filter(\@records);
46
47
Return the original record.
48
49
=cut
50
sub filter {
51
    my $self = shift;
52
    my $record = shift;
53
54
    return $record;
55
}
(-)a/Koha/RecordProcessor.pm (+183 lines)
Line 0 Link Here
1
package Koha::RecordProcessor;
2
3
# Copyright 2012 C & P Bibliography Services
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
=head1 NAME
21
22
Koha::RecordProcessor - Dispatcher class for record normalization
23
24
=head1 SYNOPSIS
25
26
  use Koha::RecordProcessor;
27
  my $normalizer = Koha::RecordProcessor(%params);
28
  $normalizer->process($record)
29
30
=head1 DESCRIPTION
31
32
Dispatcher class for record normalization. RecordProcessors must
33
extend Koha::RecordProcessor::Base, be in the Koha::Filter namespace,
34
and provide the following methods:
35
36
B<filter ($record)> - apply the filter and return the result. $record
37
may be either a scalar or an arrayref, and the return result will be
38
the same type.
39
40
These methods may be overriden:
41
42
B<initialize (%params)> - initialize the filter
43
44
B<destroy ()> - destroy the filter
45
46
These methods should not be overridden unless you are very sure of what
47
you are doing:
48
49
B<new ()> - create a new filter object
50
51
Note that the RecordProcessor will not clone the record that is
52
passed in. If you do not want to change the original MARC::Record
53
object (or whatever type of object you are passing in), you must
54
clone it I<prior> to passing it off to the RecordProcessor.
55
56
=head1 FUNCTIONS
57
58
=cut
59
60
use strict;
61
use warnings;
62
use Module::Load::Conditional qw(can_load);
63
use Module::Pluggable::Object;
64
65
use base qw(Class::Accessor);
66
67
__PACKAGE__->mk_accessors(qw( schema filters options record ));
68
69
=head2 new
70
71
    my $normalizer = Koha::RecordProcessor->new(%params);
72
73
Create a new normalizer. Available parameters are:
74
75
=over 8
76
77
=item B<schema>
78
79
Which metadata schema is in use. At the moment the only supported schema
80
is 'MARC'.
81
82
=item B<filters>
83
84
What filter(s) to use. This must be an arrayref to a list of filters. Filters
85
can be specified either with a complete class path, or, if they are in the
86
Koha::Filter::${schema} namespace, as only the filter name, and
87
"Koha::Filter::${schema}" will be prepended to it before the filter is loaded.
88
89
=back
90
91
=cut
92
sub new {
93
    my $class = shift;
94
    my $param = shift;
95
96
97
    my $schema = $param->{schema} || 'MARC';
98
    my $options = $param->{options} || '';
99
    my @filters = ( );
100
101
    foreach my $filter ($param->{filters}) {
102
        next unless $filter;
103
        my $filter_module = $filter =~ m/:/ ? $filter : "Koha::Filter::${schema}::${filter}";
104
        if (can_load( modules => { $filter_module => undef } )) {
105
            my $object = $filter_module->new();
106
            $filter_module->initialize($param);
107
            push @filters, $object;
108
        }
109
    }
110
111
    my $self = $class->SUPER::new( { schema => $schema,
112
                                     filters => \@filters,
113
                                     options => $options });
114
    bless $self, $class;
115
    return $self;
116
}
117
118
=head2 bind
119
120
    $normalizer->bind($record)
121
122
Bind a normalizer to a particular record.
123
124
=cut
125
sub bind {
126
    my $self = shift;
127
    my $record = shift;
128
129
    $self->{record} = $record;
130
    return;
131
}
132
133
=head2 process
134
135
    my $newrecord = $normalizer->process([$record])
136
137
Run the record(s) through the normalization pipeline. If $record is
138
not specified, process the record the normalizer is bound to.
139
Note that $record may be either a scalar or an arrayref, and the
140
return value will be of the same type.
141
142
=cut
143
sub process {
144
    my $self = shift;
145
    my $record = shift || $self->record;
146
147
    return unless defined $record;
148
149
    my $newrecord = $record;
150
151
    foreach my $filterobj (@{$self->filters}) {
152
        next unless $filterobj;
153
        $newrecord = $filterobj->filter($newrecord);
154
    }
155
156
    return $newrecord;
157
}
158
159
sub DESTROY {
160
    my $self = shift;
161
162
    foreach my $filterobj (@{$self->filters}) {
163
        $filterobj->destroy();
164
    }
165
}
166
167
=head2 AvailableFilters
168
169
    my @available_filters = Koha::RecordProcessor::AvailableFilters([$schema]);
170
171
Get a list of available filters. Optionally specify the metadata schema.
172
At present only MARC is supported as a schema.
173
174
=cut
175
sub AvailableFilters {
176
    my $schema = pop || '';
177
    my $path = 'Koha::Filter';
178
    $path .= "::$schema" if ($schema eq 'MARC');
179
    my $finder = Module::Pluggable::Object->new(search_path => $path);
180
    return $finder->plugins;
181
}
182
183
1;
(-)a/Koha/RecordProcessor/Base.pm (+133 lines)
Line 0 Link Here
1
package Koha::RecordProcessor::Base;
2
3
# Copyright 2012 C & P Bibliography Services
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
=head1 NAME
21
22
Koha::RecordProcessor::Base - Base class for RecordProcessor filters
23
24
=head1 SYNOPSIS
25
26
  use base qw(Koha::RecordProcessor::Base);
27
28
=head1 DESCRIPTION
29
30
Base class for record normalizer filters. RecordProcessors must
31
provide the following methods:
32
33
B<filter ($record)> - apply the filter and return the result. $record
34
may be either a scalar or an arrayref, and the return result will be
35
the same type.
36
37
The following variables must be defined in each filter:
38
  our $NAME ='Filter';
39
  our $VERSION = '1.0';
40
41
These methods may be overriden:
42
43
B<initialize (%params)> - initialize the filter
44
45
B<destroy ()> - destroy the filter
46
47
These methods should not be overridden unless you are very sure of what
48
you are doing:
49
50
B<new ()> - create a new filter object
51
52
Note that the RecordProcessor will not clone the record that is
53
passed in. If you do not want to change the original MARC::Record
54
object (or whatever type of object you are passing in), you must
55
clone it I<prior> to passing it off to the RecordProcessor.
56
57
=head1 FUNCTIONS
58
59
=cut
60
61
use strict;
62
use warnings;
63
64
use base qw(Class::Accessor);
65
66
__PACKAGE__->mk_ro_accessors(qw( name version ));
67
__PACKAGE__->mk_accessors(qw( params ));
68
our $NAME = 'Base';
69
our $VERSION = '1.0';
70
71
72
=head2 new
73
74
    my $filter = Koha::RecordProcessor::Base->new;
75
76
Create a new filter;
77
78
=cut
79
sub new {
80
    my $class = shift;
81
82
    my $self = $class->SUPER::new( { });#name => $class->NAME,
83
                                     #version => $class->VERSION });
84
85
    bless $self, $class;
86
    return $self;
87
}
88
89
90
=head2 initialize
91
92
    $filter->initalize(%params);
93
94
Initialize a filter using the specified parameters.
95
96
=cut
97
sub initialize {
98
    my $self = shift;
99
    my $params = shift;
100
101
    #$self->params = $params;
102
103
    return $self;
104
}
105
106
107
=head2 destroy
108
109
    $filter->destroy();
110
111
Destroy the filter.
112
113
=cut
114
sub destroy {
115
    my $self = shift;
116
    return;
117
}
118
119
=head2 filter
120
121
    my $newrecord = $filter->filter($record);
122
    my $newrecords = $filter->filter(\@records);
123
124
Filter the specified record(s) and return the result.
125
126
=cut
127
sub filter {
128
    my $self = shift;
129
    my $record = shift;
130
    return $record;
131
}
132
133
1;
(-)a/Koha/SearchEngine/Solr/Index.pm (+6 lines)
Lines 9-14 use List::MoreUtils qw(uniq); Link Here
9
use Koha::SearchEngine::Solr;
9
use Koha::SearchEngine::Solr;
10
use C4::AuthoritiesMarc;
10
use C4::AuthoritiesMarc;
11
use C4::Biblio;
11
use C4::Biblio;
12
use Koha::RecordProcessor;
12
13
13
has searchengine => (
14
has searchengine => (
14
    is => 'rw',
15
    is => 'rw',
Lines 39-44 sub index_record { Link Here
39
        $record = GetAuthority( $id )  if $recordtype eq "authority";
40
        $record = GetAuthority( $id )  if $recordtype eq "authority";
40
        $record = GetMarcBiblio( $id ) if $recordtype eq "biblio";
41
        $record = GetMarcBiblio( $id ) if $recordtype eq "biblio";
41
42
43
        if ($record_type eq 'biblio' && C4::Context->preference('IncludeSeeFromInSearches')) {
44
            my $normalizer = Koha::RecordProcessor->new( { filters => 'EmbedSeeFromHeadings' } );
45
            $record = $normalizer->process($record);
46
        }
47
42
        next unless ( $record );
48
        next unless ( $record );
43
49
44
        my $index_values = {
50
        my $index_values = {
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 371-373 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' Link Here
371
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToUseWhenPrefill','','Define a list of subfields to use when prefilling items (separated by space)','','Free');
371
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToUseWhenPrefill','','Define a list of subfields to use when prefilling items (separated by space)','','Free');
372
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|',NULL,'free');
372
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|',NULL,'free');
373
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionOverride',0,'Allow staff to check out an item with age restriction.',NULL,'YesNo');
373
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionOverride',0,'Allow staff to check out an item with age restriction.',NULL,'YesNo');
374
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('IncludeSeeFromInSearches','0','','Include see-from references in searches.','YesNo');
(-)a/installer/data/mysql/updatedatabase.pl (+8 lines)
Lines 5696-5701 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5696
    SetVersion($DBversion);
5696
    SetVersion($DBversion);
5697
}
5697
}
5698
5698
5699
$DBversion = "3.09.00.XXX";
5700
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5701
    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('IncludeSeeFromInSearches','0','','Include see-from references in searches.','YesNo');");
5702
    print "Upgrade to $DBversion done (Add IncludeSeeFromInSearches system preference)\n";
5703
    SetVersion ($DBversion);
5704
}
5705
5706
5699
=head1 FUNCTIONS
5707
=head1 FUNCTIONS
5700
5708
5701
=head2 TableExists($table)
5709
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref (+7 lines)
Lines 76-81 Searching: Link Here
76
                  yes: Using
76
                  yes: Using
77
                  no: "Not using"
77
                  no: "Not using"
78
            - 'ICU Zebra indexing. Please note: This setting will not affect Zebra indexing, it should only be used to tell Koha that you have activated ICU indexing if you have actually done so, since there is no way for Koha to figure this out on its own.'
78
            - 'ICU Zebra indexing. Please note: This setting will not affect Zebra indexing, it should only be used to tell Koha that you have activated ICU indexing if you have actually done so, since there is no way for Koha to figure this out on its own.'
79
        -
80
            - pref: IncludeSeeFromInSearches
81
              default: 0
82
              choices:
83
                  yes: Include
84
                  no: "Don't include"
85
            - "<i>see from</i> (non-preferred form) headings in bibliographic searches. Please note: you will need to reindex your bibliographic database when changing this preference."
79
    Search Form:
86
    Search Form:
80
        -
87
        -
81
            - Show tabs in OPAC and staff-side advanced search for limiting searches on the
88
            - Show tabs in OPAC and staff-side advanced search for limiting searches on the
(-)a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl (-3 / +3 lines)
Lines 336-342 Link Here
336
    <xsl:choose>
336
    <xsl:choose>
337
    <xsl:when test="marc:datafield[@tag=100] or marc:datafield[@tag=110] or marc:datafield[@tag=111] or marc:datafield[@tag=700] or marc:datafield[@tag=710] or marc:datafield[@tag=711]">
337
    <xsl:when test="marc:datafield[@tag=100] or marc:datafield[@tag=110] or marc:datafield[@tag=111] or marc:datafield[@tag=700] or marc:datafield[@tag=710] or marc:datafield[@tag=711]">
338
    <p class="author">by
338
    <p class="author">by
339
    <xsl:for-each select="marc:datafield[@tag=100 or @tag=700]">
339
    <xsl:for-each select="marc:datafield[(@tag=100 or @tag=700) and @ind1!='z']">
340
    <a>
340
    <a>
341
    <xsl:choose>
341
    <xsl:choose>
342
        <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'">
342
        <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'">
Lines 351-357 Link Here
351
    <xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
351
    <xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
352
    </xsl:for-each>
352
    </xsl:for-each>
353
353
354
    <xsl:for-each select="marc:datafield[@tag=110 or @tag=710]">
354
    <xsl:for-each select="marc:datafield[(@tag=110 or @tag=710) and @ind1!='z']">
355
    <a>
355
    <a>
356
    <xsl:choose>
356
    <xsl:choose>
357
        <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'">
357
        <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'">
Lines 365-371 Link Here
365
    <xsl:choose><xsl:when test="position()=last()"><xsl:text> </xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
365
    <xsl:choose><xsl:when test="position()=last()"><xsl:text> </xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
366
    </xsl:for-each>
366
    </xsl:for-each>
367
367
368
    <xsl:for-each select="marc:datafield[@tag=111 or @tag=711]">
368
    <xsl:for-each select="marc:datafield[(@tag=111 or @tag=711) and @ind1!='z']">
369
        <xsl:choose>
369
        <xsl:choose>
370
        <xsl:when test="marc:subfield[@code='n']">
370
        <xsl:when test="marc:subfield[@code='n']">
371
           <xsl:text> </xsl:text>
371
           <xsl:text> </xsl:text>
(-)a/koha-tmpl/intranet-tmpl/prog/en/xslt/NORMARCslim2intranetResults.xsl (-3 / +3 lines)
Lines 283-289 Link Here
283
    <xsl:choose>
283
    <xsl:choose>
284
    <xsl:when test="marc:datafield[@tag=100] or marc:datafield[@tag=110] or marc:datafield[@tag=111] or marc:datafield[@tag=700] or marc:datafield[@tag=710] or marc:datafield[@tag=711]">
284
    <xsl:when test="marc:datafield[@tag=100] or marc:datafield[@tag=110] or marc:datafield[@tag=111] or marc:datafield[@tag=700] or marc:datafield[@tag=710] or marc:datafield[@tag=711]">
285
    <p class="author">av
285
    <p class="author">av
286
    <xsl:for-each select="marc:datafield[@tag=100 or @tag=700]">
286
    <xsl:for-each select="marc:datafield[(@tag=100 or @tag=700) and @ind1!='z']">
287
    <a>
287
    <a>
288
    <xsl:choose>
288
    <xsl:choose>
289
        <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'">
289
        <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'">
Lines 298-304 Link Here
298
    <xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
298
    <xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
299
    </xsl:for-each>
299
    </xsl:for-each>
300
300
301
    <xsl:for-each select="marc:datafield[@tag=110 or @tag=710]">
301
    <xsl:for-each select="marc:datafield[(@tag=110 or @tag=710) and @ind1!='z']">
302
    <a>
302
    <a>
303
    <xsl:choose>
303
    <xsl:choose>
304
        <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'">
304
        <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'">
Lines 312-318 Link Here
312
    <xsl:choose><xsl:when test="position()=last()"><xsl:text> </xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
312
    <xsl:choose><xsl:when test="position()=last()"><xsl:text> </xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
313
    </xsl:for-each>
313
    </xsl:for-each>
314
314
315
    <xsl:for-each select="marc:datafield[@tag=111 or @tag=711]">
315
    <xsl:for-each select="marc:datafield[(@tag=111 or @tag=711) and @ind1!='z']">
316
        <xsl:choose>
316
        <xsl:choose>
317
        <xsl:when test="marc:subfield[@code='n']">
317
        <xsl:when test="marc:subfield[@code='n']">
318
           <xsl:text> </xsl:text>
318
           <xsl:text> </xsl:text>
(-)a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl (-3 / +3 lines)
Lines 450-456 Link Here
450
    <xsl:when test="marc:datafield[@tag=100] or marc:datafield[@tag=110] or marc:datafield[@tag=111] or marc:datafield[@tag=700] or marc:datafield[@tag=710] or marc:datafield[@tag=711]">
450
    <xsl:when test="marc:datafield[@tag=100] or marc:datafield[@tag=110] or marc:datafield[@tag=111] or marc:datafield[@tag=700] or marc:datafield[@tag=710] or marc:datafield[@tag=711]">
451
451
452
    by <span class="author">
452
    by <span class="author">
453
        <xsl:for-each select="marc:datafield[@tag=100 or @tag=700]">
453
        <xsl:for-each select="marc:datafield[(@tag=100 or @tag=700) and @ind1!='z']">
454
            <xsl:choose>
454
            <xsl:choose>
455
            <xsl:when test="position()=last()">
455
            <xsl:when test="position()=last()">
456
                <xsl:call-template name="nameABCDQ"/>.
456
                <xsl:call-template name="nameABCDQ"/>.
Lines 461-467 Link Here
461
            </xsl:choose>
461
            </xsl:choose>
462
        </xsl:for-each>
462
        </xsl:for-each>
463
463
464
        <xsl:for-each select="marc:datafield[@tag=110 or @tag=710]">
464
        <xsl:for-each select="marc:datafield[(@tag=110 or @tag=710) and @ind1!='z']">
465
            <xsl:choose>
465
            <xsl:choose>
466
            <xsl:when test="position()=1">
466
            <xsl:when test="position()=1">
467
		<xsl:text> -- </xsl:text>
467
		<xsl:text> -- </xsl:text>
Lines 477-483 Link Here
477
            </xsl:choose>
477
            </xsl:choose>
478
        </xsl:for-each>
478
        </xsl:for-each>
479
479
480
        <xsl:for-each select="marc:datafield[@tag=111 or @tag=711]">
480
        <xsl:for-each select="marc:datafield[(@tag=111 or @tag=711) and @ind1!='z']">
481
            <xsl:choose>
481
            <xsl:choose>
482
            <xsl:when test="position()=1">
482
            <xsl:when test="position()=1">
483
		<xsl:text> -- </xsl:text>
483
		<xsl:text> -- </xsl:text>
(-)a/koha-tmpl/opac-tmpl/prog/en/xslt/NORMARCslim2OPACResults.xsl (-3 / +3 lines)
Lines 325-331 Link Here
325
    <xsl:when test="marc:datafield[@tag=100] or marc:datafield[@tag=110] or marc:datafield[@tag=111] or marc:datafield[@tag=700] or marc:datafield[@tag=710] or marc:datafield[@tag=711]">
325
    <xsl:when test="marc:datafield[@tag=100] or marc:datafield[@tag=110] or marc:datafield[@tag=111] or marc:datafield[@tag=700] or marc:datafield[@tag=710] or marc:datafield[@tag=711]">
326
326
327
    av 
327
    av 
328
        <xsl:for-each select="marc:datafield[@tag=100 or @tag=700]">
328
        <xsl:for-each select="marc:datafield[(@tag=100 or @tag=700) and @ind1!='z']">
329
            <xsl:choose>
329
            <xsl:choose>
330
            <xsl:when test="position()=last()">
330
            <xsl:when test="position()=last()">
331
                <xsl:call-template name="nameABCDQ"/>.
331
                <xsl:call-template name="nameABCDQ"/>.
Lines 336-342 Link Here
336
            </xsl:choose>
336
            </xsl:choose>
337
        </xsl:for-each>
337
        </xsl:for-each>
338
338
339
        <xsl:for-each select="marc:datafield[@tag=110 or @tag=710]">
339
        <xsl:for-each select="marc:datafield[(@tag=110 or @tag=710) and @ind1!='z']">
340
            <xsl:choose>
340
            <xsl:choose>
341
            <xsl:when test="position()=last()">
341
            <xsl:when test="position()=last()">
342
                <xsl:call-template name="nameABCDN"/>.
342
                <xsl:call-template name="nameABCDN"/>.
Lines 347-353 Link Here
347
            </xsl:choose>
347
            </xsl:choose>
348
        </xsl:for-each>
348
        </xsl:for-each>
349
349
350
        <xsl:for-each select="marc:datafield[@tag=111 or @tag=711]">
350
        <xsl:for-each select="marc:datafield[(@tag=111 or @tag=711) and @ind1!='z']">
351
            <xsl:choose>
351
            <xsl:choose>
352
            <xsl:when test="position()=last()">
352
            <xsl:when test="position()=last()">
353
                <xsl:call-template name="nameACDEQ"/>.
353
                <xsl:call-template name="nameACDEQ"/>.
(-)a/misc/maintenance/process_record_through_filter.pl (+18 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This script is intended for testing RecordProcessor filters. To use it
4
# run the script like so:
5
# > perl process_record_through_filter.pl ${BIBLIONUMBER} ${FILTER}
6
7
use strict;
8
use warnings;
9
use Koha::RecordProcessor;
10
use Data::Dumper;
11
use C4::Biblio;
12
13
my $record = GetMarcBiblio($ARGV[0]);
14
15
print "Before: " . $record->as_formatted() . "\n";
16
my $processor = Koha::RecordProcessor->new( { filters => ( $ARGV[1] ) });
17
$record = $processor->process($record);
18
print "After : " . $record->as_formatted() . "\n";
(-)a/misc/migration_tools/rebuild_zebra.pl (+4 lines)
Lines 10-15 use File::Path; Link Here
10
use C4::Biblio;
10
use C4::Biblio;
11
use C4::AuthoritiesMarc;
11
use C4::AuthoritiesMarc;
12
use C4::Items;
12
use C4::Items;
13
use Koha::RecordProcessor;
13
14
14
# 
15
# 
15
# script that checks zebradir structure & create directories & mandatory files if needed
16
# script that checks zebradir structure & create directories & mandatory files if needed
Lines 497-502 sub get_corrected_marc_record { Link Here
497
        fix_leader($marc);
498
        fix_leader($marc);
498
        if ($record_type eq 'authority') {
499
        if ($record_type eq 'authority') {
499
            fix_authority_id($marc, $record_number);
500
            fix_authority_id($marc, $record_number);
501
        } elsif ($record_type eq 'biblio' && C4::Context->preference('IncludeSeeFromInSearches')) {
502
            my $normalizer = Koha::RecordProcessor->new( { filters => 'EmbedSeeFromHeadings' } );
503
            $marc = $normalizer->process($marc);
500
        }
504
        }
501
        if (C4::Context->preference("marcflavour") eq "UNIMARC") {
505
        if (C4::Context->preference("marcflavour") eq "UNIMARC") {
502
            fix_unimarc_100($marc);
506
            fix_unimarc_100($marc);
(-)a/t/RecordProcessor.t (+80 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2012 C & P Bibliography Services
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use strict;
21
use warnings;
22
use File::Spec;
23
use MARC::Record;
24
25
use Test::More;
26
27
BEGIN {
28
        use_ok('Koha::RecordProcessor');
29
}
30
31
my $isbn = '0590353403';
32
my $title = 'Foundation';
33
my $marc_record=MARC::Record->new;
34
my $field = MARC::Field->new('020','','','a' => $isbn);
35
$marc_record->append_fields($field);
36
$field = MARC::Field->new('245','','','a' => $title);
37
$marc_record->append_fields($field);
38
39
40
my $filterdir = File::Spec->rel2abs('Koha/Filter') . '/MARC';
41
42
opendir(my $dh, $filterdir);
43
my @installed_filters = map { ( /\.pm$/ && -f "$filterdir/$_" && s/\.pm$// ) ? "Koha::Filters::MARC::$_" : () } readdir($dh);
44
my @available_filters = Koha::RecordProcessor::AvailableFilters();
45
46
foreach my $filter (@installed_filters) {
47
    ok(grep($filter, @available_filters), "Found filter $filter");
48
}
49
50
my $marc_filters = grep (/MARC/, @available_filters);
51
is(scalar Koha::RecordProcessor::AvailableFilters('MARC'), $marc_filters, 'Retrieved list of MARC filters');
52
53
my $processor = Koha::RecordProcessor->new( { filters => ( 'ABCD::EFGH::IJKL' ) } );
54
55
is(ref($processor), 'Koha::RecordProcessor', 'Created record processor with invalid filter');
56
57
is($processor->process($marc_record), $marc_record, 'Process record with empty processor');
58
59
$processor = Koha::RecordProcessor->new( { filters => ( 'Null' ) } );
60
is(ref($processor->filters->[0]), 'Koha::Filter::MARC::Null', 'Created record processor with implicitly scoped Null filter');
61
62
$processor = Koha::RecordProcessor->new( { filters => ( 'Koha::Filter::MARC::Null' ) } );
63
is(ref($processor->filters->[0]), 'Koha::Filter::MARC::Null', 'Created record processor with explicitly scoped Null filter');
64
65
is($processor->process($marc_record), $marc_record, 'Process record');
66
67
$processor->bind($marc_record);
68
69
is($processor->record, $marc_record, 'Bound record to processor');
70
71
is($processor->process(), $marc_record, 'Filter bound record');
72
73
eval {
74
    $processor = Koha::RecordProcessor->new( { filters => ( 'Koha::Filter::MARC::Null' ) } );
75
    undef $processor;
76
};
77
78
ok(!$@, 'Destroyed processor successfully');
79
80
done_testing();
(-)a/t/db_dependent/Koha_Authority.t (+66 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2012 C & P Bibliography Services
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use strict;
21
use warnings;
22
23
use C4::Context;
24
use Test::More;
25
26
BEGIN {
27
        use_ok('Koha::Authority');
28
}
29
30
my $record = MARC::Record->new;
31
32
$record->add_fields(
33
        [ '001', '1234' ],
34
        [ '150', ' ', ' ', a => 'Cooking' ],
35
        [ '450', ' ', ' ', a => 'Cookery' ],
36
        );
37
my $authority = Koha::Authority->new($record);
38
39
is(ref($authority), 'Koha::Authority', 'Created valid Koha::Authority object');
40
41
is_deeply($authority->record, $record, 'Saved record');
42
43
SKIP:
44
{
45
    my $dbh = C4::Context->dbh;
46
    my $sth = $dbh->prepare("SELECT authid FROM auth_header LIMIT 1;");
47
    $sth->execute();
48
49
    my $authid;
50
    for my $row ($sth->fetchrow_hashref) {
51
        $authid = $row->{'authid'};
52
    }
53
    skip 'No authorities', 3 unless $authid;
54
    $authority = Koha::Authority->get_from_authid($authid);
55
56
    is(ref($authority), 'Koha::Authority', 'Retrieved valid Koha::Authority object');
57
58
    is($authority->authid, $authid, 'Object authid is correct');
59
60
    is($authority->record->field('001')->data(), $authid, 'Retrieved correct record');
61
62
    $authority = Koha::Authority->get_from_authid('alphabetsoup');
63
    is($authority, undef, 'No invalid record is retrieved');
64
}
65
66
done_testing();
(-)a/t/db_dependent/RecordProcessor_EmbedSeeFromHeadings.t (-1 / +66 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2012 C & P Bibliography Services
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use strict;
21
use warnings;
22
use File::Spec;
23
use MARC::Record;
24
use Koha::Authority;
25
26
use Test::More;
27
use Test::MockModule;
28
29
BEGIN {
30
        use_ok('Koha::RecordProcessor');
31
}
32
33
my $module = new Test::MockModule('MARC::Record');
34
$module->mock('new_from_xml', sub {
35
    my $record = MARC::Record->new;
36
37
    $record->add_fields(
38
        [ '001', '1234' ],
39
        [ '150', ' ', ' ', a => 'Cooking' ],
40
        [ '450', ' ', ' ', a => 'Cookery' ],
41
        );
42
43
    return $record;
44
});
45
46
my $bib = MARC::Record->new;
47
$bib->add_fields(
48
    [ '245', '0', '4', a => 'The Ifrane cookbook' ],
49
    [ '650', ' ', ' ', a => 'Cooking', 9 => '1234' ]
50
    );
51
52
my $resultbib = MARC::Record->new;
53
$resultbib->add_fields(
54
    [ '245', '0', '4', a => 'The Ifrane cookbook' ],
55
    [ '650', ' ', ' ', a => 'Cooking', 9 => '1234' ],
56
    [ '650', 'z', ' ', a => 'Cookery' ]
57
    );
58
59
my $processor = Koha::RecordProcessor->new( { filters => ( 'EmbedSeeFromHeadings' ) } );
60
is(ref($processor), 'Koha::RecordProcessor', 'Created record processor');
61
62
my $result = $processor->process($bib);
63
64
is_deeply($result, $resultbib, 'Inserted see-from heading to record');
65
66
done_testing();

Return to bug 7417