line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Page::Navigation; |
2
|
2
|
|
|
2
|
|
140506
|
use strict; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
58
|
|
3
|
2
|
|
|
2
|
|
19
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
66
|
|
4
|
2
|
|
|
2
|
|
911
|
use Data::Page; |
|
2
|
|
|
|
|
11624
|
|
|
2
|
|
|
|
|
13
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package |
9
|
|
|
|
|
|
|
Data::Page; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/pages_per_navigation/); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub pages_in_navigation { |
14
|
15
|
|
|
15
|
0
|
4466
|
my $self = shift; |
15
|
|
|
|
|
|
|
|
16
|
15
|
|
|
|
|
44
|
my $last_page = $self->last_page; |
17
|
15
|
|
50
|
|
|
477
|
my $pages_per_navigation = shift || $self->pages_per_navigation || 10; |
18
|
15
|
100
|
|
|
|
137
|
return wantarray ? ($self->first_page..$last_page) : [($self->first_page..$last_page)] |
|
|
100
|
|
|
|
|
|
19
|
|
|
|
|
|
|
if $pages_per_navigation >= $last_page; |
20
|
|
|
|
|
|
|
|
21
|
13
|
|
|
|
|
26
|
my $prev = $self->current_page - 1; |
22
|
13
|
|
|
|
|
663
|
my $next = $self->current_page + 1; |
23
|
13
|
|
|
|
|
638
|
my @ret = ($self->current_page); |
24
|
13
|
|
|
|
|
648
|
my $i=0; |
25
|
13
|
|
|
|
|
30
|
while(@ret < $pages_per_navigation){ |
26
|
116
|
100
|
|
|
|
173
|
if($i%2){ |
27
|
53
|
100
|
|
|
|
97
|
unshift(@ret,$prev) if $self->first_page <= $prev; |
28
|
53
|
|
|
|
|
226
|
--$prev; |
29
|
|
|
|
|
|
|
}else{ |
30
|
63
|
100
|
|
|
|
122
|
push(@ret,$next) if $last_page >= $next; |
31
|
63
|
|
|
|
|
80
|
$next++; |
32
|
|
|
|
|
|
|
} |
33
|
116
|
|
|
|
|
211
|
$i++; |
34
|
|
|
|
|
|
|
} |
35
|
13
|
100
|
|
|
|
68
|
return wantarray ? @ret : \@ret; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub first_navigation_page { |
39
|
4
|
|
|
4
|
0
|
9
|
my $self = shift; |
40
|
4
|
|
|
|
|
9
|
my @pages = $self->pages_in_navigation; |
41
|
4
|
|
|
|
|
17
|
shift @pages; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub last_navigation_page { |
45
|
4
|
|
|
4
|
0
|
11
|
my $self = shift; |
46
|
4
|
|
|
|
|
9
|
my @pages = $self->pages_in_navigation; |
47
|
4
|
|
|
|
|
26
|
pop @pages; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
__END__ |