line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Application::Plugin::Flash; |
2
|
2
|
|
|
2
|
|
50749
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
181
|
|
3
|
2
|
|
|
2
|
|
1765
|
use CGI::Session::Flash; |
|
2
|
|
|
|
|
2452
|
|
|
2
|
|
|
|
|
49
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
107
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.02"; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Export our flash functions and set up the necessary CGI::Application |
10
|
|
|
|
|
|
|
# hooks. |
11
|
|
|
|
|
|
|
sub import |
12
|
|
|
|
|
|
|
{ |
13
|
2
|
|
|
2
|
|
12571
|
my $package = shift; |
14
|
2
|
|
|
|
|
6
|
my $caller = caller; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Export the flash methods |
17
|
|
|
|
|
|
|
{ |
18
|
2
|
|
|
2
|
|
9
|
no strict 'refs'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
554
|
|
|
2
|
|
|
|
|
5
|
|
19
|
2
|
|
|
|
|
6
|
*{"$caller\::flash"} = \&flash; |
|
2
|
|
|
|
|
13
|
|
20
|
2
|
|
|
|
|
5
|
*{"$caller\::flash_config"} = \&flash_config; |
|
2
|
|
|
|
|
10
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
2245
|
return 1; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Retrieve the flash object. This method also provides a convenient simple |
27
|
|
|
|
|
|
|
# syntax for setting and getting data from the flash. |
28
|
|
|
|
|
|
|
sub flash |
29
|
|
|
|
|
|
|
{ |
30
|
2
|
|
|
2
|
1
|
2244
|
my $self = shift; |
31
|
2
|
|
|
|
|
5
|
my $flash; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Create the flash object singleton. |
34
|
2
|
100
|
|
|
|
7
|
if (!defined $self->{'__CAP_FLASH_OBJECT'}) |
35
|
|
|
|
|
|
|
{ |
36
|
1
|
50
|
|
|
|
7
|
croak "Flash requires session support." unless ($self->can("session")); |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
5
|
$self->{'__CAP_FLASH_OBJECT'} = |
39
|
|
|
|
|
|
|
CGI::Session::Flash->new($self->session, $self->flash_config); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
2
|
|
|
|
|
60
|
$flash = $self->{'__CAP_FLASH_OBJECT'}; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Set or get the values for a specific key. |
45
|
2
|
50
|
|
|
|
6
|
if (@_) |
46
|
|
|
|
|
|
|
{ |
47
|
0
|
|
|
|
|
0
|
my $key = shift; |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
0
|
if (@_) |
50
|
|
|
|
|
|
|
{ |
51
|
0
|
|
|
|
|
0
|
$flash->set($key => @_); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
0
|
return $flash->get($key); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
# Return the flash object. |
57
|
|
|
|
|
|
|
else |
58
|
|
|
|
|
|
|
{ |
59
|
2
|
|
|
|
|
8
|
return $flash; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub flash_config |
64
|
|
|
|
|
|
|
{ |
65
|
5
|
|
|
5
|
1
|
1788
|
my $self = shift; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Set the values of the configuration. |
68
|
5
|
100
|
|
|
|
15
|
if (@_) |
69
|
|
|
|
|
|
|
{ |
70
|
1
|
50
|
|
|
|
7
|
croak "Invalid flash configuration. Specify a list of name and values." |
71
|
|
|
|
|
|
|
if (@_ % 2 == 1); |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
5
|
$self->{'__CAP_FLASH_CONFIG'} = { @_ }; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Return the config. |
77
|
5
|
|
100
|
|
|
16
|
my $config = $self->{'__CAP_FLASH_CONFIG'} || { }; |
78
|
5
|
100
|
|
|
|
29
|
return wantarray ? %$config : $config; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
__END__ |