line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Web::Sitemap::Url; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.902_2'; |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
30
|
use strict; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
138
|
|
6
|
4
|
|
|
4
|
|
24
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
93
|
|
7
|
4
|
|
|
4
|
|
22
|
use utf8; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
24
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
85
|
use Carp; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
2396
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
50044
|
|
|
50044
|
0
|
142681
|
my ($class, $data, %p) = @_; |
13
|
|
|
|
|
|
|
|
14
|
50044
|
|
|
|
|
82633
|
my %allowed_keys = map { $_ => 1 } qw( |
|
100088
|
|
|
|
|
199144
|
|
15
|
|
|
|
|
|
|
mobile loc_prefix |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
50044
|
|
|
|
|
108547
|
my @bad_keys = grep { !exists $allowed_keys{$_} } keys %p; |
|
100088
|
|
|
|
|
208220
|
|
19
|
50044
|
50
|
|
|
|
113484
|
croak "Unknown parameters: @bad_keys" if @bad_keys; |
20
|
|
|
|
|
|
|
|
21
|
50044
|
|
|
|
|
145548
|
my $self = { |
22
|
|
|
|
|
|
|
mobile => 0, |
23
|
|
|
|
|
|
|
loc_prefix => '', |
24
|
|
|
|
|
|
|
%p, # actual input values |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
|
27
|
50044
|
100
|
|
|
|
99345
|
if (not ref $data) { |
|
|
50
|
|
|
|
|
|
28
|
50041
|
50
|
|
|
|
93362
|
croak 'Web::Sitemap::Url first argument must be defined' |
29
|
|
|
|
|
|
|
unless defined $data; |
30
|
50041
|
|
|
|
|
78299
|
$self->{loc} = $data; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
elsif (ref $data eq 'HASH') { |
33
|
3
|
50
|
|
|
|
12
|
unless (defined $data->{loc}) { |
34
|
0
|
|
|
|
|
0
|
croak 'Web::Sitemap::Url first argument hash must have `loc` key defined'; |
35
|
|
|
|
|
|
|
} |
36
|
3
|
|
|
|
|
20
|
$self = { %$self, %$data }; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
0
|
|
|
|
|
0
|
croak 'Web::Sitemap::Url first argument must be a string or a hash reference'; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
50044
|
|
|
|
|
153754
|
return bless $self, $class; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub to_xml_string { |
46
|
50044
|
|
|
50044
|
0
|
82250
|
my ($self, %p) = @_; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
return sprintf( |
49
|
|
|
|
|
|
|
"\n%s%s%s%s%s", |
50
|
|
|
|
|
|
|
$self->{loc_prefix}, |
51
|
|
|
|
|
|
|
$self->{loc}, |
52
|
|
|
|
|
|
|
$self->{changefreq} ? sprintf('%s', $self->{changefreq}) : '', |
53
|
50044
|
50
|
|
|
|
136888
|
$self->{mobile} ? '' : '', |
|
|
50
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$self->_images_xml_string |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _images_xml_string { |
59
|
50044
|
|
|
50044
|
|
74207
|
my ($self) = @_; |
60
|
|
|
|
|
|
|
|
61
|
50044
|
|
|
|
|
68991
|
my $result = ''; |
62
|
|
|
|
|
|
|
|
63
|
50044
|
100
|
|
|
|
91415
|
if (defined $self->{images}) { |
64
|
3
|
|
|
|
|
5
|
my $i = 1; |
65
|
3
|
|
|
|
|
5
|
for my $image (@{$self->{images}{loc_list}}) { |
|
3
|
|
|
|
|
9
|
|
66
|
8
|
100
|
|
|
|
24
|
my $loc = ref $image eq 'HASH' ? $image->{loc} : $image; |
67
|
|
|
|
|
|
|
|
68
|
8
|
|
|
|
|
11
|
my $caption = ''; |
69
|
8
|
100
|
66
|
|
|
33
|
if (ref $image eq 'HASH' and defined $image->{caption}) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
70
|
4
|
|
|
|
|
9
|
$caption = $image->{caption}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
elsif (defined $self->{images}{caption_format_simple}) { |
73
|
2
|
|
|
|
|
7
|
$caption = $self->{images}{caption_format_simple}. " $i"; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
elsif (defined $self->{images}{caption_format}) { |
76
|
2
|
|
|
|
|
5
|
$caption = &{$self->{images}{caption_format}}($i); |
|
2
|
|
|
|
|
12
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
8
|
|
|
|
|
42
|
$result .= sprintf( |
80
|
|
|
|
|
|
|
"\n%s", |
81
|
|
|
|
|
|
|
$loc, $caption |
82
|
|
|
|
|
|
|
); |
83
|
|
|
|
|
|
|
|
84
|
8
|
|
|
|
|
18
|
$i++; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
50044
|
|
|
|
|
201176
|
return $result; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |