line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Split::Pager; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
746
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw( Class::Accessor::Fast ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1176
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw( total_pages prev_page next_page )); |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4837
|
use HTML::Split; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
350
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
1
|
|
|
1
|
1
|
15
|
my $class = shift; |
13
|
1
|
|
|
|
|
5
|
my %param = @_; |
14
|
|
|
|
|
|
|
|
15
|
1
|
50
|
|
|
|
5
|
return warn q{'html' is required} unless $param{html}; |
16
|
1
|
50
|
|
|
|
5
|
return warn q{'length' is required} unless $param{length}; |
17
|
1
|
50
|
|
|
|
8
|
return warn q{'length' is not numeric.} unless $param{length} =~ /^\d+$/; |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
50
|
|
|
19
|
my @pages = HTML::Split->split( |
20
|
|
|
|
|
|
|
html => $param{html}, |
21
|
|
|
|
|
|
|
length => $param{length}, |
22
|
|
|
|
|
|
|
extend_tags => $param{extend_tags} || [], |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
6
|
my $self = bless { |
26
|
|
|
|
|
|
|
pages => \@pages, |
27
|
|
|
|
|
|
|
total_pages => scalar @pages, |
28
|
|
|
|
|
|
|
}, $class; |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
7
|
$self->current_page(1); |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
4
|
return $self; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub current_page { |
36
|
6
|
|
|
6
|
1
|
13
|
my ($self, $page) = @_; |
37
|
6
|
100
|
66
|
|
|
22
|
if (defined $page && $page > 0) { |
38
|
2
|
|
|
|
|
12
|
$self->{current_page} = $page; |
39
|
2
|
100
|
|
|
|
10
|
$self->{prev_page} = ($page - 1 > 0) ? $page - 1 : undef; |
40
|
2
|
100
|
|
|
|
10
|
$self->{next_page} = ($page + 1 <= $self->total_pages) ? $page + 1 : undef; |
41
|
2
|
|
|
|
|
16
|
return $self; |
42
|
|
|
|
|
|
|
} |
43
|
4
|
|
|
|
|
19
|
return $self->{current_page}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub text { |
47
|
2
|
|
|
2
|
1
|
12
|
my $self = shift; |
48
|
2
|
50
|
|
|
|
10
|
return wantarray ? @{ $self->{pages} } |
|
0
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
: $self->{pages}[$self->current_page - 1]; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
__END__ |