line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::MARC::Field; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 Template::Plugin::MARC::Field |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Object class to allow nested auto-loading. Not used directly. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=cut |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
21
|
use 5.010000; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
39
|
|
10
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
11
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
12
|
1
|
|
|
1
|
|
16
|
use MARC::Field; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
535
|
use Template::Plugin::MARC::Subfield; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
509
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $AUTOLOAD; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
18
|
|
|
18
|
0
|
77
|
my ($class, $field) = @_; |
22
|
18
|
|
|
|
|
50
|
my $fieldhash = { |
23
|
|
|
|
|
|
|
'tag' => $field->tag(), |
24
|
|
|
|
|
|
|
'subfields' => [], |
25
|
|
|
|
|
|
|
}; |
26
|
18
|
100
|
|
|
|
254
|
if ($field->is_control_field()) { |
27
|
2
|
|
|
|
|
18
|
$fieldhash->{'value'} = $field->data(); |
28
|
2
|
|
|
|
|
20
|
push @{$fieldhash->{'subfields'}}, Template::Plugin::MARC::Subfield->new('@' => $field->data()); |
|
2
|
|
|
|
|
9
|
|
29
|
|
|
|
|
|
|
} else { |
30
|
16
|
|
|
|
|
95
|
$fieldhash->{'ind1'} = $field->indicator(1); |
31
|
16
|
|
|
|
|
161
|
$fieldhash->{'ind2'} = $field->indicator(2); |
32
|
16
|
|
|
|
|
159
|
my @subfields = $field->subfields(); |
33
|
16
|
|
|
|
|
267
|
foreach my $subf (@subfields) { |
34
|
28
|
100
|
|
|
|
105
|
$fieldhash->{"s$subf->[0]"} = $subf->[1] unless $fieldhash->{"s$subf->[0]"}; |
35
|
28
|
100
|
|
|
|
63
|
$fieldhash->{'all'} .= ' ' if $fieldhash->{'all'}; |
36
|
28
|
|
|
|
|
60
|
$fieldhash->{'all'} .= $subf->[1]; |
37
|
28
|
|
|
|
|
32
|
push @{$fieldhash->{'subfields'}}, Template::Plugin::MARC::Subfield->new($subf->[0] => $subf->[1]); |
|
28
|
|
|
|
|
181
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
18
|
|
|
|
|
80
|
return bless $fieldhash, $class; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub has { |
45
|
47
|
|
|
47
|
0
|
64
|
my ($self, $selector, $match) = @_; |
46
|
|
|
|
|
|
|
|
47
|
47
|
100
|
100
|
|
|
238
|
unless ($selector eq 'ind1' || $selector eq 'ind2' || $selector eq 'tag') { |
|
|
|
100
|
|
|
|
|
48
|
18
|
|
|
|
|
33
|
$selector = "s$selector"; # Everything else is a subfield |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
47
|
100
|
100
|
|
|
270
|
return $self->{$selector} eq $match if (defined $self->{$selector} && defined $match); |
52
|
19
|
|
|
|
|
82
|
return defined $self->{$selector}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub filter { |
56
|
1
|
|
|
1
|
0
|
3
|
my ($self, $selectors) = @_; |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
3
|
my $result = ''; |
59
|
1
|
|
|
|
|
4
|
foreach my $selector (keys %$selectors) { |
60
|
1
|
50
|
|
|
|
5
|
if ($selector eq 'code') { |
61
|
1
|
|
|
|
|
2
|
foreach my $subf (@{$self->{'subfields'}}) { |
|
1
|
|
|
|
|
3
|
|
62
|
4
|
100
|
|
|
|
15
|
if (index($selectors->{$selector}, $subf->code) >= 0) { |
63
|
2
|
100
|
|
|
|
7
|
$result .= ' ' if $result; |
64
|
2
|
|
|
|
|
6
|
$result .= $subf->value; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
1
|
|
|
|
|
5
|
return $result; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub AUTOLOAD { |
73
|
49
|
|
|
49
|
|
4554
|
my $self = shift; |
74
|
49
|
|
|
|
|
194
|
(my $a = $AUTOLOAD) =~ s/.*:://; |
75
|
|
|
|
|
|
|
|
76
|
49
|
|
|
|
|
200
|
return $self->{"$a"}; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |