line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Menu::Pages; |
2
|
2
|
|
|
2
|
|
3126
|
use Template::Quick; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
105
|
|
3
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
33
|
|
4
|
2
|
|
|
2
|
|
8
|
use utf8; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
14
|
|
5
|
2
|
|
|
2
|
|
47
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
87
|
|
6
|
|
|
|
|
|
|
require Exporter; |
7
|
2
|
|
|
|
|
1603
|
use vars qw( |
8
|
|
|
|
|
|
|
$DefaultClass |
9
|
|
|
|
|
|
|
@EXPORT |
10
|
|
|
|
|
|
|
@ISA |
11
|
|
|
|
|
|
|
$action |
12
|
|
|
|
|
|
|
$length |
13
|
|
|
|
|
|
|
$nStart |
14
|
|
|
|
|
|
|
$sStyle |
15
|
|
|
|
|
|
|
$append |
16
|
|
|
|
|
|
|
$pages |
17
|
|
|
|
|
|
|
$path |
18
|
|
|
|
|
|
|
$per_page |
19
|
|
|
|
|
|
|
$server |
20
|
2
|
|
|
2
|
|
7
|
); |
|
2
|
|
|
|
|
2
|
|
21
|
|
|
|
|
|
|
@HTML::Menu::Pages::EXPORT = qw(makePages); |
22
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
23
|
|
|
|
|
|
|
$HTML::Menu::Pages::VERSION = '1.11'; |
24
|
|
|
|
|
|
|
$DefaultClass = 'HTML::Menu::Pages' unless defined $HTML::Menu::Pages::DefaultClass; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 NAME |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
HTML::Menu::Pages - Create html anchors |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 SYNOPSIS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use HTML::Menu::Pages; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 OO Syntax. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $test = new HTML::Menu::Pages; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my %needed =( |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
length => '345', |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
style => 'mysql', |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
mod_rewrite => 0, |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
action => 'dbs', |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
start => param('von') ? param('von') : 0, |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
path => "/srv/www/cgi-bin/", |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
append => '?queryString=testit' |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
print $test->makePages(\%needed ); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 FO Syntax. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my %needed =( |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
length => '345', |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
style => 'mysql', |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
mod_rewrite => 0, |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
action => 'dbs', |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
start => param('von') ? param('von') : 0, |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
path => "/srv/www/cgi-bin/", |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
append => '?queryString=testit', |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
links_pro_page => 30 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
print makePages(\%needed ); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# |
83
|
|
|
|
|
|
|
=head2 Changes |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
0.37 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
links_pro_page option |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 EXPORT |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
makePages |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 Public |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 Public new() |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub new { |
102
|
2
|
|
|
2
|
1
|
4552
|
my ($class, @initializer) = @_; |
103
|
2
|
|
|
|
|
8
|
my $self = {}; |
104
|
2
|
|
33
|
|
|
30
|
bless $self, ref $class || $class || $DefaultClass; |
105
|
2
|
|
|
|
|
9
|
return $self; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 makePages() |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
see SYNOPSIS |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub makePages { |
115
|
2
|
|
|
2
|
1
|
53
|
my ($self, @p) = getSelf(@_); |
116
|
2
|
|
|
|
|
4
|
my $hashref = $p[0]; |
117
|
2
|
|
|
|
|
8
|
$action = $hashref->{action}; |
118
|
2
|
50
|
|
|
|
11
|
$server = defined $hashref->{server} ? $hashref->{server} : $ENV{SCRIPT_NAME}; |
119
|
2
|
50
|
|
|
|
15
|
$nStart = $hashref->{start} > 0 ? $hashref->{start} : 0; |
120
|
2
|
|
|
|
|
4
|
$sStyle = $hashref->{style}; |
121
|
2
|
50
|
|
|
|
9
|
$append = $hashref->{append} ? $hashref->{append} : ''; |
122
|
2
|
50
|
|
|
|
13
|
$length = $hashref->{length} ? $hashref->{length} : 0; |
123
|
2
|
50
|
|
|
|
8
|
$pages = $hashref->{title} ? $hashref->{title} : 'Pages'; |
124
|
2
|
100
|
|
|
|
8
|
$path = $hashref->{path} ? $hashref->{path} : 'cgi-bin/'; |
125
|
2
|
50
|
|
|
|
7
|
$per_page = $hashref->{links_pro_page} ? $hashref->{links_pro_page} : 10; |
126
|
2
|
50
|
|
|
|
16
|
$self->ebis() if ($length > $per_page); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 ebis() |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
private |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub ebis { |
136
|
2
|
|
|
2
|
1
|
7
|
my ($self, @p) = getSelf(@_); |
137
|
2
|
50
|
|
|
|
11
|
my $previousPage = (($nStart - $per_page) > 0) ? $nStart - $per_page : 0; |
138
|
2
|
|
|
|
|
5
|
my $nextPage = $nStart; |
139
|
2
|
50
|
|
|
|
8
|
$nextPage = $per_page if ($previousPage <= 0); |
140
|
2
|
|
|
|
|
17
|
my %template = ( |
141
|
|
|
|
|
|
|
path => "$path/templates", |
142
|
|
|
|
|
|
|
style => $sStyle, |
143
|
|
|
|
|
|
|
template => "pages.htm", |
144
|
|
|
|
|
|
|
name => 'pages' |
145
|
|
|
|
|
|
|
); |
146
|
2
|
|
|
|
|
22
|
my @data = ( |
147
|
|
|
|
|
|
|
{ |
148
|
|
|
|
|
|
|
name => 'header', |
149
|
|
|
|
|
|
|
pages => '150
|
|
|
|
|
|
|
. ("javascript:requestURI('$server?action=$action&$append','$action','$action')") |
151
|
|
|
|
|
|
|
. '">' |
152
|
|
|
|
|
|
|
. $pages . '', |
153
|
|
|
|
|
|
|
}, |
154
|
|
|
|
|
|
|
); |
155
|
2
|
50
|
|
|
|
24
|
push @data, |
156
|
|
|
|
|
|
|
{ |
157
|
|
|
|
|
|
|
name => "previous", |
158
|
|
|
|
|
|
|
href => |
159
|
|
|
|
|
|
|
"javascript:requestURI('$server?von=$previousPage&bis=$nextPage&action=$action&$append','$action','$action')", |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
if ($nStart - $per_page >= 0); |
162
|
2
|
|
|
|
|
4
|
my $sites = 1; |
163
|
|
|
|
|
|
|
|
164
|
2
|
50
|
|
|
|
21
|
if ($length > 1) { |
165
|
2
|
50
|
|
|
|
7
|
if ($length % $per_page == 0) { |
166
|
0
|
|
|
|
|
0
|
$sites = (int($length / $per_page)) * 10; |
167
|
|
|
|
|
|
|
} else { |
168
|
2
|
|
|
|
|
14
|
$sites = (int($length / $per_page) + 1) * 10; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
} |
171
|
2
|
|
|
|
|
5
|
my $beginn = $nStart / $per_page; |
172
|
2
|
50
|
|
|
|
8
|
$beginn = (int($nStart / $per_page) + 1) * 10 unless ($nStart % $per_page == 0); |
173
|
2
|
50
|
|
|
|
9
|
$beginn = 0 if ($beginn < 0); |
174
|
2
|
50
|
|
|
|
8
|
my $b = ($sites >= 10) ? $beginn : 0; |
175
|
2
|
50
|
|
|
|
9
|
$b = ($beginn - $per_page >= 0) ? $beginn - $per_page : 0; |
176
|
2
|
|
|
|
|
5
|
my $h1 = (($nStart - ($per_page * 5)) / $per_page); |
177
|
2
|
50
|
|
|
|
5
|
$b = $h1 if ($h1 > 0); |
178
|
2
|
50
|
|
|
|
9
|
my $m_nEnd = ($sites >= 10) ? $b + 10 : $sites; |
179
|
2
|
|
|
|
|
2
|
$b = int($b); |
180
|
2
|
|
|
|
|
4
|
$m_nEnd = int($m_nEnd); |
181
|
|
|
|
|
|
|
|
182
|
2
|
|
|
|
|
6
|
while ($b <= $m_nEnd) { # append links |
183
|
22
|
|
|
|
|
18
|
my $c = $b * $per_page; |
184
|
22
|
|
|
|
|
17
|
my $d = $c + $per_page; |
185
|
22
|
50
|
|
|
|
27
|
$d = $length if ($d > $length); |
186
|
22
|
|
|
|
|
44
|
my $svbis = |
187
|
|
|
|
|
|
|
"javascript:requestURI('$server?von=$c&bis=$d&action=$action&$append','$action','$action')"; |
188
|
22
|
100
|
|
|
|
54
|
push @data, |
189
|
|
|
|
|
|
|
($b * $per_page eq $nStart) |
190
|
|
|
|
|
|
|
? { |
191
|
|
|
|
|
|
|
name => 'currentLinks', |
192
|
|
|
|
|
|
|
href => $svbis, |
193
|
|
|
|
|
|
|
title => $b + 1, |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
: { |
196
|
|
|
|
|
|
|
name => 'links', |
197
|
|
|
|
|
|
|
href => $svbis, |
198
|
|
|
|
|
|
|
title => $b + 1, |
199
|
|
|
|
|
|
|
}; |
200
|
22
|
50
|
|
|
|
30
|
last if ($d eq $length); |
201
|
22
|
|
|
|
|
28
|
$b++; |
202
|
|
|
|
|
|
|
} |
203
|
2
|
|
|
|
|
2
|
my $v = $nStart + $per_page; |
204
|
2
|
|
|
|
|
4
|
my $next = $v + $per_page; |
205
|
2
|
50
|
|
|
|
7
|
$next = $length if ($next > $length); |
206
|
2
|
|
|
|
|
11
|
my $esvbis = |
207
|
|
|
|
|
|
|
"javascript:requestURI('$server?von=$v&bis=$next&action=$action&$append','$action','$action')"; |
208
|
2
|
50
|
|
|
|
13
|
push @data, |
209
|
|
|
|
|
|
|
{ |
210
|
|
|
|
|
|
|
name => "next", |
211
|
|
|
|
|
|
|
href => $esvbis |
212
|
|
|
|
|
|
|
} if ($v < $length); # apend the Next "button" |
213
|
2
|
|
|
|
|
5
|
push @data, {name => 'footer'}; # apend the footer |
214
|
2
|
|
|
|
|
15
|
return initTemplate(\%template, \@data); |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head2 getSelf() |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
privat see L |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=cut |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
sub getSelf { |
224
|
4
|
50
|
33
|
4
|
1
|
32
|
return @_ if defined($_[0]) && (!ref($_[0])) && ($_[0] eq 'HTML::Menu::Pages'); |
|
|
|
33
|
|
|
|
|
225
|
4
|
50
|
33
|
|
|
37
|
return (defined($_[0]) |
226
|
|
|
|
|
|
|
&& (ref($_[0]) eq 'HTML::Menu::Pages' || UNIVERSAL::isa($_[0], 'HTML::Menu::Pages'))) |
227
|
|
|
|
|
|
|
? @_ |
228
|
|
|
|
|
|
|
: ($HTML::Menu::Pages::DefaultClass->new, @_); |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head1 AUTHOR |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Dirk Lindner |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head2 see Also |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
L L L L L L |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head1 LICENSE |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Copyright (C) 2005 - 2015 by Hr. Dirk Lindner |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
246
|
|
|
|
|
|
|
modify it under the terms of the GNU Lesser General Public License |
247
|
|
|
|
|
|
|
as published by the Free Software Foundation; |
248
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
249
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
250
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
251
|
|
|
|
|
|
|
GNU Lesser General Public License for more details. |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=cut |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
1; |