| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
XAO::DO::Web::Clipboard - clipboard value retrieval object. |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Currently is only useful in XAO::Web site context. |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Clipboard object is based on Action object (see L) |
|
12
|
|
|
|
|
|
|
and therefor what it does depends on the "mode" argument. |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
For each mode there is a separate method with usually very similar |
|
15
|
|
|
|
|
|
|
name. The list below lists mode names and their method counterparts. |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=over |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
############################################################################### |
|
22
|
|
|
|
|
|
|
package XAO::DO::Web::Clipboard; |
|
23
|
3
|
|
|
3
|
|
2116
|
use strict; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
92
|
|
|
24
|
3
|
|
|
3
|
|
15
|
use XAO::Utils; |
|
|
3
|
|
|
|
|
14
|
|
|
|
3
|
|
|
|
|
185
|
|
|
25
|
3
|
|
|
3
|
|
19
|
use XAO::Errors qw(XAO::DO::Web::Clipboard); |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
22
|
|
|
26
|
3
|
|
|
3
|
|
1195
|
use base XAO::Objects->load(objname => 'Web::Action'); |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
23
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION='2.001'; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub check_mode ($$) { |
|
31
|
55
|
|
|
55
|
0
|
101
|
my $self = shift; |
|
32
|
55
|
|
|
|
|
137
|
my $args = get_args(\@_); |
|
33
|
55
|
|
100
|
|
|
605
|
my $mode = $args->{mode} || 'show'; |
|
34
|
|
|
|
|
|
|
|
|
35
|
55
|
100
|
|
|
|
170
|
if ($mode eq 'set') { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
36
|
10
|
|
|
|
|
31
|
$self->clipboard_set($args); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
elsif ($mode eq 'show') { |
|
39
|
28
|
|
|
|
|
77
|
$self->clipboard_show($args); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
elsif ($mode eq 'array-push') { |
|
42
|
5
|
|
|
|
|
13
|
$self->clipboard_array_push($args); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
elsif ($mode eq 'array-size') { |
|
45
|
6
|
|
|
|
|
13
|
$self->clipboard_array_size($args); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
elsif ($mode eq 'array-pop') { |
|
48
|
3
|
|
|
|
|
16
|
$self->clipboard_array_pop($args); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
elsif ($mode eq 'array-list') { |
|
51
|
3
|
|
|
|
|
9
|
$self->clipboard_array_list($args); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
else { |
|
54
|
0
|
|
|
|
|
0
|
throw XAO::E::DO::Web::Clipboard "check_mode - unknown mode '$mode'"; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
############################################################################### |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item 'set' => clipboard_set (%) |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Sets a value in the clipboard. Example: |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
<%Clipboard mode='set' name='foo' value='bar'%> |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
If there is no 'value' argument it puts 'undef' into the clipboard, but |
|
67
|
|
|
|
|
|
|
does not remove the named record. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub clipboard_set ($%) { |
|
72
|
10
|
|
|
10
|
1
|
18
|
my $self = shift; |
|
73
|
10
|
|
|
|
|
22
|
my $args = get_args(\@_); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $name=$args->{name} || |
|
76
|
10
|
|
33
|
|
|
95
|
throw XAO::E::DO::Web::Clipboard "clipboard_set - no 'name' given"; |
|
77
|
|
|
|
|
|
|
|
|
78
|
10
|
|
|
|
|
48
|
$self->clipboard->put($name => $args->{value}); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
############################################################################### |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item 'show' => clipboard_show (%) |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Displays clipboard parameter with the given "name". Example: |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
<%Clipboard mode="show" name="username" default="aa@bb.com"%> |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Would display whatever is set in the Clipboard for variable |
|
90
|
|
|
|
|
|
|
"username" or "aa@bb.com" if it is not set. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub clipboard_show ($%) { |
|
95
|
28
|
|
|
28
|
1
|
48
|
my $self = shift; |
|
96
|
28
|
|
|
|
|
59
|
my $args = get_args(\@_); |
|
97
|
|
|
|
|
|
|
|
|
98
|
28
|
|
|
|
|
274
|
my $clipboard = $self->clipboard; |
|
99
|
|
|
|
|
|
|
$args->{name} || |
|
100
|
28
|
50
|
|
|
|
95
|
throw XAO::E::DO::Web::Clipboard "clipboard_show - no 'name' given"; |
|
101
|
|
|
|
|
|
|
|
|
102
|
28
|
|
|
|
|
85
|
my $value = $clipboard->get($args->{name}); |
|
103
|
28
|
100
|
100
|
|
|
1350
|
$value = $args->{default} if !defined($value) || ref($value); |
|
104
|
|
|
|
|
|
|
|
|
105
|
28
|
100
|
|
|
|
118
|
$self->textout($value) if defined $value; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
############################################################################### |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item 'array-push' => clipboard_array_push (%) |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Push a value into an array with the given "name". Example: |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
<%Clipboard mode='array-push' name='elements' value='Something'%> |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Displays nothing. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub clipboard_array_push ($%) { |
|
121
|
5
|
|
|
5
|
1
|
8
|
my $self = shift; |
|
122
|
5
|
|
|
|
|
10
|
my $args = get_args(\@_); |
|
123
|
|
|
|
|
|
|
|
|
124
|
5
|
|
33
|
|
|
43
|
my $name = $args->{'name'} || |
|
125
|
|
|
|
|
|
|
throw $self "- no 'name' given"; |
|
126
|
|
|
|
|
|
|
|
|
127
|
5
|
|
|
|
|
12
|
my $clipboard = $self->clipboard; |
|
128
|
|
|
|
|
|
|
|
|
129
|
5
|
|
|
|
|
13
|
my $array = $clipboard->get($name); |
|
130
|
|
|
|
|
|
|
|
|
131
|
5
|
100
|
66
|
|
|
244
|
if(!ref $array || ref $array ne 'ARRAY') { |
|
132
|
2
|
|
|
|
|
4
|
undef $array; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
5
|
100
|
|
|
|
11
|
if(!defined $array) { |
|
136
|
2
|
|
|
|
|
4
|
$array = []; |
|
137
|
2
|
|
|
|
|
7
|
$clipboard->put($name => $array); |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
5
|
|
|
|
|
65
|
push(@$array, $args->{'value'}); |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
############################################################################### |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item 'array-pop' => clipboard_array_pop (%) |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Output the topmost element of the given array. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
<%Clipboard mode='array-pop' name='elements'%> |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
If there is no array at that location, there is an empty array, or there |
|
152
|
|
|
|
|
|
|
is a non-array value, then there is no output. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub clipboard_array_pop ($%) { |
|
157
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
|
158
|
3
|
|
|
|
|
7
|
my $args = get_args(\@_); |
|
159
|
|
|
|
|
|
|
|
|
160
|
3
|
|
33
|
|
|
29
|
my $name = $args->{'name'} || |
|
161
|
|
|
|
|
|
|
throw $self "- no 'name' given"; |
|
162
|
|
|
|
|
|
|
|
|
163
|
3
|
|
|
|
|
9
|
my $array = $self->clipboard->get($name); |
|
164
|
|
|
|
|
|
|
|
|
165
|
3
|
50
|
66
|
|
|
153
|
if(ref $array && ref $array eq 'ARRAY' && @$array) { |
|
|
|
|
66
|
|
|
|
|
|
166
|
1
|
|
|
|
|
3
|
$self->textout(pop @$array); |
|
167
|
|
|
|
|
|
|
} |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
############################################################################### |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item 'array-list' => clipboard_array_list (%) |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Iterate over all array elements, displaying each element with the given |
|
175
|
|
|
|
|
|
|
template or path. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
<%Clipboard mode='array-list' name='elements' template='<$VALUE$>'%> |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=cut |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub clipboard_array_list ($%) { |
|
182
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
|
183
|
3
|
|
|
|
|
5
|
my $args = get_args(\@_); |
|
184
|
|
|
|
|
|
|
|
|
185
|
3
|
|
33
|
|
|
28
|
my $name = $args->{'name'} || |
|
186
|
|
|
|
|
|
|
throw $self "- no 'name' given"; |
|
187
|
|
|
|
|
|
|
|
|
188
|
3
|
|
|
|
|
8
|
my $array = $self->clipboard->get($name); |
|
189
|
|
|
|
|
|
|
|
|
190
|
3
|
50
|
33
|
|
|
157
|
(ref $array && ref $array eq 'ARRAY') || |
|
191
|
|
|
|
|
|
|
return; |
|
192
|
|
|
|
|
|
|
|
|
193
|
3
|
|
|
|
|
17
|
my $page=$self->object; |
|
194
|
|
|
|
|
|
|
|
|
195
|
3
|
|
|
|
|
220
|
for(my $i=0; $i < @$array; ++$i) { |
|
196
|
|
|
|
|
|
|
$page->display($page->pass_args($args->{'pass'}, $args),{ |
|
197
|
|
|
|
|
|
|
path => $args->{'path'}, |
|
198
|
7
|
|
50
|
|
|
36
|
template => $args->{'template'}, |
|
199
|
|
|
|
|
|
|
VALUE => $array->[$i] // '', |
|
200
|
|
|
|
|
|
|
INDEX => $i, |
|
201
|
|
|
|
|
|
|
SIZE => scalar @$array, |
|
202
|
|
|
|
|
|
|
}); |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
} |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
############################################################################### |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=item 'array-size' => clipboard_array_size (%) |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Output the number of elements in the given array. |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
<%Clipboard mode='array-size' name='elements'%> |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
If there is no array at that location or there is a non-array value, |
|
215
|
|
|
|
|
|
|
then there is no output. |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=cut |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
sub clipboard_array_size ($%) { |
|
220
|
6
|
|
|
6
|
1
|
11
|
my $self = shift; |
|
221
|
6
|
|
|
|
|
9
|
my $args = get_args(\@_); |
|
222
|
|
|
|
|
|
|
|
|
223
|
6
|
|
33
|
|
|
53
|
my $name = $args->{'name'} || |
|
224
|
|
|
|
|
|
|
throw $self "- no 'name' given"; |
|
225
|
|
|
|
|
|
|
|
|
226
|
6
|
|
|
|
|
17
|
my $array = $self->clipboard->get($name); |
|
227
|
|
|
|
|
|
|
|
|
228
|
6
|
100
|
66
|
|
|
288
|
if(ref $array && ref $array eq 'ARRAY') { |
|
229
|
4
|
|
|
|
|
16
|
$self->textout(scalar(@$array)); |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
} |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
############################################################################### |
|
234
|
|
|
|
|
|
|
1; |
|
235
|
|
|
|
|
|
|
__END__ |