line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# --*-Perl-*-- |
2
|
|
|
|
|
|
|
# $Id: Name.pm 11 2004-11-22 23:56:20Z tandler $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package PBib::LabelStyle::Name; |
6
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
7
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
8
|
|
|
|
|
|
|
#use English; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# for debug: |
11
|
1
|
|
|
1
|
|
5
|
use Data::Dumper; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
78
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
BEGIN { |
14
|
1
|
|
|
1
|
|
6
|
use vars qw($Revision $VERSION); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
109
|
|
15
|
1
|
50
|
|
1
|
|
3
|
my $major = 1; q$Revision: 11 $ =~ /: (\d+)/; my ($minor) = ($1); $VERSION = "$major." . ($minor<10 ? '0' : '') . $minor;
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# superclass |
19
|
1
|
|
|
1
|
|
5
|
use base qw(PBib::LabelStyle); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
83
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# used modules |
22
|
1
|
|
|
1
|
|
12
|
use Biblio::Util; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
887
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# module variables |
25
|
|
|
|
|
|
|
#use vars qw(mmmm); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# |
28
|
|
|
|
|
|
|
# label & field options |
29
|
|
|
|
|
|
|
# |
30
|
|
|
|
|
|
|
|
31
|
110
|
|
|
110
|
0
|
125
|
sub etalItalics { my ($self, $options) = @_; |
32
|
|
|
|
|
|
|
# how many authors until I use the "et al." style? |
33
|
110
|
|
|
|
|
244
|
return $self->fieldOption("etal-italics", $options); # || 1; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# |
37
|
|
|
|
|
|
|
# |
38
|
|
|
|
|
|
|
# methods |
39
|
|
|
|
|
|
|
# |
40
|
|
|
|
|
|
|
# |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub text { |
43
|
|
|
|
|
|
|
# |
44
|
|
|
|
|
|
|
# return the replacement text |
45
|
|
|
|
|
|
|
# |
46
|
141
|
|
|
141
|
0
|
166
|
my ($self, $refID, $options) = @_; |
47
|
141
|
|
|
|
|
541
|
my $label = $self->PBib::LabelStyle::text($refID, $options); |
48
|
141
|
|
|
|
|
313
|
my $inline = $self->{'inlineLabels'}->{$refID}; |
49
|
141
|
|
|
|
|
252
|
my $postfix = $self->{'labelPostfixes'}->{$refID}; |
50
|
141
|
50
|
|
|
|
333
|
if( $self->suppressAuthor($options) ) { |
51
|
0
|
|
|
|
|
0
|
return "($postfix)"; |
52
|
|
|
|
|
|
|
} |
53
|
141
|
100
|
|
|
|
407
|
if( $self->inlineField($options) ) { |
54
|
8
|
|
|
|
|
33
|
return "$inline ($postfix)"; |
55
|
|
|
|
|
|
|
} |
56
|
133
|
|
|
|
|
421
|
return $label; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub formatLabel { |
61
|
|
|
|
|
|
|
# |
62
|
|
|
|
|
|
|
# return the label (cite key) for this reference |
63
|
|
|
|
|
|
|
# can be overwritten by subclasses |
64
|
|
|
|
|
|
|
# to implement more sophisticated styles |
65
|
|
|
|
|
|
|
# the default implementation is rather simple ... |
66
|
|
|
|
|
|
|
# |
67
|
112
|
|
|
112
|
0
|
151
|
my ($self, $refID, $options) = @_; |
68
|
112
|
|
|
|
|
253
|
$self->setRefID($refID); |
69
|
112
|
|
|
|
|
122
|
my $inlineLabels = $self->{'inlineLabels'}; |
70
|
112
|
100
|
|
|
|
200
|
$inlineLabels = $self->{'inlineLabels'} = {} unless defined($inlineLabels); |
71
|
112
|
|
|
|
|
140
|
my $labelPostfixes = $self->{'labelPostfixes'}; |
72
|
112
|
100
|
|
|
|
174
|
$labelPostfixes = $self->{'labelPostfixes'} = {} unless defined($labelPostfixes); |
73
|
112
|
|
|
|
|
307
|
my $label = $self->formatInlineLabel($refID, $options); |
74
|
112
|
|
|
|
|
222
|
my $postfix = $self->formatLabelPostfix($refID, $options); |
75
|
112
|
|
|
|
|
232
|
$inlineLabels->{$refID} = $label; |
76
|
112
|
|
|
|
|
159
|
$labelPostfixes->{$refID} = $postfix; |
77
|
112
|
50
|
|
|
|
197
|
if( $postfix ) { |
78
|
112
|
|
|
|
|
192
|
$label = "$label, $postfix"; |
79
|
|
|
|
|
|
|
} |
80
|
112
|
|
|
|
|
283
|
return $label; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub formatSeparators { |
84
|
116
|
|
|
116
|
0
|
155
|
my ($self, $refField, $options) = @_; |
85
|
|
|
|
|
|
|
# replace comma as reference separator with semicolon |
86
|
116
|
|
|
|
|
208
|
$refField =~ s/,\s*\[/; \[/g; |
87
|
116
|
|
|
|
|
255
|
return $refField; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
sub formatField { |
90
|
116
|
|
|
116
|
0
|
156
|
my ($self, $refField, $options) = @_; |
91
|
116
|
50
|
|
|
|
259
|
return "[$refField]" if $self->useBraces($options); |
92
|
|
|
|
|
|
|
### useBraces is somehow quite limited and doesn't work |
93
|
|
|
|
|
|
|
### with inline! (it can ignore suppressAuthor and noParens) |
94
|
116
|
50
|
|
|
|
301
|
return $refField if $self->suppressAuthor($options); |
95
|
116
|
100
|
|
|
|
301
|
return $refField if $self->inlineField($options); |
96
|
108
|
50
|
|
|
|
288
|
return $refField if $self->noParens($options); |
97
|
108
|
|
|
|
|
391
|
return "($refField)"; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub formatInlineLabel { |
102
|
112
|
|
|
112
|
0
|
129
|
my ($self, $refID, $options) = @_; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# first check if there is a Key defined |
105
|
112
|
|
|
|
|
245
|
my $label = $self->entry('Key'); |
106
|
112
|
50
|
|
|
|
221
|
return $label if $label; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# next, check for Authors or Editors |
109
|
112
|
|
66
|
|
|
233
|
my $names = $self->entry('Authors') || $self->entry('Editors'); |
110
|
112
|
100
|
|
|
|
211
|
if( $names ) { |
111
|
110
|
|
|
|
|
267
|
my $itemStyle = $self->itemStyle(); |
112
|
110
|
|
|
|
|
282
|
my @name_array = $itemStyle->split_names($names, 'xname'); |
113
|
|
|
|
|
|
|
# print Dumper $names, \@name_array; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# how many authors do we have? use et al.? |
116
|
110
|
100
|
|
|
|
345
|
if( scalar(@name_array) >= $self->etalNumber() ) { |
|
|
50
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# there are too many authors, use "first et al." |
118
|
50
|
|
|
|
|
141
|
$label = $itemStyle->last_name($name_array[0]) . " et al."; |
119
|
|
|
|
|
|
|
} elsif( $name_array[-1] eq "et al." ) { |
120
|
|
|
|
|
|
|
# if the last author is "et al.", only use the first |
121
|
0
|
|
|
|
|
0
|
$label = $itemStyle->last_name($name_array[0]) . " et al."; |
122
|
|
|
|
|
|
|
} else { |
123
|
60
|
|
|
|
|
177
|
$label = Biblio::Util::join_and_list(map($itemStyle->last_name($_), @name_array)); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# pretty print "et al." |
127
|
110
|
50
|
|
|
|
308
|
if( $self->etalItalics() ) { |
128
|
110
|
|
|
|
|
364
|
$label =~ s/et al./ $self->outDoc()->italic('et al.') /eg; |
|
50
|
|
|
|
|
130
|
|
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
} |
131
|
112
|
100
|
|
|
|
404
|
return $label if $label; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# still no label -> try Organization etc. |
134
|
2
|
|
0
|
|
|
10
|
$label = $self->entry('Organization') |
135
|
|
|
|
|
|
|
|| $self->entry('Instritution') |
136
|
|
|
|
|
|
|
|| $self->entry('School') |
137
|
|
|
|
|
|
|
|| $self->entry('Project'); |
138
|
2
|
50
|
|
|
|
8
|
return $label if $label; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# default: use CiteKey (not nice) ... |
141
|
0
|
|
|
|
|
0
|
$self->warn("use CiteKey as label for $refID"); |
142
|
0
|
|
|
|
|
0
|
return $refID; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub formatLabelPostfix { |
146
|
112
|
|
|
112
|
0
|
139
|
my ($self, $refID, $options) = @_; |
147
|
112
|
|
|
|
|
251
|
my $label = $self->entry('Year'); |
148
|
112
|
|
|
|
|
225
|
return $label; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
1; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# |
156
|
|
|
|
|
|
|
# $Log: Name.pm,v $ |
157
|
|
|
|
|
|
|
# Revision 1.8 2003/09/30 14:35:12 tandler |
158
|
|
|
|
|
|
|
# useBraces option for Label styles, not really nicely implemented, i.e. should be changed ... |
159
|
|
|
|
|
|
|
# |
160
|
|
|
|
|
|
|
# Revision 1.7 2003/09/23 11:40:08 tandler |
161
|
|
|
|
|
|
|
# new label-style option :noparens |
162
|
|
|
|
|
|
|
# use Biblio::Util's xname mode in splitname |
163
|
|
|
|
|
|
|
# |
164
|
|
|
|
|
|
|
# Revision 1.6 2003/06/12 22:11:26 tandler |
165
|
|
|
|
|
|
|
# improved handling of the "Key" field |
166
|
|
|
|
|
|
|
# |
167
|
|
|
|
|
|
|
# Revision 1.5 2002/11/05 18:31:20 peter |
168
|
|
|
|
|
|
|
# suppressAthor option -- temporary fix in formatField |
169
|
|
|
|
|
|
|
# |
170
|
|
|
|
|
|
|
# Revision 1.4 2002/11/03 22:16:43 peter |
171
|
|
|
|
|
|
|
# suppress author option |
172
|
|
|
|
|
|
|
# |
173
|
|
|
|
|
|
|
# Revision 1.3 2002/09/23 11:07:29 peter |
174
|
|
|
|
|
|
|
# et al. set in italics |
175
|
|
|
|
|
|
|
# |
176
|
|
|
|
|
|
|
# Revision 1.2 2002/03/27 10:23:15 Diss |
177
|
|
|
|
|
|
|
# small fixes ... |
178
|
|
|
|
|
|
|
# |
179
|
|
|
|
|
|
|
# Revision 1.1 2002/03/27 10:00:51 Diss |
180
|
|
|
|
|
|
|
# new module structure, not yet included in LitRefs/LitUI (R2) |
181
|
|
|
|
|
|
|
# |