Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/Form/Textboxlist.pm |
Statements | Executed 18 statements in 970µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
2 | 1 | 1 | 73µs | 3.83ms | new | Foswiki::Form::Textboxlist::
1 | 1 | 1 | 49µs | 70µs | BEGIN@9 | Foswiki::Form::Textboxlist::
1 | 1 | 1 | 29µs | 29µs | BEGIN@4 | Foswiki::Form::Textboxlist::
1 | 1 | 1 | 17µs | 25µs | BEGIN@8 | Foswiki::Form::Textboxlist::
1 | 1 | 1 | 11µs | 11µs | BEGIN@6 | Foswiki::Form::Textboxlist::
0 | 0 | 0 | 0s | 0s | getDefaultValue | Foswiki::Form::Textboxlist::
0 | 0 | 0 | 0s | 0s | getOptions | Foswiki::Form::Textboxlist::
0 | 0 | 0 | 0s | 0s | isMultiValued | Foswiki::Form::Textboxlist::
0 | 0 | 0 | 0s | 0s | renderForEdit | Foswiki::Form::Textboxlist::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | package Foswiki::Form::Textboxlist; | ||||
3 | |||||
4 | 2 | 76µs | 1 | 29µs | # spent 29µs within Foswiki::Form::Textboxlist::BEGIN@4 which was called:
# once (29µs+0s) by Foswiki::Form::createField at line 4 # spent 29µs making 1 call to Foswiki::Form::Textboxlist::BEGIN@4 |
5 | 1 | 17µs | our @ISA = qw( Foswiki::Form::ListFieldDefinition ); | ||
6 | 2 | 46µs | 1 | 11µs | # spent 11µs within Foswiki::Form::Textboxlist::BEGIN@6 which was called:
# once (11µs+0s) by Foswiki::Form::createField at line 6 # spent 11µs making 1 call to Foswiki::Form::Textboxlist::BEGIN@6 |
7 | |||||
8 | 2 | 77µs | 2 | 32µs | # spent 25µs (17+8) within Foswiki::Form::Textboxlist::BEGIN@8 which was called:
# once (17µs+8µs) by Foswiki::Form::createField at line 8 # spent 25µs making 1 call to Foswiki::Form::Textboxlist::BEGIN@8
# spent 7µs making 1 call to strict::import |
9 | 2 | 679µs | 2 | 91µs | # spent 70µs (49+21) within Foswiki::Form::Textboxlist::BEGIN@9 which was called:
# once (49µs+21µs) by Foswiki::Form::createField at line 9 # spent 70µs making 1 call to Foswiki::Form::Textboxlist::BEGIN@9
# spent 21µs making 1 call to warnings::import |
10 | |||||
11 | # spent 3.83ms (73µs+3.76) within Foswiki::Form::Textboxlist::new which was called 2 times, avg 1.92ms/call:
# 2 times (73µs+3.76ms) by Foswiki::Form::createField at line 311 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Form.pm, avg 1.92ms/call | ||||
12 | 8 | 69µs | my $class = shift; | ||
13 | 2 | 112µs | my $this = $class->SUPER::new(@_); # spent 112µs making 2 calls to Foswiki::Form::FieldDefinition::new, avg 56µs/call | ||
14 | |||||
15 | 2 | 3.64ms | Foswiki::Plugins::JQueryPlugin::createPlugin("textboxlist"); # spent 3.64ms making 2 calls to Foswiki::Plugins::JQueryPlugin::createPlugin, avg 1.82ms/call | ||
16 | return $this; | ||||
17 | } | ||||
18 | |||||
19 | sub isMultiValued { return 1; } | ||||
20 | |||||
21 | sub getDefaultValue { undef } | ||||
22 | |||||
23 | sub renderForEdit { | ||||
24 | my ( $this, $param1, $param2, $param3 ) = @_; | ||||
25 | |||||
26 | my $value; | ||||
27 | my $web; | ||||
28 | my $topic; | ||||
29 | my $topicObject; | ||||
30 | if ( ref($param1) ) { # Foswiki > 1.1 | ||||
31 | $topicObject = $param1; | ||||
32 | $value = $param2; | ||||
33 | } | ||||
34 | else { | ||||
35 | $web = $param1; | ||||
36 | $topic = $param2; | ||||
37 | $value = $param3; | ||||
38 | } | ||||
39 | |||||
40 | my @values = @{ $this->SUPER::getOptions() }; | ||||
41 | my $metadata = ''; | ||||
42 | if (@values) { | ||||
43 | if ( scalar(@values) == 1 && $values[0] =~ /^https?:/ ) { | ||||
44 | $metadata = "{autocomplete: '$values[0]'}"; | ||||
45 | } | ||||
46 | else { | ||||
47 | $metadata = | ||||
48 | "{autocomplete: ['" | ||||
49 | . join( "', '", map { $_ =~ s/(["'])/\\$1/g; $_ } @values ) | ||||
50 | . "']}"; | ||||
51 | } | ||||
52 | } | ||||
53 | |||||
54 | my $field = CGI::textfield( | ||||
55 | -class => | ||||
56 | $this->cssClasses("foswikiInputField jqTextboxList $metadata"), | ||||
57 | -name => $this->{name}, | ||||
58 | -size => $this->{size}, | ||||
59 | -value => $value, | ||||
60 | -id => $this->{name}, | ||||
61 | ); | ||||
62 | |||||
63 | return ( '', $field ); | ||||
64 | } | ||||
65 | |||||
66 | sub getOptions { | ||||
67 | my $this = shift; | ||||
68 | |||||
69 | my $query = Foswiki::Func::getCgiQuery(); | ||||
70 | |||||
71 | # trick this in | ||||
72 | my @values = (); | ||||
73 | my @valuesFromQuery = $query->param( $this->{name} ); | ||||
74 | foreach my $item (@valuesFromQuery) { | ||||
75 | |||||
76 | # Item10889: Coming from an "Warning! Confirmation required", often | ||||
77 | # there's an undef item (the, last, empty, one, <-- here) | ||||
78 | if ( defined $item ) { | ||||
79 | foreach my $value ( split( /\s*,\s*/, $item ) ) { | ||||
80 | push @values, $value if defined $value; | ||||
81 | } | ||||
82 | } | ||||
83 | } | ||||
84 | |||||
85 | return \@values; | ||||
86 | } | ||||
87 | |||||
88 | 1 | 6µs | 1; | ||
89 | __END__ |