| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::Vsort; |
|
2
|
72
|
|
|
72
|
|
4631511
|
use Mojo::Base -strict; |
|
|
72
|
|
|
|
|
10286
|
|
|
|
72
|
|
|
|
|
543
|
|
|
3
|
72
|
|
|
72
|
|
7757
|
use Mojolicious::Plugin::Vparam::Common; |
|
|
72
|
|
|
|
|
169
|
|
|
|
72
|
|
|
|
|
24975
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub register { |
|
6
|
74
|
|
|
74
|
0
|
268
|
my ($class, $self, $app, $conf) = @_; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Same as vparams but add standart table sort parameters for: |
|
9
|
|
|
|
|
|
|
# ORDER BY, LIMIT, OFFSET |
|
10
|
|
|
|
|
|
|
$app->helper(vsort => sub{ |
|
11
|
12
|
|
|
12
|
|
43127
|
my ($self, %attr) = @_; |
|
12
|
|
|
|
|
|
|
|
|
13
|
12
|
|
|
|
|
36
|
my $sort = delete $attr{'-sort'}; |
|
14
|
12
|
100
|
100
|
|
|
96
|
die 'Key "-sort" must be ArrayRef' |
|
15
|
|
|
|
|
|
|
if defined($sort) and 'ARRAY' ne ref $sort; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$attr{ $conf->{vsort_page} } = { |
|
18
|
|
|
|
|
|
|
type => 'int', |
|
19
|
|
|
|
|
|
|
default => 1, |
|
20
|
11
|
100
|
|
|
|
77
|
} if defined $conf->{vsort_page}; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$attr{ $conf->{vsort_rws} } = { |
|
23
|
|
|
|
|
|
|
type => 'int', |
|
24
|
|
|
|
|
|
|
default => $conf->{rows}, |
|
25
|
11
|
100
|
|
|
|
63
|
} if defined $conf->{vsort_rws}; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$attr{ $conf->{vsort_oby} } = { |
|
28
|
|
|
|
|
|
|
type => 'int', |
|
29
|
|
|
|
|
|
|
default => 0, |
|
30
|
10
|
50
|
66
|
|
|
73
|
post => sub { $sort->[ $_[1] ] or ($_[1] + 1) or 1 }, |
|
31
|
11
|
100
|
|
|
|
95
|
} if defined $conf->{vsort_oby}; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$attr{ $conf->{vsort_ods} } = { |
|
34
|
|
|
|
|
|
|
type => 'str', |
|
35
|
|
|
|
|
|
|
default => $conf->{ods}, |
|
36
|
10
|
|
|
|
|
50
|
post => sub { uc $_[1] }, |
|
37
|
|
|
|
|
|
|
regexp => qr{^(?:asc|desc)$}i, |
|
38
|
11
|
100
|
|
|
|
114
|
} if defined $conf->{vsort_ods}; |
|
39
|
|
|
|
|
|
|
|
|
40
|
11
|
|
|
|
|
96
|
my $result = $self->vparams( %attr ); |
|
41
|
11
|
100
|
|
|
|
173
|
return wantarray ? %$result : $result; |
|
42
|
74
|
|
|
|
|
694
|
}); |
|
43
|
|
|
|
|
|
|
|
|
44
|
74
|
|
|
|
|
2089
|
return; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |