line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::PageIndex; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7064
|
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
76
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
636
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Exporter; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
@ISA=qw(Exporter); |
9
|
|
|
|
|
|
|
@EXPORT=qw(); |
10
|
|
|
|
|
|
|
@EXPORT_OK=qw(); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$VERSION = '0.3'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
0
|
|
|
0
|
0
|
|
my ($class) = @_; |
16
|
0
|
|
|
|
|
|
my ($self) = {}; |
17
|
0
|
|
|
|
|
|
bless ($self, $class); |
18
|
0
|
|
|
|
|
|
return $self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
################################################################################ |
22
|
|
|
|
|
|
|
# Public methods |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub makeindex { |
25
|
0
|
|
|
0
|
1
|
|
my ($self, $total, $current, $Base, $Arg, $np) =@_; |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
if (!$Base) { print __PACKAGE__.": Base URL not provided"; return;} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$self->{'BASE'} = $Base; |
30
|
0
|
0
|
|
|
|
|
$self->{'ARG'} = $Arg if $Arg; |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
if ($total <= 1) { |
33
|
0
|
|
|
|
|
|
return ""; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Handle defaults and guard against absurd input values |
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
$current = 1 if $current < 1; |
39
|
0
|
0
|
|
|
|
|
$current = $total if $current > $total; |
40
|
0
|
0
|
|
|
|
|
$np=0 if !$np; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return $self->_text_numbers($total, $current,$np); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
################################################################################ |
48
|
|
|
|
|
|
|
# Private methods |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _text_numbers { |
51
|
0
|
|
|
0
|
|
|
my ($self, $total, $current,$np) = @_; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my ($prev) = $current - 1; |
54
|
0
|
|
|
|
|
|
my ($next) = $current + 1; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my ($out); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Display [Prev] unless on first page |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
if ($current > 1) { |
61
|
0
|
|
|
|
|
|
$out .= "
|
62
|
|
|
|
|
|
|
$self->_url($prev) . |
63
|
|
|
|
|
|
|
"\"> [Prev] \n"; |
64
|
|
|
|
|
|
|
} else { |
65
|
0
|
0
|
|
|
|
|
if ($np > 0) { |
66
|
0
|
|
|
|
|
|
$out .= " [Prev] \n"; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Display 1 2 3 etc... |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my ($i); |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
for ($i = 1; $i<=$total; $i++) { |
75
|
0
|
0
|
|
|
|
|
if ($i == $current) { |
76
|
0
|
|
|
|
|
|
$out .= " $i \n"; |
77
|
|
|
|
|
|
|
} else { |
78
|
0
|
|
|
|
|
|
$out .= "
|
79
|
|
|
|
|
|
|
$self->_url($i) . |
80
|
|
|
|
|
|
|
"\"> $i \n"; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Display [Next] unless on last page |
85
|
|
|
|
|
|
|
|
86
|
0
|
0
|
|
|
|
|
if ($current < $total) { |
87
|
0
|
|
|
|
|
|
$out .= "
|
88
|
|
|
|
|
|
|
$self->_url($next) . |
89
|
|
|
|
|
|
|
"\"> [Next] \n"; |
90
|
|
|
|
|
|
|
} else { |
91
|
0
|
0
|
|
|
|
|
if ($np > 0) { |
92
|
0
|
|
|
|
|
|
$out .= " [Next] \n"; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
return $out; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub _url { |
100
|
0
|
|
|
0
|
|
|
my ($self, $tagValue) = @_; |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
my ($url) = $self->{'BASE'}; |
103
|
0
|
|
|
|
|
|
my ($arg) = $self->{'ARG'}; |
104
|
|
|
|
|
|
|
|
105
|
0
|
0
|
|
|
|
|
if ($arg) { |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
$url =~ s/\&$arg=[^&]*//g; |
108
|
0
|
|
|
|
|
|
$url =~ s/\?$arg=[^&]*&/?/g; |
109
|
0
|
|
|
|
|
|
$url =~ s/\?$arg=[^&]*$//; |
110
|
|
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
|
if ($url =~ /\?/) { |
112
|
0
|
|
|
|
|
|
$url .= "&$arg=$tagValue"; |
113
|
|
|
|
|
|
|
} else { |
114
|
0
|
|
|
|
|
|
$url .= "?$arg=$tagValue"; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
return $url; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; # wheeee; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
__END__ |