Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TablePlugin/Core.pm |
Statements | Executed 3456 statements in 33.3ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
462 | 10 | 1 | 4.05ms | 4.05ms | CORE:subst (opcode) | Foswiki::Plugins::TablePlugin::Core::
5 | 1 | 1 | 3.86ms | 26.7ms | handler | Foswiki::Plugins::TablePlugin::Core::
2 | 1 | 1 | 2.66ms | 14.8ms | emitTable | Foswiki::Plugins::TablePlugin::Core::
8 | 1 | 1 | 2.39ms | 3.43ms | _processTableRow | Foswiki::Plugins::TablePlugin::Core::
2 | 2 | 1 | 816µs | 1.69ms | _parseAttributes | Foswiki::Plugins::TablePlugin::Core::
2 | 2 | 1 | 720µs | 1.16ms | _createCssStyles | Foswiki::Plugins::TablePlugin::Core::
69 | 6 | 1 | 569µs | 569µs | _appendToClassList | Foswiki::Plugins::TablePlugin::Core::
212 | 3 | 1 | 478µs | 478µs | CORE:regcomp (opcode) | Foswiki::Plugins::TablePlugin::Core::
48 | 27 | 1 | 437µs | 437µs | _storeAttribute | Foswiki::Plugins::TablePlugin::Core::
4 | 3 | 1 | 385µs | 385µs | _mergeHashes | Foswiki::Plugins::TablePlugin::Core::
17 | 15 | 1 | 323µs | 323µs | __ANON__[:985] | Foswiki::Plugins::TablePlugin::Core::
22 | 1 | 1 | 305µs | 499µs | _appendColNumberCssClass | Foswiki::Plugins::TablePlugin::Core::
83 | 10 | 1 | 287µs | 287µs | CORE:match (opcode) | Foswiki::Plugins::TablePlugin::Core::
2 | 1 | 1 | 223µs | 223µs | _headerRowCount | Foswiki::Plugins::TablePlugin::Core::
16 | 2 | 1 | 206µs | 329µs | _appendRowNumberCssClass | Foswiki::Plugins::TablePlugin::Core::
14 | 7 | 1 | 175µs | 275µs | _debug | Foswiki::Plugins::TablePlugin::Core::
8 | 1 | 1 | 165µs | 229µs | _appendLastColumnCssClass | Foswiki::Plugins::TablePlugin::Core::
1 | 1 | 1 | 104µs | 1.19ms | _parseTableSpecificTableAttributes | Foswiki::Plugins::TablePlugin::Core::
22 | 1 | 1 | 96µs | 96µs | _getDefaultSortDirection | Foswiki::Plugins::TablePlugin::Core::
8 | 1 | 1 | 93µs | 159µs | _appendFirstColumnCssClass | Foswiki::Plugins::TablePlugin::Core::
12 | 6 | 1 | 91µs | 95µs | _arrayRefFromParam | Foswiki::Plugins::TablePlugin::Core::
7 | 1 | 1 | 77µs | 131µs | _appendLastRowCssClass | Foswiki::Plugins::TablePlugin::Core::
2 | 1 | 1 | 73µs | 304µs | _resetReusedVariables | Foswiki::Plugins::TablePlugin::Core::
1 | 1 | 1 | 68µs | 3.23ms | _writeStyleToHead | Foswiki::Plugins::TablePlugin::Core::
6 | 4 | 1 | 58µs | 99µs | _debugData | Foswiki::Plugins::TablePlugin::Core::
20 | 2 | 1 | 47µs | 47µs | CORE:substcont (opcode) | Foswiki::Plugins::TablePlugin::Core::
1 | 1 | 1 | 40µs | 1.04ms | _initDefaults | Foswiki::Plugins::TablePlugin::Core::
1 | 1 | 1 | 37µs | 47µs | BEGIN@3 | Foswiki::Plugins::TablePlugin::
2 | 1 | 1 | 34µs | 4.34ms | _addDefaultStyles | Foswiki::Plugins::TablePlugin::Core::
1 | 1 | 1 | 29µs | 3.26ms | _addHeadStyles | Foswiki::Plugins::TablePlugin::Core::
1 | 1 | 1 | 29µs | 902µs | _parseDefaultAttributes | Foswiki::Plugins::TablePlugin::Core::
2 | 2 | 1 | 29µs | 32µs | _cleanParamValue | Foswiki::Plugins::TablePlugin::Core::
1 | 1 | 1 | 28µs | 28µs | BEGIN@10 | Foswiki::Plugins::TablePlugin::Core::
1 | 1 | 1 | 26µs | 574µs | BEGIN@11 | Foswiki::Plugins::TablePlugin::Core::
1 | 1 | 1 | 25µs | 33µs | addDefaultSizeUnit | Foswiki::Plugins::TablePlugin::Core::
4 | 3 | 1 | 25µs | 25µs | CORE:sort (opcode) | Foswiki::Plugins::TablePlugin::Core::
1 | 1 | 1 | 25µs | 74µs | BEGIN@1714 | Foswiki::Plugins::TablePlugin::Core::
1 | 1 | 1 | 20µs | 42µs | BEGIN@4 | Foswiki::Plugins::TablePlugin::
1 | 1 | 1 | 18µs | 18µs | BEGIN@121 | Foswiki::Plugins::TablePlugin::Core::
1 | 1 | 1 | 17µs | 52µs | BEGIN@1716 | Foswiki::Plugins::TablePlugin::Core::
1 | 1 | 1 | 16µs | 16µs | BEGIN@8 | Foswiki::Plugins::TablePlugin::Core::
1 | 1 | 1 | 10µs | 10µs | BEGIN@9 | Foswiki::Plugins::TablePlugin::Core::
2 | 2 | 1 | 10µs | 10µs | CORE:qr (opcode) | Foswiki::Plugins::TablePlugin::Core::
0 | 0 | 0 | 0s | 0s | __ANON__[:454] | Foswiki::Plugins::TablePlugin::Core::
0 | 0 | 0 | 0s | 0s | __ANON__[:459] | Foswiki::Plugins::TablePlugin::Core::
0 | 0 | 0 | 0s | 0s | _appendSortedAscendingCssClass | Foswiki::Plugins::TablePlugin::Core::
0 | 0 | 0 | 0s | 0s | _appendSortedCssClass | Foswiki::Plugins::TablePlugin::Core::
0 | 0 | 0 | 0s | 0s | _appendSortedDescendingCssClass | Foswiki::Plugins::TablePlugin::Core::
0 | 0 | 0 | 0s | 0s | _convertStringToDate | Foswiki::Plugins::TablePlugin::Core::
0 | 0 | 0 | 0s | 0s | _convertStringToNumber | Foswiki::Plugins::TablePlugin::Core::
0 | 0 | 0 | 0s | 0s | _getCurrentSortDirection | Foswiki::Plugins::TablePlugin::Core::
0 | 0 | 0 | 0s | 0s | _getImageTextForSorting | Foswiki::Plugins::TablePlugin::Core::
0 | 0 | 0 | 0s | 0s | _getIncludeParams | Foswiki::Plugins::TablePlugin::Core::
0 | 0 | 0 | 0s | 0s | _getInlineMarkupStyle | Foswiki::Plugins::TablePlugin::Core::
0 | 0 | 0 | 0s | 0s | _getNewSortDirection | Foswiki::Plugins::TablePlugin::Core::
0 | 0 | 0 | 0s | 0s | _setSortTypeForCells | Foswiki::Plugins::TablePlugin::Core::
0 | 0 | 0 | 0s | 0s | _stripHtml | Foswiki::Plugins::TablePlugin::Core::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | |||||
3 | 2 | 59µs | 2 | 56µs | # spent 47µs (37+9) within Foswiki::Plugins::TablePlugin::BEGIN@3 which was called:
# once (37µs+9µs) by Foswiki::Plugins::TablePlugin::BEGIN@1 at line 3 # spent 47µs making 1 call to Foswiki::Plugins::TablePlugin::BEGIN@3
# spent 9µs making 1 call to strict::import |
4 | 2 | 62µs | 2 | 64µs | # spent 42µs (20+22) within Foswiki::Plugins::TablePlugin::BEGIN@4 which was called:
# once (20µs+22µs) by Foswiki::Plugins::TablePlugin::BEGIN@1 at line 4 # spent 42µs making 1 call to Foswiki::Plugins::TablePlugin::BEGIN@4
# spent 22µs making 1 call to warnings::import |
5 | |||||
6 | package Foswiki::Plugins::TablePlugin::Core; | ||||
7 | |||||
8 | 2 | 50µs | 1 | 16µs | # spent 16µs within Foswiki::Plugins::TablePlugin::Core::BEGIN@8 which was called:
# once (16µs+0s) by Foswiki::Plugins::TablePlugin::BEGIN@1 at line 8 # spent 16µs making 1 call to Foswiki::Plugins::TablePlugin::Core::BEGIN@8 |
9 | 2 | 42µs | 1 | 10µs | # spent 10µs within Foswiki::Plugins::TablePlugin::Core::BEGIN@9 which was called:
# once (10µs+0s) by Foswiki::Plugins::TablePlugin::BEGIN@1 at line 9 # spent 10µs making 1 call to Foswiki::Plugins::TablePlugin::Core::BEGIN@9 |
10 | 2 | 64µs | 1 | 28µs | # spent 28µs within Foswiki::Plugins::TablePlugin::Core::BEGIN@10 which was called:
# once (28µs+0s) by Foswiki::Plugins::TablePlugin::BEGIN@1 at line 10 # spent 28µs making 1 call to Foswiki::Plugins::TablePlugin::Core::BEGIN@10 |
11 | 2 | 721µs | 2 | 1.12ms | # spent 574µs (26+548) within Foswiki::Plugins::TablePlugin::Core::BEGIN@11 which was called:
# once (26µs+548µs) by Foswiki::Plugins::TablePlugin::BEGIN@1 at line 11 # spent 574µs making 1 call to Foswiki::Plugins::TablePlugin::Core::BEGIN@11
# spent 548µs making 1 call to Error::import |
12 | |||||
13 | 1 | 1µs | my @curTable; | ||
14 | 1 | 1µs | my $translationToken; | ||
15 | 1 | 900ns | my $insideTABLE; | ||
16 | 1 | 700ns | my $currTablePre; | ||
17 | 1 | 1µs | my $didWriteDefaultStyle; | ||
18 | 1 | 800ns | my $defaultAttrs; # to write generic table CSS | ||
19 | 1 | 800ns | my $tableSpecificAttrs; # to write table specific table CSS | ||
20 | 1 | 900ns | my $combinedTableAttrs; # default and specific table attributes | ||
21 | 1 | 2µs | my $styles = {}; # hash of default and specific styles | ||
22 | |||||
23 | # not yet refactored: | ||||
24 | 1 | 1µs | my $tableCount; | ||
25 | 1 | 800ns | my $sortCol; | ||
26 | 1 | 800ns | my $MAX_SORT_COLS; | ||
27 | 1 | 700ns | my $requestedTable; | ||
28 | 1 | 800ns | my $up; | ||
29 | 1 | 800ns | my $sortTablesInText; | ||
30 | 1 | 800ns | my $sortAttachments; | ||
31 | 1 | 900ns | my $sortColFromUrl; | ||
32 | 1 | 900ns | my $url; | ||
33 | 1 | 800ns | my $currentSortDirection; | ||
34 | 1 | 1µs | my @rowspan; | ||
35 | |||||
36 | 1 | 2µs | my $HEAD_ID_DEFAULT_STYLE = | ||
37 | 'TABLEPLUGIN_default'; # this name is part of the API, do not change | ||||
38 | 1 | 1µs | my $HEAD_ID_SPECIFIC_STYLE = | ||
39 | 'TABLEPLUGIN_specific'; # this name is part of the API, do not change | ||||
40 | |||||
41 | 1 | 21µs | 1 | 6µs | my $PATTERN_TABLE = qr/%TABLE(?:{(.*?)})?%/; # spent 6µs making 1 call to Foswiki::Plugins::TablePlugin::Core::CORE:qr |
42 | 1 | 10µs | 1 | 8µs | my $URL_ICON = # spent 8µs making 1 call to Foswiki::Func::getPubUrlPath |
43 | Foswiki::Func::getPubUrlPath() . '/' | ||||
44 | . $Foswiki::cfg{SystemWebName} | ||||
45 | . '/DocumentGraphics/'; | ||||
46 | 1 | 24µs | 1 | 525µs | my $GIF_TABLE_SORT_ASCENDING = CGI::img( # spent 525µs making 1 call to CGI::AUTOLOAD |
47 | { | ||||
48 | src => $URL_ICON . 'tablesortup.gif', | ||||
49 | border => 0, | ||||
50 | width => 11, | ||||
51 | height => 13, | ||||
52 | alt => 'Sorted ascending', | ||||
53 | title => 'Sorted ascending' | ||||
54 | } | ||||
55 | ); | ||||
56 | |||||
57 | 1 | 11µs | 1 | 352µs | my $GIF_TABLE_SORT_DESCENDING = CGI::img( # spent 352µs making 1 call to CGI::img |
58 | { | ||||
59 | src => $URL_ICON . 'tablesortdown.gif', | ||||
60 | border => 0, | ||||
61 | width => 11, | ||||
62 | height => 13, | ||||
63 | alt => 'Sorted descending', | ||||
64 | title => 'Sorted descending' | ||||
65 | } | ||||
66 | ); | ||||
67 | |||||
68 | 1 | 10µs | 1 | 350µs | my $GIF_TABLE_SORT_BOTH = CGI::img( # spent 350µs making 1 call to CGI::img |
69 | { | ||||
70 | src => $URL_ICON . 'tablesortdiamond.gif', | ||||
71 | border => 0, | ||||
72 | width => 11, | ||||
73 | height => 13, | ||||
74 | alt => 'Sort', | ||||
75 | title => 'Sort' | ||||
76 | } | ||||
77 | ); | ||||
78 | 1 | 9µs | 1 | 134µs | my $CHAR_SORT_ASCENDING = CGI::span( { class => 'tableSortIcon tableSortUp' }, # spent 134µs making 1 call to CGI::span |
79 | $GIF_TABLE_SORT_ASCENDING ); | ||||
80 | 1 | 7µs | 1 | 122µs | my $CHAR_SORT_DESCENDING = # spent 122µs making 1 call to CGI::span |
81 | CGI::span( { class => 'tableSortIcon tableSortDown' }, | ||||
82 | $GIF_TABLE_SORT_DESCENDING ); | ||||
83 | 1 | 7µs | 1 | 122µs | my $CHAR_SORT_BOTH = # spent 122µs making 1 call to CGI::span |
84 | CGI::span( { class => 'tableSortIcon tableSortUp' }, $GIF_TABLE_SORT_BOTH ); | ||||
85 | |||||
86 | 1 | 3µs | my $SORT_DIRECTION = { | ||
87 | 'ASCENDING' => 0, | ||||
88 | 'DESCENDING' => 1, | ||||
89 | 'NONE' => 2, | ||||
90 | }; | ||||
91 | |||||
92 | 1 | 10µs | 1 | 4µs | my $PATTERN_ATTRIBUTE_SIZE = qr'([0-9]+)(px|%)*'o; # spent 4µs making 1 call to Foswiki::Plugins::TablePlugin::Core::CORE:qr |
93 | |||||
94 | 1 | 1µs | my $TABLE_RULES = {}; | ||
95 | 1 | 5µs | $TABLE_RULES->{all}->{TD} = $TABLE_RULES->{all}->{TH} = | ||
96 | $TABLE_RULES->{data_all}->{TD} = $TABLE_RULES->{header_all}->{TH} = | ||||
97 | 'border-style:solid'; | ||||
98 | 1 | 4µs | $TABLE_RULES->{none}->{TD} = $TABLE_RULES->{none}->{TH} = | ||
99 | $TABLE_RULES->{data_none}->{TD} = $TABLE_RULES->{header_none}->{TH} = | ||||
100 | 'border-style:none'; | ||||
101 | 1 | 5µs | $TABLE_RULES->{cols}->{TD} = $TABLE_RULES->{cols}->{TH} = | ||
102 | $TABLE_RULES->{data_cols}->{TD} = $TABLE_RULES->{header_cols}->{TH} = | ||||
103 | 'border-style:none solid'; | ||||
104 | 1 | 4µs | $TABLE_RULES->{rows}->{TD} = $TABLE_RULES->{rows}->{TH} = | ||
105 | $TABLE_RULES->{data_rows}->{TD} = $TABLE_RULES->{header_rows}->{TH} = | ||||
106 | 'border-style:solid none'; | ||||
107 | 1 | 2µs | $TABLE_RULES->{groups}->{TD} = 'border-style:none'; | ||
108 | 1 | 2µs | $TABLE_RULES->{groups}->{TH} = 'border-style:solid none'; | ||
109 | |||||
110 | 1 | 2µs | my $TABLE_FRAME = {}; | ||
111 | 1 | 2µs | $TABLE_FRAME->{void} = 'border-style:none'; | ||
112 | 1 | 2µs | $TABLE_FRAME->{above} = 'border-style:solid none none none'; | ||
113 | 1 | 2µs | $TABLE_FRAME->{below} = 'border-style:none none solid none'; | ||
114 | 1 | 2µs | $TABLE_FRAME->{lhs} = 'border-style:none none none solid'; | ||
115 | 1 | 2µs | $TABLE_FRAME->{rhs} = 'border-style:none solid none none'; | ||
116 | 1 | 2µs | $TABLE_FRAME->{hsides} = 'border-style:solid none solid none'; | ||
117 | 1 | 2µs | $TABLE_FRAME->{vsides} = 'border-style:none solid none solid'; | ||
118 | 1 | 2µs | $TABLE_FRAME->{box} = 'border-style:solid'; | ||
119 | 1 | 2µs | $TABLE_FRAME->{border} = 'border-style:solid'; | ||
120 | |||||
121 | # spent 18µs within Foswiki::Plugins::TablePlugin::Core::BEGIN@121 which was called:
# once (18µs+0s) by Foswiki::Plugins::TablePlugin::BEGIN@1 at line 131 | ||||
122 | 1 | 2µs | $translationToken = "\0"; | ||
123 | |||||
124 | # the maximum number of columns we will handle | ||||
125 | 1 | 2µs | $MAX_SORT_COLS = 10000; | ||
126 | 1 | 1µs | $didWriteDefaultStyle = 0; | ||
127 | 1 | 1µs | $tableCount = 0; | ||
128 | 1 | 1µs | $currTablePre = ''; | ||
129 | 1 | 2µs | $combinedTableAttrs = {}; | ||
130 | 1 | 9µs | $tableSpecificAttrs = {}; | ||
131 | 1 | 11.1ms | 1 | 18µs | } # spent 18µs making 1 call to Foswiki::Plugins::TablePlugin::Core::BEGIN@121 |
132 | |||||
133 | # spent 1.04ms (40µs+1.00) within Foswiki::Plugins::TablePlugin::Core::_initDefaults which was called:
# once (40µs+1.00ms) by Foswiki::Plugins::TablePlugin::Core::handler at line 1877 | ||||
134 | 1 | 5µs | 1 | 16µs | _debug('_initDefaults'); # spent 16µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_debug |
135 | 1 | 5µs | $defaultAttrs = { | ||
136 | headerrows => 0, | ||||
137 | footerrows => 0, | ||||
138 | sort => 1, | ||||
139 | class => 'foswikiTable', | ||||
140 | sortAllTables => $sortTablesInText, | ||||
141 | }; | ||||
142 | |||||
143 | 1 | 13µs | 1 | 902µs | _parseDefaultAttributes( # spent 902µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_parseDefaultAttributes |
144 | %{Foswiki::Plugins::TablePlugin::pluginAttributes} ); | ||||
145 | |||||
146 | 1 | 11µs | 1 | 86µs | $combinedTableAttrs = _mergeHashes( {}, $defaultAttrs ); # spent 86µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_mergeHashes |
147 | } | ||||
148 | |||||
149 | # spent 4.34ms (34µs+4.31) within Foswiki::Plugins::TablePlugin::Core::_addDefaultStyles which was called 2 times, avg 2.17ms/call:
# 2 times (34µs+4.31ms) by Foswiki::Plugins::TablePlugin::Core::emitTable at line 1331, avg 2.17ms/call | ||||
150 | |||||
151 | 2 | 8µs | return if $Foswiki::Plugins::TablePlugin::writtenToHead; | ||
152 | 1 | 2µs | $Foswiki::Plugins::TablePlugin::writtenToHead = 1; | ||
153 | |||||
154 | # create CSS styles tables in general | ||||
155 | 1 | 8µs | 1 | 1.05ms | my ( $id, @styles ) = _createCssStyles( 1, $defaultAttrs ); # spent 1.05ms making 1 call to Foswiki::Plugins::TablePlugin::Core::_createCssStyles |
156 | 1 | 14µs | 1 | 3.26ms | _addHeadStyles( $HEAD_ID_DEFAULT_STYLE, @styles ) if scalar @styles; # spent 3.26ms making 1 call to Foswiki::Plugins::TablePlugin::Core::_addHeadStyles |
157 | } | ||||
158 | |||||
159 | # spent 304µs (73+231) within Foswiki::Plugins::TablePlugin::Core::_resetReusedVariables which was called 2 times, avg 152µs/call:
# 2 times (73µs+231µs) by Foswiki::Plugins::TablePlugin::Core::emitTable at line 1817, avg 152µs/call | ||||
160 | 2 | 10µs | 2 | 32µs | _debug('_resetReusedVariables'); # spent 32µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_debug, avg 16µs/call |
161 | 2 | 3µs | $currTablePre = ''; | ||
162 | 2 | 34µs | 2 | 199µs | $combinedTableAttrs = _mergeHashes( {}, $defaultAttrs ); # spent 199µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_mergeHashes, avg 100µs/call |
163 | 2 | 5µs | $tableSpecificAttrs = {}; | ||
164 | 2 | 16µs | $sortCol = 0; | ||
165 | } | ||||
166 | |||||
167 | =pod | ||||
168 | |||||
169 | =cut | ||||
170 | |||||
171 | # spent 437µs within Foswiki::Plugins::TablePlugin::Core::_storeAttribute which was called 48 times, avg 9µs/call:
# 2 times (77µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 363, avg 39µs/call
# 2 times (20µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 357, avg 10µs/call
# 2 times (20µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 300, avg 10µs/call
# 2 times (18µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 345, avg 9µs/call
# 2 times (17µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 365, avg 8µs/call
# 2 times (17µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 360, avg 8µs/call
# 2 times (17µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 346, avg 8µs/call
# 2 times (17µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 340, avg 8µs/call
# 2 times (15µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 301, avg 7µs/call
# 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 342, avg 7µs/call
# 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 347, avg 7µs/call
# 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 303, avg 7µs/call
# 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 359, avg 7µs/call
# 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 305, avg 7µs/call
# 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 304, avg 7µs/call
# 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 373, avg 7µs/call
# 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 358, avg 7µs/call
# 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 351, avg 7µs/call
# 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 348, avg 7µs/call
# 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 354, avg 7µs/call
# 2 times (13µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 370, avg 7µs/call
# once (12µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 249
# once (10µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 250
# once (10µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 296
# once (8µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 289
# once (7µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 297
# once (6µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 298 | ||||
172 | 48 | 94µs | my ( $inAttrName, $inValue, $inCollection ) = @_; | ||
173 | |||||
174 | 48 | 119µs | if ( !$inCollection ) { | ||
175 | _debug('_storeAttribute -- missing inCollection!'); | ||||
176 | return; | ||||
177 | } | ||||
178 | 48 | 232µs | return if !defined $inValue; | ||
179 | 12 | 18µs | return if !defined $inAttrName || $inAttrName eq ''; | ||
180 | 12 | 91µs | $inCollection->{$inAttrName} = $inValue; | ||
181 | } | ||||
182 | |||||
183 | =pod | ||||
184 | |||||
185 | =cut | ||||
186 | |||||
187 | # spent 902µs (29+873) within Foswiki::Plugins::TablePlugin::Core::_parseDefaultAttributes which was called:
# once (29µs+873µs) by Foswiki::Plugins::TablePlugin::Core::_initDefaults at line 143 | ||||
188 | 1 | 8µs | my (%params) = @_; | ||
189 | |||||
190 | 1 | 5µs | 1 | 15µs | _debug('_parseDefaultAttributes'); # spent 15µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_debug |
191 | |||||
192 | 1 | 11µs | 1 | 857µs | _parseAttributes( 0, $defaultAttrs, \%params ); # spent 857µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_parseAttributes |
193 | } | ||||
194 | |||||
195 | =pod | ||||
196 | |||||
197 | =cut | ||||
198 | |||||
199 | # spent 1.19ms (104µs+1.08) within Foswiki::Plugins::TablePlugin::Core::_parseTableSpecificTableAttributes which was called:
# once (104µs+1.08ms) by Foswiki::Plugins::TablePlugin::Core::handler at line 1889 | ||||
200 | 1 | 4µs | my (%params) = @_; | ||
201 | |||||
202 | 1 | 4µs | 1 | 15µs | _debug('_parseTableSpecificTableAttributes'); # spent 15µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_debug |
203 | |||||
204 | 1 | 6µs | 1 | 829µs | _parseAttributes( 1, $tableSpecificAttrs, \%params ); # spent 829µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_parseAttributes |
205 | |||||
206 | # remove default values from hash | ||||
207 | 6 | 30µs | while ( my ( $key, $value ) = each %{$tableSpecificAttrs} ) { | ||
208 | 4 | 9µs | delete $tableSpecificAttrs->{$key} | ||
209 | if $defaultAttrs->{$key} && $value eq $defaultAttrs->{$key}; | ||||
210 | } | ||||
211 | $combinedTableAttrs = | ||||
212 | 1 | 8µs | 1 | 100µs | _mergeHashes( $combinedTableAttrs, $tableSpecificAttrs ); # spent 100µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_mergeHashes |
213 | 1 | 5µs | 1 | 15µs | _debugData( 'combinedTableAttrs', $combinedTableAttrs ); # spent 15µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_debugData |
214 | |||||
215 | # create CSS styles for this table only | ||||
216 | 1 | 7µs | 1 | 110µs | my ( $id, @styles ) = _createCssStyles( 0, $tableSpecificAttrs ); # spent 110µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_createCssStyles |
217 | 1 | 6µs | 1 | 15µs | _debugData( "after _createCssStyles, id=$id; styles", \@styles ); # spent 15µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_debugData |
218 | |||||
219 | 1 | 2µs | _addHeadStyles( $id, @styles ) if scalar @styles; | ||
220 | |||||
221 | 1 | 9µs | return $currTablePre . '<nop>'; | ||
222 | } | ||||
223 | |||||
224 | =pod | ||||
225 | |||||
226 | =cut | ||||
227 | |||||
228 | # spent 1.69ms (816µs+870µs) within Foswiki::Plugins::TablePlugin::Core::_parseAttributes which was called 2 times, avg 843µs/call:
# once (459µs+398µs) by Foswiki::Plugins::TablePlugin::Core::_parseDefaultAttributes at line 192
# once (357µs+471µs) by Foswiki::Plugins::TablePlugin::Core::_parseTableSpecificTableAttributes at line 204 | ||||
229 | 2 | 4µs | my ( $isTableSpecific, $inCollection, $inParams ) = @_; | ||
230 | |||||
231 | 2 | 12µs | 2 | 38µs | _debugData( "isTableSpecific=$isTableSpecific; _parseAttributes=", # spent 38µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_debugData, avg 19µs/call |
232 | $inParams ); | ||||
233 | |||||
234 | # include topic to read definitions | ||||
235 | 2 | 4µs | my $includeTopicParam = $inParams->{include}; | ||
236 | 2 | 2µs | $inParams = _getIncludeParams($includeTopicParam) if $includeTopicParam; | ||
237 | |||||
238 | # table attributes | ||||
239 | # some will be used for css styling as well | ||||
240 | |||||
241 | 2 | 3µs | _storeAttribute( 'generateInlineMarkup', | ||
242 | Foswiki::Func::isTrue( $inParams->{inlinemarkup} ), | ||||
243 | $inCollection ) | ||||
244 | if defined $inParams->{inlinemarkup}; | ||||
245 | |||||
246 | # sort attributes | ||||
247 | 2 | 10µs | if ( defined $inParams->{sort} ) { | ||
248 | 1 | 5µs | 1 | 64µs | my $sort = Foswiki::Func::isTrue( $inParams->{sort} ); # spent 64µs making 1 call to Foswiki::Func::isTrue |
249 | 1 | 6µs | 1 | 12µs | _storeAttribute( 'sort', $sort, $inCollection ); # spent 12µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_storeAttribute |
250 | 1 | 5µs | 1 | 10µs | _storeAttribute( 'sortAllTables', $sort, $inCollection ); # spent 10µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_storeAttribute |
251 | } | ||||
252 | 2 | 4µs | if ( defined( $inParams->{initsort} ) | ||
253 | and int( $inParams->{initsort} ) > 0 ) | ||||
254 | { | ||||
255 | _storeAttribute( 'initSort', $inParams->{initsort}, $inCollection ); | ||||
256 | |||||
257 | # override sort attribute: we are sorting after all | ||||
258 | _storeAttribute( 'sort', 1, $inCollection ); | ||||
259 | } | ||||
260 | |||||
261 | 2 | 3µs | if ( $inParams->{initdirection} ) { | ||
262 | _storeAttribute( 'initDirection', $SORT_DIRECTION->{'ASCENDING'}, | ||||
263 | $inCollection ) | ||||
264 | if $inParams->{initdirection} =~ /^down$/i; | ||||
265 | _storeAttribute( 'initDirection', $SORT_DIRECTION->{'DESCENDING'}, | ||||
266 | $inCollection ) | ||||
267 | if $inParams->{initdirection} =~ /^up$/i; | ||||
268 | } | ||||
269 | |||||
270 | # If EditTablePlugin is installed and we are editing a table, | ||||
271 | # the CGI parameter 'sort' is defined as "off" to disable all | ||||
272 | # header sorting ((Item5135) | ||||
273 | 2 | 11µs | 2 | 43µs | my $cgi = Foswiki::Func::getCgiQuery(); # spent 43µs making 2 calls to Foswiki::Func::getCgiQuery, avg 21µs/call |
274 | 2 | 11µs | 2 | 95µs | my $urlParamSort = $cgi->param('sort'); # spent 95µs making 2 calls to Foswiki::Request::param, avg 47µs/call |
275 | 2 | 3µs | if ( $urlParamSort && $urlParamSort =~ /^off$/oi ) { | ||
276 | delete $inCollection->{sortAllTables}; | ||||
277 | } | ||||
278 | |||||
279 | # If EditTablePlugin is installed and we are editing a table, the | ||||
280 | # 'disableallsort' TABLE parameter is added to disable initsort and header | ||||
281 | # sorting in the table that is being edited. (Item5135) | ||||
282 | 2 | 16µs | 2 | 35µs | if ( Foswiki::Func::isTrue( $inParams->{disableallsort} ) ) { # spent 35µs making 2 calls to Foswiki::Func::isTrue, avg 18µs/call |
283 | $inCollection->{sortAllTables} = 0; | ||||
284 | delete $inCollection->{initSort}; | ||||
285 | } | ||||
286 | |||||
287 | 2 | 4µs | if ($isTableSpecific) { | ||
288 | |||||
289 | 1 | 7µs | 1 | 8µs | _storeAttribute( 'summary', $inParams->{summary}, $inCollection ); # spent 8µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_storeAttribute |
290 | 1 | 3µs | my $id = | ||
291 | defined $inParams->{id} | ||||
292 | ? $inParams->{id} | ||||
293 | : 'table' | ||||
294 | . $Foswiki::Plugins::TablePlugin::topic | ||||
295 | . ( $tableCount + 1 ); | ||||
296 | 1 | 5µs | 1 | 10µs | _storeAttribute( 'id', $id, $inCollection ); # spent 10µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_storeAttribute |
297 | 1 | 6µs | 1 | 7µs | _storeAttribute( 'headerrows', $inParams->{headerrows}, $inCollection ); # spent 7µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_storeAttribute |
298 | 1 | 6µs | 1 | 6µs | _storeAttribute( 'footerrows', $inParams->{footerrows}, $inCollection ); # spent 6µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_storeAttribute |
299 | } | ||||
300 | 2 | 12µs | 2 | 20µs | _storeAttribute( 'border', $inParams->{tableborder}, $inCollection ); # spent 20µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 10µs/call |
301 | 2 | 12µs | 2 | 15µs | _storeAttribute( 'tableBorderColor', $inParams->{tablebordercolor}, # spent 15µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call |
302 | $inCollection ); | ||||
303 | 2 | 12µs | 2 | 14µs | _storeAttribute( 'cellpadding', $inParams->{cellpadding}, $inCollection ); # spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call |
304 | 2 | 12µs | 2 | 14µs | _storeAttribute( 'cellspacing', $inParams->{cellspacing}, $inCollection ); # spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call |
305 | 2 | 12µs | 2 | 14µs | _storeAttribute( 'frame', $inParams->{tableframe}, $inCollection ); # spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call |
306 | |||||
307 | # tablerules css settings | ||||
308 | 2 | 4µs | my @tableRulesList = (); | ||
309 | 2 | 5µs | if ( $inParams->{tablerules} ) { | ||
310 | |||||
311 | # store tablerules as array, so that headerrules and datarules | ||||
312 | # can be appended to that list | ||||
313 | 1 | 6µs | 1 | 19µs | my $param = _cleanParamValue( $inParams->{tablerules} ); # spent 19µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_cleanParamValue |
314 | 1 | 3µs | if ($param) { | ||
315 | 1 | 2µs | push( @tableRulesList, $param ); | ||
316 | } | ||||
317 | } | ||||
318 | 2 | 4µs | if ( $inParams->{headerrules} ) { | ||
319 | 1 | 5µs | 1 | 14µs | my $param = _cleanParamValue( $inParams->{headerrules} ); # spent 14µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_cleanParamValue |
320 | 1 | 3µs | if ($param) { | ||
321 | 1 | 2µs | $param = "header_$param"; | ||
322 | 1 | 2µs | push( @tableRulesList, $param ); | ||
323 | } | ||||
324 | } | ||||
325 | 2 | 3µs | if ( $inParams->{datarules} ) { | ||
326 | my $param = _cleanParamValue( $inParams->{datarules} ); | ||||
327 | if ($param) { | ||||
328 | $param = "data_$param"; | ||||
329 | push( @tableRulesList, $param ); | ||||
330 | } | ||||
331 | } | ||||
332 | 2 | 4µs | $inCollection->{tableRules} = \@tableRulesList if scalar @tableRulesList; | ||
333 | |||||
334 | # use 'rules' as table attribute only (not to define css styles) | ||||
335 | # but set to | ||||
336 | 2 | 4µs | my $rules = | ||
337 | ( defined $inParams->{headerrules} || defined $inParams->{datarules} ) | ||||
338 | ? 'none' | ||||
339 | : $inParams->{tablerules}; | ||||
340 | 2 | 9µs | 2 | 17µs | _storeAttribute( 'rules', $rules, $inCollection ); # spent 17µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 8µs/call |
341 | |||||
342 | 2 | 13µs | 2 | 14µs | _storeAttribute( 'width', $inParams->{tablewidth}, $inCollection ); # spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call |
343 | |||||
344 | # css attributes | ||||
345 | 2 | 12µs | 2 | 18µs | _storeAttribute( 'headerColor', $inParams->{headercolor}, $inCollection ); # spent 18µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 9µs/call |
346 | 2 | 11µs | 2 | 17µs | _storeAttribute( 'headerBg', $inParams->{headerbg}, $inCollection ); # spent 17µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 8µs/call |
347 | 2 | 12µs | 2 | 14µs | _storeAttribute( 'cellBorder', $inParams->{cellborder}, $inCollection ); # spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call |
348 | 2 | 20µs | 4 | 26µs | _storeAttribute( 'headerAlignListRef', # spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call
# spent 12µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_arrayRefFromParam, avg 6µs/call |
349 | _arrayRefFromParam( $inParams->{headeralign} ), | ||||
350 | $inCollection ); | ||||
351 | 2 | 20µs | 4 | 25µs | _storeAttribute( 'dataAlignListRef', # spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call
# spent 11µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_arrayRefFromParam, avg 6µs/call |
352 | _arrayRefFromParam( $inParams->{dataalign} ), | ||||
353 | $inCollection ); | ||||
354 | 2 | 20µs | 4 | 25µs | _storeAttribute( 'columnWidthsListRef', # spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call
# spent 12µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_arrayRefFromParam, avg 6µs/call |
355 | _arrayRefFromParam( $inParams->{columnwidths} ), | ||||
356 | $inCollection ); | ||||
357 | 2 | 10µs | 2 | 20µs | _storeAttribute( 'vAlign', $inParams->{valign} || 'top', $inCollection ); # spent 20µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 10µs/call |
358 | 2 | 12µs | 2 | 14µs | _storeAttribute( 'dataVAlign', $inParams->{datavalign}, $inCollection ); # spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call |
359 | 2 | 12µs | 2 | 14µs | _storeAttribute( 'headerVAlign', $inParams->{headervalign}, $inCollection ); # spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call |
360 | 2 | 11µs | 2 | 17µs | _storeAttribute( 'headerBgSorted', # spent 17µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 8µs/call |
361 | $inParams->{headerbgsorted} || $inParams->{headerbg}, | ||||
362 | $inCollection ); | ||||
363 | 2 | 19µs | 4 | 102µs | _storeAttribute( 'dataBgListRef', _arrayRefFromParam( $inParams->{databg} ), # spent 77µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 39µs/call
# spent 25µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_arrayRefFromParam, avg 13µs/call |
364 | $inCollection ); | ||||
365 | 2 | 19µs | 4 | 40µs | _storeAttribute( # spent 22µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_arrayRefFromParam, avg 11µs/call
# spent 17µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 8µs/call |
366 | 'dataBgSortedListRef', | ||||
367 | _arrayRefFromParam( $inParams->{databgsorted} || $inParams->{databg} ), | ||||
368 | $inCollection | ||||
369 | ); | ||||
370 | 2 | 20µs | 4 | 25µs | _storeAttribute( 'dataColorListRef', # spent 13µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call
# spent 12µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_arrayRefFromParam, avg 6µs/call |
371 | _arrayRefFromParam( $inParams->{datacolor} ), | ||||
372 | $inCollection ); | ||||
373 | 2 | 12µs | 2 | 14µs | _storeAttribute( 'tableCaption', $inParams->{caption}, $inCollection ); # spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call |
374 | |||||
375 | # remove empty attributes | ||||
376 | 22 | 123µs | while ( my ( $key, $value ) = each %{$inCollection} ) { | ||
377 | 18 | 28µs | delete $inCollection->{$key} if !defined $value || $value eq ''; | ||
378 | } | ||||
379 | |||||
380 | 2 | 24µs | 2 | 31µs | _debugData( '_parseAttributes result:', $inCollection ); # spent 31µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_debugData, avg 15µs/call |
381 | } | ||||
382 | |||||
383 | =pod | ||||
384 | |||||
385 | _getIncludeParams( $includeTopic ) -> \%params | ||||
386 | |||||
387 | From $includeTopic read the first TABLE tag and return its parameters. | ||||
388 | |||||
389 | =cut | ||||
390 | |||||
391 | sub _getIncludeParams { | ||||
392 | my ($inIncludeTopic) = @_; | ||||
393 | |||||
394 | my ( $includeWeb, $includeTopic ) = | ||||
395 | Foswiki::Func::normalizeWebTopicName( $Foswiki::Plugins::TablePlugin::web, | ||||
396 | $inIncludeTopic ); | ||||
397 | |||||
398 | _debug("_getIncludeParams:$inIncludeTopic"); | ||||
399 | _debug("\t includeTopic=$includeTopic") if $includeTopic; | ||||
400 | |||||
401 | if ( !Foswiki::Func::topicExists( $includeWeb, $includeTopic ) ) { | ||||
402 | _debug("TablePlugin: included topic $inIncludeTopic does not exist."); | ||||
403 | die("TablePlugin: included topic $inIncludeTopic does not exist."); | ||||
404 | } | ||||
405 | else { | ||||
406 | |||||
407 | my $text = Foswiki::Func::readTopicText( $includeWeb, $includeTopic ); | ||||
408 | |||||
409 | $text =~ /$PATTERN_TABLE/os; | ||||
410 | if ($1) { | ||||
411 | my $paramString = $1; | ||||
412 | |||||
413 | if ( $includeWeb ne $Foswiki::Plugins::TablePlugin::web | ||||
414 | || $includeTopic ne $Foswiki::Plugins::TablePlugin::topic ) | ||||
415 | { | ||||
416 | |||||
417 | # expand common vars, except oneself to prevent recursion | ||||
418 | $paramString = | ||||
419 | Foswiki::Func::expandCommonVariables( $paramString, | ||||
420 | $includeTopic, $includeWeb ); | ||||
421 | } | ||||
422 | my %params = Foswiki::Func::extractParameters($paramString); | ||||
423 | return \%params; | ||||
424 | } | ||||
425 | } | ||||
426 | return undef; | ||||
427 | } | ||||
428 | |||||
429 | =pod | ||||
430 | |||||
431 | _convertStringToDate ( $text ) -> $number | ||||
432 | |||||
433 | Convert text to number if syntactically possible, otherwise return undef. | ||||
434 | Assumes that the text has been stripped from HTML markup. | ||||
435 | |||||
436 | =cut | ||||
437 | |||||
438 | sub _convertStringToDate { | ||||
439 | my ($text) = @_; | ||||
440 | |||||
441 | return undef if !defined $text; | ||||
442 | return undef if $text eq ''; | ||||
443 | return undef if ( $text =~ /^\s*$/ ); | ||||
444 | |||||
445 | my $date = undef; | ||||
446 | |||||
447 | if ( $text =~ /^\s*-?[0-9]+(\.[0-9])*\s*$/ ) { | ||||
448 | _debug("\t this is a number"); | ||||
449 | } | ||||
450 | else { | ||||
451 | try { | ||||
452 | $date = Foswiki::Time::parseTime($text); | ||||
453 | _debug("\t is a date"); | ||||
454 | } | ||||
455 | catch Error::Simple with { | ||||
456 | |||||
457 | # nope, wasn't a date | ||||
458 | _debug("\t $text is not a date"); | ||||
459 | }; | ||||
460 | } | ||||
461 | |||||
462 | return $date; | ||||
463 | } | ||||
464 | |||||
465 | =pod | ||||
466 | |||||
467 | _convertStringToNumber ( $text ) -> $number | ||||
468 | |||||
469 | Convert text to number if syntactically possible, otherwise return undef. | ||||
470 | Assumes that the text has been stripped from HTML markup. | ||||
471 | |||||
472 | =cut | ||||
473 | |||||
474 | sub _convertStringToNumber { | ||||
475 | my ($text) = @_; | ||||
476 | |||||
477 | return undef if !defined $text; | ||||
478 | return undef if $text eq ''; | ||||
479 | return undef if ( $text =~ /^\s*$/ ); | ||||
480 | |||||
481 | # very course testing on IP (could in fact be anything with n.n. syntax | ||||
482 | if ( | ||||
483 | $text =~ m/ | ||||
484 | ^ | ||||
485 | \s* # any space | ||||
486 | (?: # don't need to capture | ||||
487 | [0-9]+ # digits | ||||
488 | \. # dot | ||||
489 | ) # | ||||
490 | {2,} # repeat more than once: exclude decimal numbers | ||||
491 | .*? # any string | ||||
492 | $ | ||||
493 | /x | ||||
494 | ) | ||||
495 | { | ||||
496 | _debug("\t $text looks like an IP address, or something similar"); | ||||
497 | |||||
498 | # should be sorted by text | ||||
499 | return undef; | ||||
500 | } | ||||
501 | |||||
502 | if ( | ||||
503 | $text =~ m/ | ||||
504 | ^ | ||||
505 | \s* # any space | ||||
506 | ( # | ||||
507 | -* # possible minus | ||||
508 | [0-9]+ # digits | ||||
509 | \.* # possible decimal | ||||
510 | [0-9]* # possible fracture digits | ||||
511 | ) # end capture of number | ||||
512 | .*$ # any string | ||||
513 | /x | ||||
514 | ) | ||||
515 | { | ||||
516 | |||||
517 | _debug("\t $1 is a number"); | ||||
518 | |||||
519 | # make sure to return a number, not a string | ||||
520 | return $1 * 1.0; | ||||
521 | } | ||||
522 | return undef; | ||||
523 | } | ||||
524 | |||||
525 | # spent 3.43ms (2.39+1.04) within Foswiki::Plugins::TablePlugin::Core::_processTableRow which was called 8 times, avg 429µs/call:
# 8 times (2.39ms+1.04ms) by Foswiki::Plugins::TablePlugin::Core::handler at line 1891, avg 429µs/call | ||||
526 | 8 | 30µs | my ( $thePre, $theRow ) = @_; | ||
527 | |||||
528 | 8 | 16µs | $currTablePre = $thePre || ''; | ||
529 | 8 | 11µs | my $span = 0; | ||
530 | 8 | 10µs | my $l1 = 0; | ||
531 | 8 | 11µs | my $l2 = 0; | ||
532 | |||||
533 | 8 | 14µs | if ( !$insideTABLE ) { | ||
534 | 2 | 61µs | @curTable = (); | ||
535 | 2 | 3µs | @rowspan = (); | ||
536 | |||||
537 | 2 | 3µs | $tableCount++; | ||
538 | 2 | 5µs | $currentSortDirection = $SORT_DIRECTION->{'NONE'}; | ||
539 | |||||
540 | 2 | 6µs | if ( defined $requestedTable | ||
541 | && $requestedTable == $tableCount | ||||
542 | && defined $sortColFromUrl ) | ||||
543 | { | ||||
544 | $sortCol = $sortColFromUrl; | ||||
545 | $sortCol = 0 unless ( $sortCol =~ m/^[0-9]+$/ ); | ||||
546 | $sortCol = $MAX_SORT_COLS if ( $sortCol > $MAX_SORT_COLS ); | ||||
547 | $currentSortDirection = _getCurrentSortDirection($up); | ||||
548 | } | ||||
549 | elsif ( defined $combinedTableAttrs->{initSort} ) { | ||||
550 | $sortCol = $combinedTableAttrs->{initSort} - 1; | ||||
551 | $sortCol = $MAX_SORT_COLS if ( $sortCol > $MAX_SORT_COLS ); | ||||
552 | $currentSortDirection = | ||||
553 | _getCurrentSortDirection( $combinedTableAttrs->{initDirection} ); | ||||
554 | } | ||||
555 | } | ||||
556 | |||||
557 | 8 | 57µs | 8 | 15µs | $theRow =~ s/\t/ /go; # change tabs to space # spent 15µs making 8 calls to Foswiki::Plugins::TablePlugin::Core::CORE:subst, avg 2µs/call |
558 | 8 | 118µs | 8 | 80µs | $theRow =~ s/\s*$//o; # remove trailing spaces # spent 80µs making 8 calls to Foswiki::Plugins::TablePlugin::Core::CORE:subst, avg 10µs/call |
559 | $theRow =~ | ||||
560 | 8 | 47µs | 8 | 13µs | s/(\|\|+)/'colspan'.$translationToken.length($1)."\|"/geo; # calc COLSPAN # spent 13µs making 8 calls to Foswiki::Plugins::TablePlugin::Core::CORE:subst, avg 2µs/call |
561 | 8 | 11µs | my $colCount = 0; | ||
562 | 8 | 15µs | my @row = (); | ||
563 | 8 | 12µs | $span = 0; | ||
564 | 8 | 15µs | my $value = ''; | ||
565 | |||||
566 | 8 | 47µs | foreach ( split( /\|/, $theRow ) ) { | ||
567 | 22 | 38µs | my $attr = {}; | ||
568 | 22 | 28µs | $span = 1; | ||
569 | |||||
570 | #AS 25-5-01 Fix to avoid matching also single columns | ||||
571 | 22 | 286µs | 44 | 102µs | if (s/colspan$translationToken([0-9]+)//) { # spent 66µs making 22 calls to Foswiki::Plugins::TablePlugin::Core::CORE:regcomp, avg 3µs/call
# spent 35µs making 22 calls to Foswiki::Plugins::TablePlugin::Core::CORE:subst, avg 2µs/call |
572 | $span = $1; | ||||
573 | $attr->{colspan} = $span; | ||||
574 | } | ||||
575 | 22 | 157µs | 22 | 61µs | s/^\s+$/ /o; # spent 61µs making 22 calls to Foswiki::Plugins::TablePlugin::Core::CORE:subst, avg 3µs/call |
576 | 22 | 36µs | ( $l1, $l2 ) = ( 0, 0 ); | ||
577 | 22 | 243µs | 22 | 110µs | if (/^(\s*).*?(\s*)$/) { # spent 110µs making 22 calls to Foswiki::Plugins::TablePlugin::Core::CORE:match, avg 5µs/call |
578 | 22 | 48µs | $l1 = length($1); | ||
579 | 22 | 35µs | $l2 = length($2); | ||
580 | } | ||||
581 | 22 | 32µs | if ( $l1 >= 2 ) { | ||
582 | if ( $l2 <= 1 ) { | ||||
583 | $attr->{align} = 'right'; | ||||
584 | } | ||||
585 | else { | ||||
586 | $attr->{align} = 'center'; | ||||
587 | } | ||||
588 | } | ||||
589 | 22 | 73µs | if ( $span <= 2 ) { | ||
590 | 22 | 185µs | 22 | 499µs | $attr->{class} = # spent 499µs making 22 calls to Foswiki::Plugins::TablePlugin::Core::_appendColNumberCssClass, avg 23µs/call |
591 | _appendColNumberCssClass( $attr->{class}, $colCount ); | ||||
592 | } | ||||
593 | |||||
594 | # html attribute: (column) width | ||||
595 | 22 | 36µs | if ( $combinedTableAttrs->{generateInlineMarkup} | ||
596 | && defined $combinedTableAttrs->{columnWidthsListRef} ) | ||||
597 | { | ||||
598 | my @columnWidths = @{ $combinedTableAttrs->{columnWidthsListRef} }; | ||||
599 | if ( defined $columnWidths[$colCount] | ||||
600 | && $columnWidths[$colCount] | ||||
601 | && $span <= 2 ) | ||||
602 | { | ||||
603 | $attr->{width} = $columnWidths[$colCount]; | ||||
604 | } | ||||
605 | } | ||||
606 | |||||
607 | # END html attribute | ||||
608 | |||||
609 | 22 | 183µs | 22 | 42µs | if (/^(\s|<[^>]*>)*\^(\s|<[^>]*>)*$/) { # row span above # spent 42µs making 22 calls to Foswiki::Plugins::TablePlugin::Core::CORE:match, avg 2µs/call |
610 | $rowspan[$colCount]++; | ||||
611 | push @row, { text => $value, type => 'Y' }; | ||||
612 | } | ||||
613 | else { | ||||
614 | 22 | 155µs | for ( my $col = $colCount ; $col < ( $colCount + $span ) ; $col++ ) | ||
615 | { | ||||
616 | 22 | 38µs | if ( defined( $rowspan[$col] ) && $rowspan[$col] ) { | ||
617 | my $nRows = scalar(@curTable); | ||||
618 | my $rspan = $rowspan[$col] + 1; | ||||
619 | if ( $rspan > 1 ) { | ||||
620 | $curTable[ $nRows - $rspan ][$col]->{attrs}->{rowspan} = | ||||
621 | $rspan; | ||||
622 | } | ||||
623 | undef( $rowspan[$col] ); | ||||
624 | } | ||||
625 | } | ||||
626 | |||||
627 | 22 | 45µs | if ( | ||
628 | ( | ||||
629 | ( | ||||
630 | defined $requestedTable | ||||
631 | && $requestedTable == $tableCount | ||||
632 | ) | ||||
633 | || defined $combinedTableAttrs->{initSort} | ||||
634 | ) | ||||
635 | && defined $sortCol | ||||
636 | && $colCount == $sortCol | ||||
637 | ) | ||||
638 | { | ||||
639 | |||||
640 | # CSS class name | ||||
641 | if ( $currentSortDirection == $SORT_DIRECTION->{'ASCENDING'} ) { | ||||
642 | $attr->{class} = | ||||
643 | _appendSortedAscendingCssClass( $attr->{class} ); | ||||
644 | } | ||||
645 | if ( $currentSortDirection == $SORT_DIRECTION->{'DESCENDING'} ) | ||||
646 | { | ||||
647 | $attr->{class} = | ||||
648 | _appendSortedDescendingCssClass( $attr->{class} ); | ||||
649 | } | ||||
650 | } | ||||
651 | |||||
652 | 22 | 34µs | my $type = ''; | ||
653 | 22 | 196µs | 22 | 67µs | if (/^\s*\*(.*)\*\s*$/) { # spent 67µs making 22 calls to Foswiki::Plugins::TablePlugin::Core::CORE:match, avg 3µs/call |
654 | 11 | 28µs | $value = $1; | ||
655 | 11 | 15µs | $type = 'th'; | ||
656 | |||||
657 | # html attribute: align | ||||
658 | 11 | 18µs | if ( $combinedTableAttrs->{generateInlineMarkup} | ||
659 | && defined $combinedTableAttrs->{headerAlignListRef} ) | ||||
660 | { | ||||
661 | my @headerAlign = | ||||
662 | @{ $combinedTableAttrs->{headerAlignListRef} }; | ||||
663 | if (@headerAlign) { | ||||
664 | my $align = | ||||
665 | @headerAlign[ $colCount % ( $#headerAlign + 1 ) ]; | ||||
666 | $attr->{align} = $align; | ||||
667 | } | ||||
668 | } | ||||
669 | |||||
670 | # END html attribute | ||||
671 | |||||
672 | # html attribute: valign | ||||
673 | 11 | 17µs | if ( $combinedTableAttrs->{generateInlineMarkup} ) { | ||
674 | if ( defined $combinedTableAttrs->{headerVAlign} ) { | ||||
675 | $attr->{valign} = $combinedTableAttrs->{headerVAlign}; | ||||
676 | } | ||||
677 | elsif ( defined $combinedTableAttrs->{vAlign} ) { | ||||
678 | $attr->{valign} = $combinedTableAttrs->{vAlign}; | ||||
679 | } | ||||
680 | } | ||||
681 | |||||
682 | # END html attribute | ||||
683 | } | ||||
684 | else { | ||||
685 | 11 | 118µs | 11 | 52µs | if (/^\s*(.*?)\s*$/) { # strip white spaces # spent 52µs making 11 calls to Foswiki::Plugins::TablePlugin::Core::CORE:match, avg 5µs/call |
686 | 11 | 30µs | $_ = $1; | ||
687 | } | ||||
688 | 11 | 14µs | $value = $_; | ||
689 | 11 | 16µs | $type = 'td'; | ||
690 | |||||
691 | # html attribute: align | ||||
692 | 11 | 18µs | if ( $combinedTableAttrs->{generateInlineMarkup} | ||
693 | && defined $combinedTableAttrs->{dataAlignListRef} ) | ||||
694 | { | ||||
695 | my @dataAlign = | ||||
696 | @{ $combinedTableAttrs->{dataAlignListRef} }; | ||||
697 | if (@dataAlign) { | ||||
698 | my $align = | ||||
699 | @dataAlign[ $colCount % ( $#dataAlign + 1 ) ]; | ||||
700 | $attr->{align} = $align; | ||||
701 | } | ||||
702 | } | ||||
703 | |||||
704 | # END html attribute | ||||
705 | |||||
706 | # html attribute: valign | ||||
707 | 11 | 17µs | if ( $combinedTableAttrs->{generateInlineMarkup} ) { | ||
708 | if ( defined $combinedTableAttrs->{dataVAlign} ) { | ||||
709 | $attr->{valign} = $combinedTableAttrs->{dataVAlign}; | ||||
710 | } | ||||
711 | elsif ( defined $combinedTableAttrs->{vAlign} ) { | ||||
712 | $attr->{valign} = $combinedTableAttrs->{vAlign}; | ||||
713 | } | ||||
714 | } | ||||
715 | |||||
716 | # END html attribute | ||||
717 | } | ||||
718 | |||||
719 | 22 | 91µs | push @row, { text => $value, attrs => $attr, type => $type }; | ||
720 | } | ||||
721 | 22 | 57µs | while ( $span > 1 ) { | ||
722 | push @row, { text => $value, type => 'X' }; | ||||
723 | $colCount++; | ||||
724 | $span--; | ||||
725 | } | ||||
726 | 22 | 72µs | $colCount++; | ||
727 | } | ||||
728 | 8 | 15µs | push @curTable, \@row; | ||
729 | 8 | 60µs | return $currTablePre | ||
730 | . '<nop>'; # Avoid Foswiki converting empty lines to new paras | ||||
731 | } | ||||
732 | |||||
733 | # spent 223µs within Foswiki::Plugins::TablePlugin::Core::_headerRowCount which was called 2 times, avg 111µs/call:
# 2 times (223µs+0s) by Foswiki::Plugins::TablePlugin::Core::emitTable at line 1354, avg 111µs/call | ||||
734 | 2 | 4µs | my ($table) = @_; | ||
735 | |||||
736 | 2 | 3µs | my $headerCount = 0; | ||
737 | 2 | 3µs | my $footerCount = 0; | ||
738 | 2 | 3µs | my $endheader = 0; | ||
739 | |||||
740 | # All cells in header are headings? | ||||
741 | 2 | 8µs | foreach my $row (@$table) { | ||
742 | 8 | 10µs | my $isHeader = 1; | ||
743 | 8 | 22µs | foreach my $cell (@$row) { | ||
744 | 22 | 76µs | if ( $cell->{type} ne 'th' ) { | ||
745 | 11 | 14µs | $isHeader = 0; | ||
746 | 11 | 11µs | $endheader = 1; | ||
747 | 11 | 14µs | $footerCount = 0 if $footerCount; | ||
748 | } | ||||
749 | } | ||||
750 | 8 | 32µs | unless ($endheader) { | ||
751 | 1 | 2µs | $headerCount++ if $isHeader; | ||
752 | } | ||||
753 | else { | ||||
754 | 7 | 9µs | $footerCount++ if $isHeader; | ||
755 | } | ||||
756 | } | ||||
757 | |||||
758 | # Some cells came after the footer - so there isn't one. | ||||
759 | 2 | 3µs | $footerCount = 0 if ( $endheader > 1 ); | ||
760 | |||||
761 | 2 | 17µs | return ( $headerCount, $footerCount ); | ||
762 | } | ||||
763 | |||||
764 | =pod | ||||
765 | |||||
766 | _setSortTypeForCells ( $col, \@table ) | ||||
767 | |||||
768 | Sets a sort key for each cell. | ||||
769 | |||||
770 | =cut | ||||
771 | |||||
772 | sub _setSortTypeForCells { | ||||
773 | my ( $col, $table ) = @_; | ||||
774 | |||||
775 | foreach my $row ( @{$table} ) { | ||||
776 | |||||
777 | my $rowText = _stripHtml( $row->[$col]->{text} ); | ||||
778 | |||||
779 | my $num = _convertStringToNumber($rowText); | ||||
780 | my $date = _convertStringToDate($rowText); | ||||
781 | |||||
782 | $row->[$col]->{sortText} = ''; | ||||
783 | $row->[$col]->{number} = 0; | ||||
784 | $row->[$col]->{dateString} = ''; | ||||
785 | |||||
786 | if ( defined $date ) { | ||||
787 | |||||
788 | # date has just converted to a number | ||||
789 | $row->[$col]->{number} = $date; | ||||
790 | |||||
791 | # add dateString value in case dates are equal | ||||
792 | $row->[$col]->{dateString} = $rowText; | ||||
793 | } | ||||
794 | elsif ( defined $num ) { | ||||
795 | $row->[$col]->{number} = $num; | ||||
796 | |||||
797 | # when sorting mixed numbers and text, make the text sort value as low as possible | ||||
798 | $row->[$col]->{sortText} = ' '; | ||||
799 | } | ||||
800 | else { | ||||
801 | $row->[$col]->{sortText} = lc $rowText; | ||||
802 | } | ||||
803 | |||||
804 | } | ||||
805 | } | ||||
806 | |||||
807 | # Remove HTML from text so it can be sorted | ||||
808 | sub _stripHtml { | ||||
809 | my ($text) = @_; | ||||
810 | |||||
811 | return undef if !defined $text; | ||||
812 | $text =~ | ||||
813 | s/\[\[[^\]]+\]\[([^\]]+)\]\]/$1/go; # extract label from [[...][...]] link | ||||
814 | |||||
815 | my $orgtext = | ||||
816 | $text; # in case we will have removed all contents with stripping html | ||||
817 | $text =~ s/<[^>]+>//go; # strip HTML | ||||
818 | $text =~ s/\ / /go; | ||||
819 | $text = _getImageTextForSorting($orgtext) if ( $text eq '' ); | ||||
820 | $text =~ s/[\[\]\*\|=_\&\<\>]/ /g; # remove Wiki formatting chars | ||||
821 | $text =~ s/^ *//go; # strip leading space space | ||||
822 | |||||
823 | return $text; | ||||
824 | } | ||||
825 | |||||
826 | =pod | ||||
827 | |||||
828 | Retrieve text data from an image html tag to be used for sorting. | ||||
829 | First try the alt tag string. If not available, return the url string. | ||||
830 | If not available, return the original string. | ||||
831 | |||||
832 | =cut | ||||
833 | |||||
834 | sub _getImageTextForSorting { | ||||
835 | my ($text) = @_; | ||||
836 | |||||
837 | # try to see _if_ there is any img data for sorting | ||||
838 | my $hasImageTag = ( $text =~ m/\<\s*img([^>]+)>/ ); | ||||
839 | return $text if ( !$hasImageTag ); | ||||
840 | |||||
841 | # first try to get the alt text | ||||
842 | my $key = 'alt'; | ||||
843 | $text =~ m/$key=\s*[\"\']([^\"\']*)/; | ||||
844 | return $1 if ( $1 ne '' ); | ||||
845 | |||||
846 | # else | ||||
847 | |||||
848 | # no alt text; use the url | ||||
849 | $key = 'url'; | ||||
850 | $text =~ m/$key=\s*[\"\']([^\"\']*)/; | ||||
851 | return $1 if ( $1 ne '' ); | ||||
852 | |||||
853 | # else | ||||
854 | |||||
855 | return $text; | ||||
856 | } | ||||
857 | |||||
858 | =pod | ||||
859 | |||||
860 | Appends $className to $classList, separated by a space. | ||||
861 | |||||
862 | =cut | ||||
863 | |||||
864 | # spent 569µs within Foswiki::Plugins::TablePlugin::Core::_appendToClassList which was called 69 times, avg 8µs/call:
# 22 times (194µs+0s) by Foswiki::Plugins::TablePlugin::Core::_appendColNumberCssClass at line 888, avg 9µs/call
# 16 times (123µs+0s) by Foswiki::Plugins::TablePlugin::Core::_appendRowNumberCssClass at line 881, avg 8µs/call
# 8 times (68µs+0s) by Foswiki::Plugins::TablePlugin::Core::emitTable at line 1727, avg 8µs/call
# 8 times (66µs+0s) by Foswiki::Plugins::TablePlugin::Core::_appendFirstColumnCssClass at line 894, avg 8µs/call
# 8 times (64µs+0s) by Foswiki::Plugins::TablePlugin::Core::_appendLastColumnCssClass at line 900, avg 8µs/call
# 7 times (54µs+0s) by Foswiki::Plugins::TablePlugin::Core::_appendLastRowCssClass at line 906, avg 8µs/call | ||||
865 | 69 | 113µs | my ( $classList, $className ) = @_; | ||
866 | 69 | 100µs | $classList = $classList ? $classList .= ' ' : ''; | ||
867 | 69 | 91µs | $classList .= $className; | ||
868 | 69 | 500µs | return $classList; | ||
869 | } | ||||
870 | |||||
871 | sub _appendSortedCssClass { | ||||
872 | my ($classList) = @_; | ||||
873 | |||||
874 | return _appendToClassList( $classList, 'foswikiSortedCol' ); | ||||
875 | } | ||||
876 | |||||
877 | # spent 329µs (206+123) within Foswiki::Plugins::TablePlugin::Core::_appendRowNumberCssClass which was called 16 times, avg 21µs/call:
# 8 times (108µs+62µs) by Foswiki::Plugins::TablePlugin::Core::emitTable at line 1732, avg 21µs/call
# 8 times (98µs+61µs) by Foswiki::Plugins::TablePlugin::Core::emitTable at line 1739, avg 20µs/call | ||||
878 | 16 | 29µs | my ( $classList, $colListName, $rowNum ) = @_; | ||
879 | |||||
880 | 16 | 31µs | my $rowClassName = 'foswikiTableRow' . $colListName . $rowNum; | ||
881 | 16 | 126µs | 16 | 123µs | return _appendToClassList( $classList, $rowClassName ); # spent 123µs making 16 calls to Foswiki::Plugins::TablePlugin::Core::_appendToClassList, avg 8µs/call |
882 | } | ||||
883 | |||||
884 | # spent 499µs (305+194) within Foswiki::Plugins::TablePlugin::Core::_appendColNumberCssClass which was called 22 times, avg 23µs/call:
# 22 times (305µs+194µs) by Foswiki::Plugins::TablePlugin::Core::_processTableRow at line 590, avg 23µs/call | ||||
885 | 22 | 47µs | my ( $classList, $colNum ) = @_; | ||
886 | |||||
887 | 22 | 41µs | my $colClassName = 'foswikiTableCol' . $colNum; | ||
888 | 22 | 181µs | 22 | 194µs | return _appendToClassList( $classList, $colClassName ); # spent 194µs making 22 calls to Foswiki::Plugins::TablePlugin::Core::_appendToClassList, avg 9µs/call |
889 | } | ||||
890 | |||||
891 | # spent 159µs (93+66) within Foswiki::Plugins::TablePlugin::Core::_appendFirstColumnCssClass which was called 8 times, avg 20µs/call:
# 8 times (93µs+66µs) by Foswiki::Plugins::TablePlugin::Core::emitTable at line 1702, avg 20µs/call | ||||
892 | 8 | 15µs | my ($classList) = @_; | ||
893 | |||||
894 | 8 | 64µs | 8 | 66µs | return _appendToClassList( $classList, 'foswikiFirstCol' ); # spent 66µs making 8 calls to Foswiki::Plugins::TablePlugin::Core::_appendToClassList, avg 8µs/call |
895 | } | ||||
896 | |||||
897 | # spent 229µs (165+64) within Foswiki::Plugins::TablePlugin::Core::_appendLastColumnCssClass which was called 8 times, avg 29µs/call:
# 8 times (165µs+64µs) by Foswiki::Plugins::TablePlugin::Core::emitTable at line 1705, avg 29µs/call | ||||
898 | 8 | 14µs | my ($classList) = @_; | ||
899 | |||||
900 | 8 | 68µs | 8 | 64µs | return _appendToClassList( $classList, 'foswikiLastCol' ); # spent 64µs making 8 calls to Foswiki::Plugins::TablePlugin::Core::_appendToClassList, avg 8µs/call |
901 | } | ||||
902 | |||||
903 | # spent 131µs (77+54) within Foswiki::Plugins::TablePlugin::Core::_appendLastRowCssClass which was called 7 times, avg 19µs/call:
# 7 times (77µs+54µs) by Foswiki::Plugins::TablePlugin::Core::emitTable at line 1708, avg 19µs/call | ||||
904 | 7 | 12µs | my ($classList) = @_; | ||
905 | |||||
906 | 7 | 56µs | 7 | 54µs | return _appendToClassList( $classList, 'foswikiLast' ); # spent 54µs making 7 calls to Foswiki::Plugins::TablePlugin::Core::_appendToClassList, avg 8µs/call |
907 | } | ||||
908 | |||||
909 | sub _appendSortedAscendingCssClass { | ||||
910 | my ($classList) = @_; | ||||
911 | |||||
912 | return _appendToClassList( $classList, 'foswikiSortedAscendingCol' ); | ||||
913 | } | ||||
914 | |||||
915 | sub _appendSortedDescendingCssClass { | ||||
916 | my ($classList) = @_; | ||||
917 | |||||
918 | return _appendToClassList( $classList, 'foswikiSortedDescendingCol' ); | ||||
919 | } | ||||
920 | |||||
921 | # The default sort direction. | ||||
922 | # spent 96µs within Foswiki::Plugins::TablePlugin::Core::_getDefaultSortDirection which was called 22 times, avg 4µs/call:
# 22 times (96µs+0s) by Foswiki::Plugins::TablePlugin::Core::emitTable at line 1539, avg 4µs/call | ||||
923 | 22 | 132µs | return $SORT_DIRECTION->{'ASCENDING'}; | ||
924 | } | ||||
925 | |||||
926 | # Gets the current sort direction. | ||||
927 | sub _getCurrentSortDirection { | ||||
928 | my ($currentDirection) = @_; | ||||
929 | $currentDirection = $SORT_DIRECTION->{'ASCENDING'} | ||||
930 | unless defined $currentDirection && $currentDirection =~ m/[0-2]+/; | ||||
931 | $currentDirection ||= _getDefaultSortDirection(); | ||||
932 | return $currentDirection; | ||||
933 | } | ||||
934 | |||||
935 | # Gets the new sort direction (needed for sort button) based on the current sort | ||||
936 | # direction. | ||||
937 | sub _getNewSortDirection { | ||||
938 | my ($currentDirection) = @_; | ||||
939 | if ( !defined $currentDirection ) { | ||||
940 | return _getDefaultSortDirection(); | ||||
941 | } | ||||
942 | my $newDirection; | ||||
943 | if ( $currentDirection == $SORT_DIRECTION->{'ASCENDING'} ) { | ||||
944 | $newDirection = $SORT_DIRECTION->{'DESCENDING'}; | ||||
945 | } | ||||
946 | elsif ( $currentDirection == $SORT_DIRECTION->{'DESCENDING'} ) { | ||||
947 | $newDirection = $SORT_DIRECTION->{'NONE'}; | ||||
948 | } | ||||
949 | elsif ( $currentDirection == $SORT_DIRECTION->{'NONE'} ) { | ||||
950 | $newDirection = $SORT_DIRECTION->{'ASCENDING'}; | ||||
951 | } | ||||
952 | else { | ||||
953 | $newDirection = _getDefaultSortDirection(); | ||||
954 | } | ||||
955 | |||||
956 | return $newDirection; | ||||
957 | } | ||||
958 | |||||
959 | =pod | ||||
960 | |||||
961 | _createCssStyles( $writeDefaults, $inAttrs ) -> ($id, @styles) | ||||
962 | |||||
963 | Explicitly set styles override html styling (in this file marked with comment '# html attribute'). | ||||
964 | |||||
965 | =cut | ||||
966 | |||||
967 | # spent 1.16ms (720µs+441µs) within Foswiki::Plugins::TablePlugin::Core::_createCssStyles which was called 2 times, avg 581µs/call:
# once (629µs+422µs) by Foswiki::Plugins::TablePlugin::Core::_addDefaultStyles at line 155
# once (91µs+19µs) by Foswiki::Plugins::TablePlugin::Core::_parseTableSpecificTableAttributes at line 216 | ||||
968 | 2 | 4µs | my ( $writeDefaults, $inAttrs ) = @_; | ||
969 | |||||
970 | 2 | 10µs | 2 | 31µs | _debug("_createCssStyles; writeDefaults=$writeDefaults"); # spent 31µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_debug, avg 16µs/call |
971 | |||||
972 | 2 | 4µs | my $_styles = {}; | ||
973 | # spent 323µs within Foswiki::Plugins::TablePlugin::Core::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TablePlugin/Core.pm:985] which was called 17 times, avg 19µs/call:
# 2 times (38µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1149, avg 19µs/call
# 2 times (37µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1164, avg 19µs/call
# once (24µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1023
# once (23µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 990
# once (21µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1037
# once (20µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1024
# once (18µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1129
# once (18µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1128
# once (18µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1088
# once (18µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1121
# once (18µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1111
# once (18µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1135
# once (17µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1089
# once (17µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1130
# once (17µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1127 | ||||
974 | 17 | 31µs | my ( $tableSelector, $type, $rule ) = @_; | ||
975 | |||||
976 | 17 | 21µs | return if !$rule; | ||
977 | 17 | 20µs | $type ||= '#'; # for table selector only, if no type | ||
978 | 17 | 35µs | my $storedType = $_styles->{$tableSelector}->{$type} || ''; | ||
979 | 17 | 22µs | if ( !defined $storedType ) { | ||
980 | @{ $_styles->{$tableSelector}->{$type} } = (); | ||||
981 | } | ||||
982 | 17 | 150µs | if ( $rule ne $storedType ) { | ||
983 | 34 | 104µs | push @{ $_styles->{$tableSelector}->{$type} }, $rule; | ||
984 | } | ||||
985 | 2 | 15µs | }; | ||
986 | |||||
987 | 2 | 4µs | if ( $writeDefaults && !$didWriteDefaultStyle ) { | ||
988 | 1 | 2µs | my $tableSelector = '.foswikiTable'; | ||
989 | 1 | 2µs | my $attr = 'padding-left:.3em; vertical-align:text-bottom'; | ||
990 | 1 | 6µs | 1 | 23µs | &$setAttribute( $tableSelector, '.tableSortIcon img', $attr ); |
991 | |||||
992 | 1 | 3µs | if ( $inAttrs->{cellpadding} ) { | ||
993 | my $attr = | ||||
994 | 'padding:' . addDefaultSizeUnit( $inAttrs->{cellpadding} ); | ||||
995 | &$setAttribute( $tableSelector, 'td', $attr ); | ||||
996 | &$setAttribute( $tableSelector, 'th', $attr ); | ||||
997 | } | ||||
998 | } | ||||
999 | |||||
1000 | 2 | 2µs | my $tableSelector; | ||
1001 | 2 | 2µs | my $id; | ||
1002 | 2 | 5µs | if ($writeDefaults) { | ||
1003 | 1 | 2µs | $id = 'default'; | ||
1004 | 1 | 1µs | $tableSelector = ".foswikiTable"; | ||
1005 | } | ||||
1006 | else { | ||||
1007 | 1 | 2µs | $id = $inAttrs->{id}; | ||
1008 | 1 | 2µs | $tableSelector = ".foswikiTable#$id"; | ||
1009 | } | ||||
1010 | |||||
1011 | # tablerules | ||||
1012 | 2 | 5µs | if ( $inAttrs->{tableRules} ) { | ||
1013 | 2 | 6µs | my @rules = @{ $inAttrs->{tableRules} }; | ||
1014 | |||||
1015 | 1 | 1µs | my $attr_td; | ||
1016 | 1 | 1µs | my $attr_th; | ||
1017 | 1 | 4µs | foreach my $rule (@rules) { | ||
1018 | 2 | 6µs | $attr_td = $TABLE_RULES->{$rule}->{TD} | ||
1019 | if $TABLE_RULES->{$rule}->{TD}; | ||||
1020 | 2 | 8µs | $attr_th = $TABLE_RULES->{$rule}->{TH} | ||
1021 | if $TABLE_RULES->{$rule}->{TH}; | ||||
1022 | } | ||||
1023 | 1 | 5µs | 1 | 24µs | &$setAttribute( $tableSelector, 'th', $attr_th ); |
1024 | 1 | 6µs | 1 | 20µs | &$setAttribute( $tableSelector, 'td', $attr_td ); |
1025 | } | ||||
1026 | |||||
1027 | # tableframe | ||||
1028 | 2 | 4µs | if ( $inAttrs->{frame} ) { | ||
1029 | my $attr = $TABLE_FRAME->{ $inAttrs->{frame} }; | ||||
1030 | &$setAttribute( $tableSelector, '', $attr ); | ||||
1031 | } | ||||
1032 | |||||
1033 | # tableborder | ||||
1034 | 2 | 5µs | if ( defined $inAttrs->{border} ) { | ||
1035 | 1 | 2µs | my $tableBorderWidth = $inAttrs->{border} || 0; | ||
1036 | 1 | 7µs | 1 | 33µs | my $attr = 'border-width:' . addDefaultSizeUnit($tableBorderWidth); # spent 33µs making 1 call to Foswiki::Plugins::TablePlugin::Core::addDefaultSizeUnit |
1037 | 1 | 6µs | 1 | 21µs | &$setAttribute( $tableSelector, '', $attr ); |
1038 | } | ||||
1039 | |||||
1040 | # tableBorderColor | ||||
1041 | 2 | 3µs | if ( defined $inAttrs->{tableBorderColor} ) { | ||
1042 | my $attr; | ||||
1043 | $attr = 'border-color:' . $inAttrs->{tableBorderColor}; | ||||
1044 | &$setAttribute( $tableSelector, '', $attr ); | ||||
1045 | $attr = 'border-top-color:' . $inAttrs->{tableBorderColor}; | ||||
1046 | &$setAttribute( $tableSelector, '', $attr ); | ||||
1047 | $attr = 'border-bottom-color:' . $inAttrs->{tableBorderColor}; | ||||
1048 | &$setAttribute( $tableSelector, '', $attr ); | ||||
1049 | $attr = 'border-left-color:' . $inAttrs->{tableBorderColor}; | ||||
1050 | &$setAttribute( $tableSelector, '', $attr ); | ||||
1051 | $attr = 'border-right-color:' . $inAttrs->{tableBorderColor}; | ||||
1052 | &$setAttribute( $tableSelector, '', $attr ); | ||||
1053 | } | ||||
1054 | |||||
1055 | # cellSpacing | ||||
1056 | 2 | 3µs | if ( defined $inAttrs->{cellspacing} ) { | ||
1057 | |||||
1058 | # do not use border-collapse:collapse | ||||
1059 | my $attr = 'border-collapse:separate'; | ||||
1060 | &$setAttribute( $tableSelector, '', $attr ); | ||||
1061 | } | ||||
1062 | |||||
1063 | # cellpadding | ||||
1064 | 2 | 3µs | if ( defined $inAttrs->{cellpadding} ) { | ||
1065 | my $attr = 'padding:' . addDefaultSizeUnit( $inAttrs->{cellpadding} ); | ||||
1066 | &$setAttribute( $tableSelector, 'td', $attr ); | ||||
1067 | &$setAttribute( $tableSelector, 'th', $attr ); | ||||
1068 | } | ||||
1069 | |||||
1070 | # cellborder | ||||
1071 | 2 | 3µs | if ( defined $inAttrs->{cellBorder} ) { | ||
1072 | my $cellBorderWidth = $inAttrs->{cellBorder} || 0; | ||||
1073 | my $attr = 'border-width:' . addDefaultSizeUnit($cellBorderWidth); | ||||
1074 | &$setAttribute( $tableSelector, 'td', $attr ); | ||||
1075 | &$setAttribute( $tableSelector, 'th', $attr ); | ||||
1076 | } | ||||
1077 | |||||
1078 | # tablewidth | ||||
1079 | 2 | 3µs | if ( defined $inAttrs->{width} ) { | ||
1080 | my $width = addDefaultSizeUnit( $inAttrs->{width} ); | ||||
1081 | my $attr = 'width:' . $width; | ||||
1082 | &$setAttribute( $tableSelector, '', $attr ); | ||||
1083 | } | ||||
1084 | |||||
1085 | # valign | ||||
1086 | 2 | 5µs | if ( defined $inAttrs->{vAlign} ) { | ||
1087 | 1 | 3µs | my $attr = 'vertical-align:' . $inAttrs->{vAlign}; | ||
1088 | 1 | 5µs | 1 | 18µs | &$setAttribute( $tableSelector, 'td', $attr ); |
1089 | 1 | 5µs | 1 | 17µs | &$setAttribute( $tableSelector, 'th', $attr ); |
1090 | } | ||||
1091 | |||||
1092 | # headerVAlign | ||||
1093 | 2 | 3µs | if ( defined $inAttrs->{headerVAlign} ) { | ||
1094 | my $attr = 'vertical-align:' . $inAttrs->{headerVAlign}; | ||||
1095 | &$setAttribute( $tableSelector, 'th', $attr ); | ||||
1096 | } | ||||
1097 | |||||
1098 | # dataVAlign | ||||
1099 | 2 | 3µs | if ( defined $inAttrs->{dataVAlign} ) { | ||
1100 | my $attr = 'vertical-align:' . $inAttrs->{dataVAlign}; | ||||
1101 | &$setAttribute( $tableSelector, 'td', $attr ); | ||||
1102 | } | ||||
1103 | |||||
1104 | # headerbg | ||||
1105 | 2 | 4µs | if ( defined $inAttrs->{headerBg} ) { | ||
1106 | 1 | 12µs | 1 | 2µs | my $color = # spent 2µs making 1 call to Foswiki::Plugins::TablePlugin::Core::CORE:match |
1107 | ( $inAttrs->{headerBg} =~ /none/i ) | ||||
1108 | ? 'transparent' | ||||
1109 | : $inAttrs->{headerBg}; | ||||
1110 | 1 | 3µs | my $attr = 'background-color:' . $color; | ||
1111 | 1 | 5µs | 1 | 18µs | &$setAttribute( $tableSelector, 'th', $attr ); |
1112 | } | ||||
1113 | |||||
1114 | # headerbgsorted | ||||
1115 | 2 | 4µs | if ( defined $inAttrs->{headerBgSorted} ) { | ||
1116 | 1 | 10µs | 1 | 2µs | my $color = # spent 2µs making 1 call to Foswiki::Plugins::TablePlugin::Core::CORE:match |
1117 | ( $inAttrs->{headerBgSorted} =~ /none/i ) | ||||
1118 | ? 'transparent' | ||||
1119 | : $inAttrs->{headerBgSorted}; | ||||
1120 | 1 | 3µs | my $attr = 'background-color:' . $color; | ||
1121 | 1 | 5µs | 1 | 18µs | &$setAttribute( $tableSelector, 'th.foswikiSortedCol', $attr ); |
1122 | } | ||||
1123 | |||||
1124 | # headercolor | ||||
1125 | 2 | 4µs | if ( defined $inAttrs->{headerColor} ) { | ||
1126 | 1 | 2µs | my $attr = 'color:' . $inAttrs->{headerColor}; | ||
1127 | 1 | 5µs | 1 | 17µs | &$setAttribute( $tableSelector, 'th', $attr ); |
1128 | 1 | 5µs | 1 | 18µs | &$setAttribute( $tableSelector, 'th a:link', $attr ); |
1129 | 1 | 5µs | 1 | 18µs | &$setAttribute( $tableSelector, 'th a:visited', $attr ); |
1130 | 1 | 5µs | 1 | 17µs | &$setAttribute( $tableSelector, 'th a:xhover', $attr ) |
1131 | ; # just to make sorting work: hover should be last. below we will remove the x again. | ||||
1132 | 1 | 3µs | if ( defined $inAttrs->{headerBg} ) { | ||
1133 | 1 | 2µs | my $hoverBackgroundColor = $inAttrs->{headerBg}; | ||
1134 | 1 | 2µs | $attr = 'background-color:' . $hoverBackgroundColor; | ||
1135 | 1 | 5µs | 1 | 18µs | &$setAttribute( $tableSelector, 'th a:xhover', $attr ); |
1136 | } | ||||
1137 | } | ||||
1138 | |||||
1139 | # databg (array) | ||||
1140 | 2 | 5µs | if ( defined $inAttrs->{dataBgListRef} ) { | ||
1141 | 2 | 6µs | my @dataBg = @{ $inAttrs->{dataBgListRef} }; | ||
1142 | 1 | 9µs | 1 | 2µs | my $noneColor = ( $dataBg[0] =~ /none/i ) ? 'transparent' : ''; # spent 2µs making 1 call to Foswiki::Plugins::TablePlugin::Core::CORE:match |
1143 | 1 | 1µs | my $count = 0; | ||
1144 | 1 | 4µs | foreach my $color (@dataBg) { | ||
1145 | 2 | 2µs | $color = $noneColor if $noneColor; | ||
1146 | 2 | 2µs | next if !$color; | ||
1147 | 2 | 5µs | my $rowSelector = 'foswikiTableRow' . 'dataBg' . $count; | ||
1148 | 2 | 4µs | my $attr = "background-color:$color"; | ||
1149 | 2 | 11µs | 2 | 38µs | &$setAttribute( $tableSelector, "tr.$rowSelector td", $attr ); # spent 38µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TablePlugin/Core.pm:985], avg 19µs/call |
1150 | 2 | 7µs | $count++; | ||
1151 | } | ||||
1152 | } | ||||
1153 | |||||
1154 | # databgsorted (array) | ||||
1155 | 2 | 4µs | if ( defined $inAttrs->{dataBgSortedListRef} ) { | ||
1156 | 2 | 5µs | my @dataBgSorted = @{ $inAttrs->{dataBgSortedListRef} }; | ||
1157 | 1 | 9µs | 1 | 2µs | my $noneColor = ( $dataBgSorted[0] =~ /none/i ) ? 'transparent' : ''; # spent 2µs making 1 call to Foswiki::Plugins::TablePlugin::Core::CORE:match |
1158 | 1 | 1µs | my $count = 0; | ||
1159 | 1 | 4µs | foreach my $color (@dataBgSorted) { | ||
1160 | 2 | 3µs | $color = $noneColor if $noneColor; | ||
1161 | 2 | 2µs | next if !$color; | ||
1162 | 2 | 5µs | my $rowSelector = 'foswikiTableRow' . 'dataBg' . $count; | ||
1163 | 2 | 3µs | my $attr = "background-color:$color"; | ||
1164 | 2 | 11µs | 2 | 37µs | &$setAttribute( $tableSelector, # spent 37µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TablePlugin/Core.pm:985], avg 19µs/call |
1165 | "tr.$rowSelector td.foswikiSortedCol", $attr ); | ||||
1166 | 2 | 6µs | $count++; | ||
1167 | } | ||||
1168 | } | ||||
1169 | |||||
1170 | # datacolor (array) | ||||
1171 | 2 | 3µs | if ( defined $inAttrs->{dataColorListRef} ) { | ||
1172 | my @dataColor = @{ $inAttrs->{dataColorListRef} }; | ||||
1173 | unless ( $dataColor[0] =~ /none/i ) { | ||||
1174 | my $count = 0; | ||||
1175 | foreach my $color (@dataColor) { | ||||
1176 | next if !$color; | ||||
1177 | my $rowSelector = 'foswikiTableRow' . 'dataColor' . $count; | ||||
1178 | my $attr = "color:$color"; | ||||
1179 | &$setAttribute( $tableSelector, "tr.$rowSelector td", $attr ); | ||||
1180 | $count++; | ||||
1181 | } | ||||
1182 | } | ||||
1183 | } | ||||
1184 | |||||
1185 | # columnwidths | ||||
1186 | 2 | 3µs | if ( defined $inAttrs->{columnWidthsListRef} ) { | ||
1187 | my @columnWidths = @{ $inAttrs->{columnWidthsListRef} }; | ||||
1188 | my $count = 0; | ||||
1189 | foreach my $width (@columnWidths) { | ||||
1190 | next if !$width; | ||||
1191 | $width = addDefaultSizeUnit($width); | ||||
1192 | my $colSelector = 'foswikiTableCol'; | ||||
1193 | $colSelector .= $count; | ||||
1194 | my $attr = 'width:' . $width; | ||||
1195 | &$setAttribute( $tableSelector, "td.$colSelector", $attr ); | ||||
1196 | &$setAttribute( $tableSelector, "th.$colSelector", $attr ); | ||||
1197 | $count++; | ||||
1198 | } | ||||
1199 | } | ||||
1200 | |||||
1201 | # headeralign | ||||
1202 | 2 | 3µs | if ( defined $inAttrs->{headerAlignListRef} ) { | ||
1203 | my @headerAlign = @{ $inAttrs->{headerAlignListRef} }; | ||||
1204 | if ( scalar @headerAlign == 1 ) { | ||||
1205 | my $align = $headerAlign[0]; | ||||
1206 | my $attr = 'text-align:' . $align; | ||||
1207 | &$setAttribute( $tableSelector, 'th', $attr ); | ||||
1208 | } | ||||
1209 | else { | ||||
1210 | my $count = 0; | ||||
1211 | foreach my $align (@headerAlign) { | ||||
1212 | next if !$align; | ||||
1213 | my $colSelector = 'foswikiTableCol'; | ||||
1214 | $colSelector .= $count; | ||||
1215 | my $attr = 'text-align:' . $align; | ||||
1216 | &$setAttribute( $tableSelector, "th.$colSelector", $attr ); | ||||
1217 | $count++; | ||||
1218 | } | ||||
1219 | } | ||||
1220 | } | ||||
1221 | |||||
1222 | # dataAlign | ||||
1223 | 2 | 3µs | if ( defined $inAttrs->{dataAlignListRef} ) { | ||
1224 | my @dataAlign = @{ $inAttrs->{dataAlignListRef} }; | ||||
1225 | if ( scalar @dataAlign == 1 ) { | ||||
1226 | my $align = $dataAlign[0]; | ||||
1227 | my $attr = 'text-align:' . $align; | ||||
1228 | &$setAttribute( $tableSelector, 'td', $attr ); | ||||
1229 | } | ||||
1230 | else { | ||||
1231 | my $count = 0; | ||||
1232 | foreach my $align (@dataAlign) { | ||||
1233 | next if !$align; | ||||
1234 | my $colSelector = 'foswikiTableCol'; | ||||
1235 | $colSelector .= $count; | ||||
1236 | my $attr = 'text-align:' . $align; | ||||
1237 | &$setAttribute( $tableSelector, "td.$colSelector", $attr ); | ||||
1238 | $count++; | ||||
1239 | } | ||||
1240 | } | ||||
1241 | } | ||||
1242 | |||||
1243 | 2 | 4µs | my @styles = (); | ||
1244 | 4 | 42µs | 2 | 14µs | foreach my $tableSelector ( sort keys %{$_styles} ) { # spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::CORE:sort, avg 7µs/call |
1245 | 2 | 24µs | 1 | 8µs | foreach my $selector ( sort keys %{ $_styles->{$tableSelector} } ) { # spent 8µs making 1 call to Foswiki::Plugins::TablePlugin::Core::CORE:sort |
1246 | 12 | 22µs | my $selectors = | ||
1247 | 12 | 41µs | join( '; ', @{ $_styles->{$tableSelector}->{$selector} } ); | ||
1248 | 12 | 82µs | 12 | 25µs | $selector =~ s/xhover/hover/go; # remove sorting hack # spent 25µs making 12 calls to Foswiki::Plugins::TablePlugin::Core::CORE:subst, avg 2µs/call |
1249 | # TODO: optimize by combining identical rules | ||||
1250 | 12 | 50µs | if ( $selector eq '#' ) { | ||
1251 | 1 | 4µs | push @styles, "$tableSelector {$selectors}"; | ||
1252 | } | ||||
1253 | else { | ||||
1254 | 11 | 29µs | push @styles, "$tableSelector $selector {$selectors}"; | ||
1255 | } | ||||
1256 | } | ||||
1257 | } | ||||
1258 | |||||
1259 | 2 | 40µs | return ( $id, @styles ); | ||
1260 | } | ||||
1261 | |||||
1262 | # spent 3.26ms (29µs+3.23) within Foswiki::Plugins::TablePlugin::Core::_addHeadStyles which was called:
# once (29µs+3.23ms) by Foswiki::Plugins::TablePlugin::Core::_addDefaultStyles at line 156 | ||||
1263 | 1 | 5µs | my ( $inId, @inStyles ) = @_; | ||
1264 | |||||
1265 | 1 | 2µs | return if !scalar @inStyles; | ||
1266 | |||||
1267 | 1 | 4µs | $styles->{seendIds}->{$inId} = 1; | ||
1268 | 1 | 8µs | if ( $inId eq $HEAD_ID_DEFAULT_STYLE ) { | ||
1269 | 1 | 3µs | $styles->{$HEAD_ID_DEFAULT_STYLE}->{'default'} = \@inStyles; | ||
1270 | 1 | 6µs | 1 | 3.23ms | _writeStyleToHead( $HEAD_ID_DEFAULT_STYLE, # spent 3.23ms making 1 call to Foswiki::Plugins::TablePlugin::Core::_writeStyleToHead |
1271 | $styles->{$HEAD_ID_DEFAULT_STYLE} ); | ||||
1272 | } | ||||
1273 | else { | ||||
1274 | $styles->{$HEAD_ID_SPECIFIC_STYLE}->{$inId} = \@inStyles; | ||||
1275 | _writeStyleToHead( $HEAD_ID_SPECIFIC_STYLE, | ||||
1276 | $styles->{$HEAD_ID_SPECIFIC_STYLE} ); | ||||
1277 | } | ||||
1278 | } | ||||
1279 | |||||
1280 | =pod | ||||
1281 | |||||
1282 | _getInlineMarkupStyle( $id, @styles ) -> $text | ||||
1283 | |||||
1284 | Creates an inline HTML markup | ||||
1285 | |||||
1286 | =cut | ||||
1287 | |||||
1288 | sub _getInlineMarkupStyle { | ||||
1289 | my ( $inId, @inStyles ) = @_; | ||||
1290 | |||||
1291 | } | ||||
1292 | |||||
1293 | # spent 3.23ms (68µs+3.16) within Foswiki::Plugins::TablePlugin::Core::_writeStyleToHead which was called:
# once (68µs+3.16ms) by Foswiki::Plugins::TablePlugin::Core::_addHeadStyles at line 1270 | ||||
1294 | 1 | 2µs | my ( $inId, $inStyles ) = @_; | ||
1295 | |||||
1296 | 1 | 2µs | my @allStyles = (); | ||
1297 | 2 | 17µs | 1 | 4µs | foreach my $id ( sort keys %{$inStyles} ) { # spent 4µs making 1 call to Foswiki::Plugins::TablePlugin::Core::CORE:sort |
1298 | 2 | 10µs | push @allStyles, @{ $inStyles->{$id} }; | ||
1299 | } | ||||
1300 | 1 | 6µs | my $styleText = join( "\n", @allStyles ); | ||
1301 | |||||
1302 | 1 | 4µs | my $header = <<EOS; | ||
1303 | <style type="text/css" media="all"> | ||||
1304 | $styleText | ||||
1305 | </style> | ||||
1306 | EOS | ||||
1307 | 1 | 3.10ms | 3 | 3.09ms | $header =~ s/(.*?)\s*$/$1/; # remove last newline # spent 3.08ms making 1 call to Foswiki::Plugins::TablePlugin::Core::CORE:subst
# spent 7µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::CORE:substcont, avg 3µs/call |
1308 | 1 | 15µs | 1 | 68µs | Foswiki::Func::addToHEAD( $inId, $header, $HEAD_ID_DEFAULT_STYLE ); # spent 68µs making 1 call to Foswiki::Func::addToHEAD |
1309 | } | ||||
1310 | |||||
1311 | =pod | ||||
1312 | |||||
1313 | StaticMethod addDefaultSizeUnit ($text) -> $text | ||||
1314 | |||||
1315 | Adds size unit 'px' if this is missing from the size text. | ||||
1316 | |||||
1317 | =cut | ||||
1318 | |||||
1319 | # spent 33µs (25+8) within Foswiki::Plugins::TablePlugin::Core::addDefaultSizeUnit which was called:
# once (25µs+8µs) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1036 | ||||
1320 | 1 | 2µs | my ($inSize) = @_; | ||
1321 | |||||
1322 | 1 | 2µs | my $unit = ''; | ||
1323 | 1 | 21µs | 2 | 8µs | if ( $inSize =~ m/$PATTERN_ATTRIBUTE_SIZE/ ) { # spent 5µs making 1 call to Foswiki::Plugins::TablePlugin::Core::CORE:match
# spent 2µs making 1 call to Foswiki::Plugins::TablePlugin::Core::CORE:regcomp |
1324 | 1 | 3µs | $unit = 'px' if !$2; | ||
1325 | } | ||||
1326 | 1 | 9µs | return "$inSize$unit"; | ||
1327 | } | ||||
1328 | |||||
1329 | # spent 14.8ms (2.66+12.2) within Foswiki::Plugins::TablePlugin::Core::emitTable which was called 2 times, avg 7.40ms/call:
# 2 times (2.66ms+12.2ms) by Foswiki::Plugins::TablePlugin::Core::handler at line 1898, avg 7.40ms/call | ||||
1330 | |||||
1331 | 2 | 14µs | 2 | 4.34ms | _addDefaultStyles(); # spent 4.34ms making 2 calls to Foswiki::Plugins::TablePlugin::Core::_addDefaultStyles, avg 2.17ms/call |
1332 | |||||
1333 | 2 | 11µs | 2 | 32µs | _debug('emitTable'); # spent 32µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_debug, avg 16µs/call |
1334 | |||||
1335 | #Validate headerrows/footerrows and modify if out of range | ||||
1336 | 2 | 5µs | if ( $combinedTableAttrs->{headerrows} > scalar @curTable ) { | ||
1337 | $combinedTableAttrs->{headerrows} = | ||||
1338 | scalar @curTable; # limit header to size of table! | ||||
1339 | } | ||||
1340 | 2 | 5µs | if ( $combinedTableAttrs->{headerrows} + $combinedTableAttrs->{footerrows} > | ||
1341 | @curTable ) | ||||
1342 | { | ||||
1343 | $combinedTableAttrs->{footerrows} = scalar @curTable - | ||||
1344 | $combinedTableAttrs->{headerrows}; # and footer to whatever is left | ||||
1345 | } | ||||
1346 | |||||
1347 | 2 | 7µs | my $sortThisTable = | ||
1348 | ( !defined $combinedTableAttrs->{sortAllTables} | ||||
1349 | || $combinedTableAttrs->{sortAllTables} == 0 ) | ||||
1350 | ? 0 | ||||
1351 | : $combinedTableAttrs->{sort}; | ||||
1352 | |||||
1353 | 2 | 6µs | if ( $combinedTableAttrs->{headerrows} == 0 ) { | ||
1354 | 2 | 14µs | 2 | 223µs | my ( $headerRowCount, $footerRowCount ) = _headerRowCount( \@curTable ); # spent 223µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_headerRowCount, avg 111µs/call |
1355 | |||||
1356 | # override default setting with calculated header count | ||||
1357 | 2 | 5µs | $combinedTableAttrs->{headerrows} = $headerRowCount; | ||
1358 | 2 | 4µs | $combinedTableAttrs->{footerrows} = $footerRowCount; | ||
1359 | } | ||||
1360 | |||||
1361 | 2 | 4µs | my $tableTagAttributes = {}; | ||
1362 | 2 | 6µs | $tableTagAttributes->{class} = $combinedTableAttrs->{class}; | ||
1363 | 2 | 6µs | $tableTagAttributes->{border} = $combinedTableAttrs->{border}; | ||
1364 | 2 | 6µs | $tableTagAttributes->{cellspacing} = $combinedTableAttrs->{cellspacing}; | ||
1365 | 2 | 4µs | $tableTagAttributes->{cellpadding} = $combinedTableAttrs->{cellpadding}; | ||
1366 | 2 | 4µs | $tableTagAttributes->{id} = $combinedTableAttrs->{id} | ||
1367 | || undef; | ||||
1368 | 2 | 6µs | $tableTagAttributes->{summary} = $combinedTableAttrs->{summary}; | ||
1369 | 2 | 4µs | $tableTagAttributes->{frame} = $combinedTableAttrs->{frame}; | ||
1370 | 2 | 6µs | $tableTagAttributes->{rules} = $combinedTableAttrs->{rules}; | ||
1371 | 2 | 4µs | $tableTagAttributes->{width} = $combinedTableAttrs->{width}; | ||
1372 | |||||
1373 | # remove empty attributes | ||||
1374 | 22 | 129µs | while ( my ( $key, $value ) = each %{$tableTagAttributes} ) { | ||
1375 | 18 | 29µs | delete $tableTagAttributes->{$key} if !defined $value || $value eq ''; | ||
1376 | } | ||||
1377 | |||||
1378 | 2 | 24µs | 2 | 584µs | my $text = $currTablePre . CGI::start_table($tableTagAttributes); # spent 350µs making 1 call to CGI::AUTOLOAD
# spent 234µs making 1 call to CGI::start_table |
1379 | 2 | 4µs | $text .= $currTablePre . CGI::caption( $combinedTableAttrs->{tableCaption} ) | ||
1380 | if $combinedTableAttrs->{tableCaption}; | ||||
1381 | |||||
1382 | # count the number of cols to prevent looping over non-existing columns | ||||
1383 | 2 | 3µs | my $maxCols = 0; | ||
1384 | |||||
1385 | # Flush out any remaining rowspans | ||||
1386 | 2 | 10µs | for ( my $i = 0 ; $i < @rowspan ; $i++ ) { | ||
1387 | if ( defined( $rowspan[$i] ) && $rowspan[$i] ) { | ||||
1388 | my $nRows = scalar(@curTable); | ||||
1389 | my $rspan = $rowspan[$i] + 1; | ||||
1390 | my $r = $nRows - $rspan; | ||||
1391 | $curTable[$r][$i]->{attrs} ||= {}; | ||||
1392 | if ( $rspan > 1 ) { | ||||
1393 | $curTable[$r][$i]->{attrs}->{rowspan} = $rspan; | ||||
1394 | } | ||||
1395 | } | ||||
1396 | } | ||||
1397 | |||||
1398 | 2 | 5µs | if ( | ||
1399 | ( | ||||
1400 | $sortThisTable | ||||
1401 | && defined $sortCol | ||||
1402 | && defined $requestedTable | ||||
1403 | && $requestedTable == $tableCount | ||||
1404 | ) | ||||
1405 | || defined $combinedTableAttrs->{initSort} | ||||
1406 | ) | ||||
1407 | { | ||||
1408 | |||||
1409 | # DG 08 Aug 2002: Allow multi-line headers | ||||
1410 | my @header = splice( @curTable, 0, $combinedTableAttrs->{headerrows} ); | ||||
1411 | |||||
1412 | # DG 08 Aug 2002: Skip sorting any trailers as well | ||||
1413 | my @trailer = (); | ||||
1414 | if ( $combinedTableAttrs->{footerrows} | ||||
1415 | && scalar(@curTable) > $combinedTableAttrs->{footerrows} ) | ||||
1416 | { | ||||
1417 | @trailer = splice( @curTable, -$combinedTableAttrs->{footerrows} ); | ||||
1418 | } | ||||
1419 | |||||
1420 | # Count the maximum number of columns of this table | ||||
1421 | for my $row ( 0 .. $#curTable ) { | ||||
1422 | my $thisRowMaxColCount = 0; | ||||
1423 | for my $col ( 0 .. $#{ $curTable[$row] } ) { | ||||
1424 | $thisRowMaxColCount++; | ||||
1425 | } | ||||
1426 | $maxCols = $thisRowMaxColCount | ||||
1427 | if ( $thisRowMaxColCount > $maxCols ); | ||||
1428 | } | ||||
1429 | |||||
1430 | # Handle multi-row labels by killing rowspans in sorted tables | ||||
1431 | for my $row ( 0 .. $#curTable ) { | ||||
1432 | for my $col ( 0 .. $#{ $curTable[$row] } ) { | ||||
1433 | |||||
1434 | # SMELL: why do we need to specify a rowspan of 1? | ||||
1435 | $curTable[$row][$col]->{attrs}->{rowspan} = 1; | ||||
1436 | if ( $curTable[$row][$col]->{type} eq 'Y' ) { | ||||
1437 | $curTable[$row][$col]->{text} = | ||||
1438 | $curTable[ $row - 1 ][$col]->{text}; | ||||
1439 | $curTable[$row][$col]->{type} = 'td'; | ||||
1440 | } | ||||
1441 | } | ||||
1442 | } | ||||
1443 | |||||
1444 | # url requested sort on column beyond end of table. Force to last column | ||||
1445 | $sortCol = 0 unless ( $sortCol =~ m/^[0-9]+$/ ); | ||||
1446 | $sortCol = $maxCols - 1 if ( $sortCol >= $maxCols ); | ||||
1447 | |||||
1448 | # only get the column type if within bounds | ||||
1449 | if ( $sortCol < $maxCols ) { | ||||
1450 | _setSortTypeForCells( $sortCol, \@curTable ); | ||||
1451 | } | ||||
1452 | |||||
1453 | _debug("currentSortDirection:$currentSortDirection"); | ||||
1454 | |||||
1455 | if ( $combinedTableAttrs->{sort} | ||||
1456 | && $currentSortDirection == $SORT_DIRECTION->{'ASCENDING'} ) | ||||
1457 | { | ||||
1458 | @curTable = sort { | ||||
1459 | $a->[$sortCol]->{sortText} cmp $b->[$sortCol]->{sortText} | ||||
1460 | || $a->[$sortCol]->{number} <=> $b->[$sortCol]->{number} | ||||
1461 | || $a->[$sortCol]->{dateString} | ||||
1462 | cmp $b->[$sortCol]->{dateString} | ||||
1463 | } @curTable; | ||||
1464 | } | ||||
1465 | elsif ($combinedTableAttrs->{sort} | ||||
1466 | && $currentSortDirection == $SORT_DIRECTION->{'DESCENDING'} ) | ||||
1467 | { | ||||
1468 | @curTable = sort { | ||||
1469 | $b->[$sortCol]->{sortText} cmp $a->[$sortCol]->{sortText} | ||||
1470 | || $b->[$sortCol]->{number} <=> $a->[$sortCol]->{number} | ||||
1471 | || $b->[$sortCol]->{dateString} | ||||
1472 | cmp $a->[$sortCol]->{dateString} | ||||
1473 | } @curTable; | ||||
1474 | } | ||||
1475 | |||||
1476 | # DG 08 Aug 2002: Cleanup after the header/trailer splicing | ||||
1477 | # this is probably awfully inefficient - but how big is a table? | ||||
1478 | @curTable = ( @header, @curTable, @trailer ); | ||||
1479 | } # if defined $sortCol ... | ||||
1480 | |||||
1481 | 2 | 5µs | my $rowCount = 0; | ||
1482 | 2 | 4µs | my $numberOfRows = scalar(@curTable); | ||
1483 | 2 | 3µs | my $dataColorCount = 0; | ||
1484 | |||||
1485 | 2 | 6µs | my @headerRowList = (); | ||
1486 | 2 | 3µs | my @bodyRowList = (); | ||
1487 | 2 | 3µs | my @footerRowList = (); | ||
1488 | |||||
1489 | 2 | 3µs | my $isPastHeaderRows = 0; | ||
1490 | 2 | 5µs | my $singleIndent = "\n\t"; | ||
1491 | 2 | 4µs | my $doubleIndent = "\n\t\t"; | ||
1492 | 2 | 6µs | my $tripleIndent = "\n\t\t\t"; | ||
1493 | |||||
1494 | # Only *one* row of the table has sort links, and it will either | ||||
1495 | # be the last row in the header or the first row in the footer. | ||||
1496 | 2 | 3µs | my $sortLinksWritten = 0; | ||
1497 | |||||
1498 | 2 | 8µs | foreach my $row (@curTable) { | ||
1499 | 8 | 12µs | my $rowtext = ''; | ||
1500 | 8 | 11µs | my $colCount = 0; | ||
1501 | |||||
1502 | # keep track of header cells: if all cells are header cells, do not | ||||
1503 | # update the data color count | ||||
1504 | 8 | 10µs | my $headerCellCount = 0; | ||
1505 | 8 | 12µs | my $numberOfCols = scalar(@$row); | ||
1506 | 8 | 10µs | my $writingSortLinks = 0; | ||
1507 | |||||
1508 | 8 | 25µs | foreach my $fcell (@$row) { | ||
1509 | |||||
1510 | # check if cell exists | ||||
1511 | 22 | 39µs | next if ( !$fcell || !$fcell->{type} ); | ||
1512 | |||||
1513 | 22 | 32µs | my $tableAnchor = ''; | ||
1514 | next | ||||
1515 | 22 | 34µs | if ( $fcell->{type} eq 'X' ) | ||
1516 | ; # data was there so sort could work with col spanning | ||||
1517 | 22 | 32µs | my $type = $fcell->{type}; | ||
1518 | 22 | 34µs | my $cell = $fcell->{text}; | ||
1519 | 22 | 33µs | my $attr = $fcell->{attrs} || {}; | ||
1520 | |||||
1521 | 22 | 27µs | my $newDirection; | ||
1522 | 22 | 27µs | my $isSorted = 0; | ||
1523 | |||||
1524 | 22 | 65µs | if ( | ||
1525 | $currentSortDirection != $SORT_DIRECTION->{'NONE'} | ||||
1526 | && defined $sortCol | ||||
1527 | && $colCount == $sortCol | ||||
1528 | |||||
1529 | # Removing the line below hides the marking of sorted columns | ||||
1530 | # until the user clicks on a header (KJL) | ||||
1531 | # && defined $requestedTable && $requestedTable == $tableCount | ||||
1532 | # && $sortType ne '' | ||||
1533 | ) | ||||
1534 | { | ||||
1535 | $isSorted = 1; | ||||
1536 | $newDirection = _getNewSortDirection($currentSortDirection); | ||||
1537 | } | ||||
1538 | else { | ||||
1539 | 22 | 123µs | 22 | 96µs | $newDirection = _getDefaultSortDirection(); # spent 96µs making 22 calls to Foswiki::Plugins::TablePlugin::Core::_getDefaultSortDirection, avg 4µs/call |
1540 | } | ||||
1541 | |||||
1542 | 22 | 57µs | if ( $type eq 'th' ) { | ||
1543 | 11 | 14µs | $headerCellCount++; | ||
1544 | |||||
1545 | # html attribute: bgcolor | ||||
1546 | 11 | 18µs | if ( $combinedTableAttrs->{generateInlineMarkup} | ||
1547 | && defined $combinedTableAttrs->{headerBg} ) | ||||
1548 | { | ||||
1549 | $attr->{bgcolor} = $combinedTableAttrs->{headerBg} | ||||
1550 | unless ( $combinedTableAttrs->{headerBg} =~ /none/i ); | ||||
1551 | } | ||||
1552 | |||||
1553 | # END html attribute | ||||
1554 | |||||
1555 | 11 | 14µs | if ($isSorted) { | ||
1556 | if ( $currentSortDirection == | ||||
1557 | $SORT_DIRECTION->{'ASCENDING'} ) | ||||
1558 | { | ||||
1559 | $tableAnchor = $CHAR_SORT_ASCENDING; | ||||
1560 | } | ||||
1561 | if ( $currentSortDirection == | ||||
1562 | $SORT_DIRECTION->{'DESCENDING'} ) | ||||
1563 | { | ||||
1564 | $tableAnchor = $CHAR_SORT_DESCENDING; | ||||
1565 | } | ||||
1566 | |||||
1567 | # html attribute: (sorted header cell) bgcolor | ||||
1568 | # overrides earlier set bgcolor | ||||
1569 | if ( $combinedTableAttrs->{generateInlineMarkup} | ||||
1570 | && defined $combinedTableAttrs->{headerBgSorted} ) | ||||
1571 | { | ||||
1572 | $attr->{bgcolor} = $combinedTableAttrs->{headerBgSorted} | ||||
1573 | unless ( | ||||
1574 | $combinedTableAttrs->{headerBgSorted} =~ /none/i ); | ||||
1575 | } | ||||
1576 | |||||
1577 | # END html attribute | ||||
1578 | } | ||||
1579 | |||||
1580 | 11 | 17µs | if ( | ||
1581 | defined $sortCol | ||||
1582 | && $colCount == $sortCol | ||||
1583 | && defined $requestedTable | ||||
1584 | && $requestedTable == $tableCount | ||||
1585 | && ( $combinedTableAttrs->{headerrows} | ||||
1586 | || $combinedTableAttrs->{footerrows} ) | ||||
1587 | ) | ||||
1588 | { | ||||
1589 | |||||
1590 | $tableAnchor = | ||||
1591 | CGI::a( { name => 'sorted_table' }, '<!-- -->' ) | ||||
1592 | . $tableAnchor; | ||||
1593 | } | ||||
1594 | |||||
1595 | # html attribute: headercolor (font style) | ||||
1596 | 11 | 17µs | if ( $combinedTableAttrs->{generateInlineMarkup} | ||
1597 | && defined $combinedTableAttrs->{headerColor} ) | ||||
1598 | { | ||||
1599 | my $fontStyle = | ||||
1600 | { color => $combinedTableAttrs->{headerColor} }; | ||||
1601 | $cell = CGI::font( $fontStyle, $cell ); | ||||
1602 | } | ||||
1603 | |||||
1604 | # END html attribute | ||||
1605 | |||||
1606 | 11 | 26µs | if ( | ||
1607 | $sortThisTable | ||||
1608 | && ( | ||||
1609 | ( $rowCount == $combinedTableAttrs->{headerrows} - 1 ) | ||||
1610 | || ( !$combinedTableAttrs->{headerrows} | ||||
1611 | && $rowCount == | ||||
1612 | $numberOfRows - $combinedTableAttrs->{footerrows} ) | ||||
1613 | ) | ||||
1614 | && ( $writingSortLinks || !$sortLinksWritten ) | ||||
1615 | ) | ||||
1616 | { | ||||
1617 | $writingSortLinks = 1; | ||||
1618 | my $linkAttributes = { | ||||
1619 | href => $url | ||||
1620 | . 'sortcol=' | ||||
1621 | . $colCount | ||||
1622 | . ';table=' | ||||
1623 | . $tableCount . ';up=' | ||||
1624 | . $newDirection | ||||
1625 | . '#sorted_table', | ||||
1626 | rel => 'nofollow', | ||||
1627 | title => 'Sort by this column' | ||||
1628 | }; | ||||
1629 | |||||
1630 | if ( $cell =~ /\[\[|href/o ) { | ||||
1631 | $cell .= CGI::a( $linkAttributes, $CHAR_SORT_BOTH ) | ||||
1632 | . $tableAnchor; | ||||
1633 | } | ||||
1634 | else { | ||||
1635 | $cell = CGI::a( $linkAttributes, $cell ) . $tableAnchor; | ||||
1636 | } | ||||
1637 | } | ||||
1638 | |||||
1639 | } | ||||
1640 | else { | ||||
1641 | |||||
1642 | 11 | 18µs | $type = 'td' unless $type eq 'Y'; | ||
1643 | |||||
1644 | # html attribute: bgcolor | ||||
1645 | 11 | 18µs | if ( $combinedTableAttrs->{generateInlineMarkup} ) { | ||
1646 | if ( $isSorted | ||||
1647 | && defined $combinedTableAttrs->{dataBgSortedListRef} ) | ||||
1648 | { | ||||
1649 | my @dataBg = | ||||
1650 | @{ $combinedTableAttrs->{dataBgSortedListRef} }; | ||||
1651 | |||||
1652 | unless ( $dataBg[0] =~ /none/ ) { | ||||
1653 | $attr->{bgcolor} = | ||||
1654 | $dataBg[ $dataColorCount % ( $#dataBg + 1 ) ]; | ||||
1655 | } | ||||
1656 | } | ||||
1657 | elsif ( defined $combinedTableAttrs->{dataBgListRef} ) { | ||||
1658 | my @dataBg = @{ $combinedTableAttrs->{dataBgListRef} }; | ||||
1659 | unless ( $dataBg[0] =~ /none/i ) { | ||||
1660 | $attr->{bgcolor} = | ||||
1661 | $dataBg[ $dataColorCount % ( $#dataBg + 1 ) ]; | ||||
1662 | } | ||||
1663 | } | ||||
1664 | } | ||||
1665 | |||||
1666 | # END html attribute | ||||
1667 | |||||
1668 | # html attribute: datacolor (font style) | ||||
1669 | 11 | 17µs | if ( $combinedTableAttrs->{generateInlineMarkup} | ||
1670 | && defined $combinedTableAttrs->{dataColorListRef} ) | ||||
1671 | { | ||||
1672 | my @dataColor = | ||||
1673 | @{ $combinedTableAttrs->{dataColorListRef} }; | ||||
1674 | my $color = | ||||
1675 | $dataColor[ $dataColorCount % ( $#dataColor + 1 ) ]; | ||||
1676 | unless ( $color =~ /^(none)$/i ) { | ||||
1677 | my $cellAttrs = { color => $color }; | ||||
1678 | $cell = CGI::font( $cellAttrs, ' ' . $cell . ' ' ); | ||||
1679 | } | ||||
1680 | } | ||||
1681 | |||||
1682 | # END html attribute | ||||
1683 | |||||
1684 | } ###if( $type eq 'th' ) | ||||
1685 | |||||
1686 | 22 | 24µs | if ($isSorted) { | ||
1687 | $attr->{class} = _appendSortedCssClass( $attr->{class} ); | ||||
1688 | } | ||||
1689 | |||||
1690 | 22 | 21µs | if ($writingSortLinks) { | ||
1691 | $sortLinksWritten = 1; | ||||
1692 | } | ||||
1693 | |||||
1694 | 22 | 44µs | my $isLastRow = ( $rowCount == $numberOfRows - 1 ); | ||
1695 | 22 | 31µs | if ( $attr->{rowspan} ) { | ||
1696 | $isLastRow = | ||||
1697 | ( ( $rowCount + ( $attr->{rowspan} - 1 ) ) == | ||||
1698 | $numberOfRows - 1 ); | ||||
1699 | } | ||||
1700 | |||||
1701 | # CSS class name | ||||
1702 | 22 | 70µs | 8 | 159µs | $attr->{class} = _appendFirstColumnCssClass( $attr->{class} ) # spent 159µs making 8 calls to Foswiki::Plugins::TablePlugin::Core::_appendFirstColumnCssClass, avg 20µs/call |
1703 | if $colCount == 0; | ||||
1704 | 22 | 33µs | my $isLastCol = ( $colCount == $numberOfCols - 1 ); | ||
1705 | 22 | 68µs | 8 | 229µs | $attr->{class} = _appendLastColumnCssClass( $attr->{class} ) # spent 229µs making 8 calls to Foswiki::Plugins::TablePlugin::Core::_appendLastColumnCssClass, avg 29µs/call |
1706 | if $isLastCol; | ||||
1707 | |||||
1708 | 22 | 59µs | 7 | 131µs | $attr->{class} = _appendLastRowCssClass( $attr->{class} ) # spent 131µs making 7 calls to Foswiki::Plugins::TablePlugin::Core::_appendLastRowCssClass, avg 19µs/call |
1709 | if $isLastRow; | ||||
1710 | |||||
1711 | 22 | 27µs | $colCount++; | ||
1712 | 22 | 28µs | next if ( $type eq 'Y' ); | ||
1713 | 22 | 38µs | my $fn = 'CGI::' . $type; | ||
1714 | 2 | 83µs | 2 | 123µs | # spent 74µs (25+49) within Foswiki::Plugins::TablePlugin::Core::BEGIN@1714 which was called:
# once (25µs+49µs) by Foswiki::Plugins::TablePlugin::BEGIN@1 at line 1714 # spent 74µs making 1 call to Foswiki::Plugins::TablePlugin::Core::BEGIN@1714
# spent 49µs making 1 call to strict::unimport |
1715 | 22 | 235µs | 22 | 3.26ms | $rowtext .= "$tripleIndent" . &$fn( $attr, " $cell " ); # spent 1.24ms making 10 calls to CGI::td, avg 124µs/call
# spent 1.23ms making 10 calls to CGI::th, avg 123µs/call
# spent 789µs making 2 calls to CGI::AUTOLOAD, avg 395µs/call |
1716 | 2 | 2.09ms | 2 | 86µs | # spent 52µs (17+34) within Foswiki::Plugins::TablePlugin::Core::BEGIN@1716 which was called:
# once (17µs+34µs) by Foswiki::Plugins::TablePlugin::BEGIN@1 at line 1716 # spent 52µs making 1 call to Foswiki::Plugins::TablePlugin::Core::BEGIN@1716
# spent 34µs making 1 call to strict::import |
1717 | } # foreach my $fcell ( @$row ) | ||||
1718 | |||||
1719 | # assign css class names to tr | ||||
1720 | # based on settings: dataBg, dataBgSorted | ||||
1721 | 8 | 12µs | my $trClassName = ''; | ||
1722 | |||||
1723 | # just 2 css names is too limited, but we will keep it for compatibility | ||||
1724 | # with existing style sheets | ||||
1725 | 8 | 16µs | my $rowTypeName = | ||
1726 | ( $rowCount % 2 ) ? 'foswikiTableEven' : 'foswikiTableOdd'; | ||||
1727 | 8 | 43µs | 8 | 68µs | $trClassName = _appendToClassList( $trClassName, $rowTypeName ); # spent 68µs making 8 calls to Foswiki::Plugins::TablePlugin::Core::_appendToClassList, avg 8µs/call |
1728 | |||||
1729 | 8 | 26µs | if ( $combinedTableAttrs->{dataBgSortedListRef} ) { | ||
1730 | 16 | 44µs | my @dataBgSorted = @{ $combinedTableAttrs->{dataBgSortedListRef} }; | ||
1731 | 8 | 18µs | my $modRowNum = $dataColorCount % ( $#dataBgSorted + 1 ); | ||
1732 | 8 | 46µs | 8 | 170µs | $trClassName = # spent 170µs making 8 calls to Foswiki::Plugins::TablePlugin::Core::_appendRowNumberCssClass, avg 21µs/call |
1733 | _appendRowNumberCssClass( $trClassName, 'dataBgSorted', | ||||
1734 | $modRowNum ); | ||||
1735 | } | ||||
1736 | 8 | 25µs | if ( $combinedTableAttrs->{dataBgListRef} ) { | ||
1737 | 16 | 43µs | my @dataBg = @{ $combinedTableAttrs->{dataBgListRef} }; | ||
1738 | 8 | 16µs | my $modRowNum = $dataColorCount % ( $#dataBg + 1 ); | ||
1739 | 8 | 43µs | 8 | 159µs | $trClassName = # spent 159µs making 8 calls to Foswiki::Plugins::TablePlugin::Core::_appendRowNumberCssClass, avg 20µs/call |
1740 | _appendRowNumberCssClass( $trClassName, 'dataBg', $modRowNum ); | ||||
1741 | } | ||||
1742 | 8 | 14µs | if ( $combinedTableAttrs->{dataColorListRef} ) { | ||
1743 | my @dataColor = @{ $combinedTableAttrs->{dataColorListRef} }; | ||||
1744 | my $modRowNum = $dataColorCount % ( $#dataColor + 1 ); | ||||
1745 | $trClassName = | ||||
1746 | _appendRowNumberCssClass( $trClassName, 'dataColor', $modRowNum ); | ||||
1747 | } | ||||
1748 | 8 | 10µs | $rowtext .= $doubleIndent; | ||
1749 | 8 | 68µs | 8 | 1.24ms | my $rowHTML = # spent 866µs making 7 calls to CGI::Tr, avg 124µs/call
# spent 372µs making 1 call to CGI::AUTOLOAD |
1750 | $doubleIndent . CGI::Tr( { class => $trClassName }, $rowtext ); | ||||
1751 | |||||
1752 | 8 | 17µs | my $isHeaderRow = | ||
1753 | $rowCount < | ||||
1754 | $combinedTableAttrs->{headerrows}; #( $headerCellCount == $colCount ); | ||||
1755 | 8 | 16µs | my $isFooterRow = | ||
1756 | ( ( $numberOfRows - $rowCount ) <= | ||||
1757 | $combinedTableAttrs->{footerrows} ); | ||||
1758 | |||||
1759 | 8 | 20µs | if ( !$isHeaderRow && !$isFooterRow ) { | ||
1760 | |||||
1761 | # don't include non-adjacent header rows to the top block of header rows | ||||
1762 | 7 | 10µs | $isPastHeaderRows = 1; | ||
1763 | } | ||||
1764 | |||||
1765 | 8 | 20µs | if ($isFooterRow) { | ||
1766 | push @footerRowList, $rowHTML; | ||||
1767 | } | ||||
1768 | elsif ( $isHeaderRow && !$isPastHeaderRows ) { | ||||
1769 | 1 | 2µs | push( @headerRowList, $rowHTML ); | ||
1770 | } | ||||
1771 | else { | ||||
1772 | 7 | 15µs | push @bodyRowList, $rowHTML; | ||
1773 | 7 | 9µs | $dataColorCount++; | ||
1774 | } | ||||
1775 | |||||
1776 | 8 | 11µs | if ($isHeaderRow) { | ||
1777 | |||||
1778 | # reset data color count to start with first color after | ||||
1779 | # each table heading | ||||
1780 | 1 | 2µs | $dataColorCount = 0; | ||
1781 | } | ||||
1782 | |||||
1783 | 8 | 50µs | $rowCount++; | ||
1784 | } # foreach my $row ( @curTable ) | ||||
1785 | |||||
1786 | 2 | 13µs | my $thead = | ||
1787 | "$singleIndent<thead>" | ||||
1788 | . join( "", @headerRowList ) | ||||
1789 | . "$singleIndent</thead>"; | ||||
1790 | 2 | 5µs | $text .= $currTablePre . $thead if scalar @headerRowList; | ||
1791 | |||||
1792 | 2 | 6µs | my $tfoot = | ||
1793 | "$singleIndent<tfoot>" | ||||
1794 | . join( "", @footerRowList ) | ||||
1795 | . "$singleIndent</tfoot>"; | ||||
1796 | 2 | 3µs | $text .= $currTablePre . $tfoot if scalar @footerRowList; | ||
1797 | |||||
1798 | 2 | 3µs | my $tbody; | ||
1799 | 2 | 6µs | if ( scalar @bodyRowList ) { | ||
1800 | 2 | 14µs | $tbody = | ||
1801 | "$singleIndent<tbody>" | ||||
1802 | . join( "", @bodyRowList ) | ||||
1803 | . "$singleIndent</tbody>"; | ||||
1804 | } | ||||
1805 | else { | ||||
1806 | |||||
1807 | # A HTML table requires a body, which cannot be empty (Item8991). | ||||
1808 | # So we provide one, but prevent it from being displayed. | ||||
1809 | $tbody = | ||||
1810 | "$singleIndent<tbody>$doubleIndent<tr style=\"display:none;\">$tripleIndent<td></td>$doubleIndent</tr>$singleIndent</tbody>\n"; | ||||
1811 | } | ||||
1812 | 2 | 16µs | $text .= $currTablePre . $tbody; | ||
1813 | |||||
1814 | 2 | 20µs | 2 | 310µs | $text .= $currTablePre . CGI::end_table() . "\n"; # spent 275µs making 1 call to CGI::AUTOLOAD
# spent 35µs making 1 call to CGI::end_table |
1815 | |||||
1816 | # prepare for next table | ||||
1817 | 2 | 14µs | 2 | 304µs | _resetReusedVariables(); # spent 304µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_resetReusedVariables, avg 152µs/call |
1818 | |||||
1819 | 2 | 21µs | return $text; | ||
1820 | } | ||||
1821 | |||||
1822 | # spent 26.7ms (3.86+22.8) within Foswiki::Plugins::TablePlugin::Core::handler which was called 5 times, avg 5.33ms/call:
# 5 times (3.86ms+22.8ms) by Foswiki::Plugins::TablePlugin::preRenderingHandler at line 67 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TablePlugin.pm, avg 5.33ms/call | ||||
1823 | ### my ( $text, $removed ) = @_; | ||||
1824 | |||||
1825 | 5 | 42µs | 5 | 133µs | _debug('handler'); # spent 133µs making 5 calls to Foswiki::Plugins::TablePlugin::Core::_debug, avg 27µs/call |
1826 | |||||
1827 | 5 | 9µs | unless ($Foswiki::Plugins::TablePlugin::initialised) { | ||
1828 | 1 | 2µs | $insideTABLE = 0; | ||
1829 | |||||
1830 | # Even if $tableCount is initialized already at plugin init | ||||
1831 | # we need to reset it again each time preRenderingHandler | ||||
1832 | # calls this handler sub. Important for initialiseWhenRender API | ||||
1833 | 1 | 1µs | $tableCount = 0; | ||
1834 | |||||
1835 | 1 | 8µs | 1 | 32µs | my $cgi = Foswiki::Func::getCgiQuery(); # spent 32µs making 1 call to Foswiki::Func::getCgiQuery |
1836 | 1 | 1µs | return unless $cgi; | ||
1837 | |||||
1838 | # Copy existing values | ||||
1839 | 1 | 2µs | my ( @origSort, @origTable, @origUp ); | ||
1840 | 1 | 8µs | 1 | 59µs | @origSort = $cgi->param('sortcol'); # spent 59µs making 1 call to Foswiki::Request::param |
1841 | 1 | 6µs | 1 | 44µs | @origTable = $cgi->param('table'); # spent 44µs making 1 call to Foswiki::Request::param |
1842 | 1 | 5µs | 1 | 41µs | @origUp = $cgi->param('up'); # NOTE: internal parameter # spent 41µs making 1 call to Foswiki::Request::param |
1843 | 1 | 12µs | 1 | 26µs | $cgi->delete( 'sortcol', 'table', 'up' ); # spent 26µs making 1 call to Foswiki::Request::delete |
1844 | 1 | 13µs | 1 | 322µs | $url = $cgi->url( -absolute => 1, -path => 1 ) . '?'; # spent 322µs making 1 call to Foswiki::Request::url |
1845 | 1 | 6µs | 1 | 51µs | my $queryString = $cgi->query_string(); # spent 51µs making 1 call to Foswiki::Request::queryString |
1846 | 1 | 1µs | $url .= $queryString . ';' if $queryString; | ||
1847 | |||||
1848 | # Restore parameters, so we don't interfere on the remaining execution | ||||
1849 | 1 | 1µs | $cgi->param( -name => 'sortcol', -value => \@origSort ) if @origSort; | ||
1850 | 1 | 1µs | $cgi->param( -name => 'table', -value => \@origTable ) if @origTable; | ||
1851 | 1 | 800ns | $cgi->param( -name => 'up', -value => \@origUp ) if @origUp; | ||
1852 | |||||
1853 | 1 | 5µs | 1 | 45µs | $sortColFromUrl = # spent 45µs making 1 call to Foswiki::Request::param |
1854 | $cgi->param('sortcol'); # zero based: 0 is first column | ||||
1855 | 1 | 1µs | if ( defined $sortColFromUrl && $sortColFromUrl !~ m/^[0-9]+$/ ) { | ||
1856 | $sortColFromUrl = 0; | ||||
1857 | } | ||||
1858 | |||||
1859 | 1 | 6µs | 1 | 44µs | $requestedTable = $cgi->param('table'); # spent 44µs making 1 call to Foswiki::Request::param |
1860 | 1 | 2µs | $requestedTable = 0 | ||
1861 | unless ( defined $requestedTable && $requestedTable =~ m/^[0-9]+$/ ); | ||||
1862 | |||||
1863 | 1 | 6µs | 1 | 44µs | $up = $cgi->param('up'); # spent 44µs making 1 call to Foswiki::Request::param |
1864 | |||||
1865 | 1 | 1µs | $sortTablesInText = 0; | ||
1866 | 1 | 1µs | $sortAttachments = 0; | ||
1867 | 1 | 7µs | 1 | 139µs | my $tmp = Foswiki::Func::getPreferencesValue('TABLEPLUGIN_SORT') # spent 139µs making 1 call to Foswiki::Func::getPreferencesValue |
1868 | || 'all'; | ||||
1869 | 1 | 16µs | 1 | 4µs | if ( !$tmp || $tmp =~ /^all$/oi ) { # spent 4µs making 1 call to Foswiki::Plugins::TablePlugin::Core::CORE:match |
1870 | 1 | 2µs | $sortTablesInText = 1; | ||
1871 | 1 | 2µs | $sortAttachments = 1; | ||
1872 | } | ||||
1873 | elsif ( $tmp =~ /^attachments$/oi ) { | ||||
1874 | $sortAttachments = 1; | ||||
1875 | } | ||||
1876 | |||||
1877 | 1 | 7µs | 1 | 1.04ms | _initDefaults(); # first time # spent 1.04ms making 1 call to Foswiki::Plugins::TablePlugin::Core::_initDefaults |
1878 | 1 | 3µs | $Foswiki::Plugins::TablePlugin::initialised = 1; | ||
1879 | } | ||||
1880 | |||||
1881 | 5 | 13µs | $insideTABLE = 0; | ||
1882 | |||||
1883 | 5 | 17µs | my $defaultSort = $combinedTableAttrs->{sortAllTables}; | ||
1884 | |||||
1885 | 5 | 8µs | my $acceptable = $combinedTableAttrs->{sortAllTables}; | ||
1886 | 5 | 531µs | my @lines = split( /\r?\n/, $_[0] ); | ||
1887 | 5 | 21µs | for (@lines) { | ||
1888 | 189 | 3.81ms | 584 | 1.18ms | if ( # spent 734µs making 377 calls to Foswiki::Plugins::TablePlugin::Core::CORE:subst, avg 2µs/call
# spent 410µs making 189 calls to Foswiki::Plugins::TablePlugin::Core::CORE:regcomp, avg 2µs/call
# spent 41µs making 18 calls to Foswiki::Plugins::TablePlugin::Core::CORE:substcont, avg 2µs/call |
1889 | 1 | 11µs | 2 | 1.35ms | s/$PATTERN_TABLE/_parseTableSpecificTableAttributes(Foswiki::Func::extractParameters($1))/se # spent 1.19ms making 1 call to Foswiki::Plugins::TablePlugin::Core::_parseTableSpecificTableAttributes
# spent 162µs making 1 call to Foswiki::Func::extractParameters |
1890 | ) | ||||
1891 | 8 | 46µs | 8 | 3.43ms | { # spent 3.43ms making 8 calls to Foswiki::Plugins::TablePlugin::Core::_processTableRow, avg 429µs/call |
1892 | 1 | 2µs | $acceptable = 1; | ||
1893 | } | ||||
1894 | elsif (s/^(\s*)\|(.*\|\s*)$/_processTableRow($1,$2)/eo) { | ||||
1895 | 8 | 12µs | $insideTABLE = 1; | ||
1896 | } | ||||
1897 | elsif ($insideTABLE) { | ||||
1898 | 2 | 30µs | 2 | 14.8ms | $_ = emitTable() . $_; # spent 14.8ms making 2 calls to Foswiki::Plugins::TablePlugin::Core::emitTable, avg 7.40ms/call |
1899 | 2 | 3µs | $insideTABLE = 0; | ||
1900 | |||||
1901 | 2 | 4µs | $combinedTableAttrs->{sortAllTables} = $defaultSort; | ||
1902 | 2 | 3µs | $acceptable = $defaultSort; | ||
1903 | } | ||||
1904 | } | ||||
1905 | 5 | 228µs | $_[0] = join( "\n", @lines ); | ||
1906 | |||||
1907 | 5 | 78µs | if ($insideTABLE) { | ||
1908 | $_[0] .= emitTable(); | ||||
1909 | } | ||||
1910 | } | ||||
1911 | |||||
1912 | =pod | ||||
1913 | |||||
1914 | _mergeHashes (\%a, \%b ) -> \%merged | ||||
1915 | |||||
1916 | Merges 2 hash references. | ||||
1917 | |||||
1918 | =cut | ||||
1919 | |||||
1920 | # spent 385µs within Foswiki::Plugins::TablePlugin::Core::_mergeHashes which was called 4 times, avg 96µs/call:
# 2 times (199µs+0s) by Foswiki::Plugins::TablePlugin::Core::_resetReusedVariables at line 162, avg 100µs/call
# once (100µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseTableSpecificTableAttributes at line 212
# once (86µs+0s) by Foswiki::Plugins::TablePlugin::Core::_initDefaults at line 146 | ||||
1921 | 4 | 8µs | my ( $A, $B ) = @_; | ||
1922 | |||||
1923 | 4 | 8µs | my %merged = (); | ||
1924 | 4 | 65µs | while ( my ( $k, $v ) = each(%$A) ) { | ||
1925 | 14 | 24µs | $merged{$k} = $v; | ||
1926 | } | ||||
1927 | 4 | 177µs | while ( my ( $k, $v ) = each(%$B) ) { | ||
1928 | 45 | 80µs | $merged{$k} = $v; | ||
1929 | } | ||||
1930 | 4 | 34µs | return \%merged; | ||
1931 | } | ||||
1932 | |||||
1933 | =pod | ||||
1934 | |||||
1935 | =cut | ||||
1936 | |||||
1937 | sub _cleanParamValue { | ||||
1938 | 2 | 3µs | my ($inValue) = @_; | ||
1939 | |||||
1940 | 2 | 3µs | return undef if !$inValue; | ||
1941 | |||||
1942 | 2 | 18µs | 2 | 3µs | $inValue =~ s/ //go; # remove spaces # spent 3µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::CORE:subst, avg 2µs/call |
1943 | 2 | 14µs | return $inValue; | ||
1944 | } | ||||
1945 | |||||
1946 | =pod | ||||
1947 | |||||
1948 | =cut | ||||
1949 | |||||
1950 | # spent 95µs (91+4) within Foswiki::Plugins::TablePlugin::Core::_arrayRefFromParam which was called 12 times, avg 8µs/call:
# 2 times (23µs+2µs) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 363, avg 13µs/call
# 2 times (21µs+2µs) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 365, avg 11µs/call
# 2 times (12µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 348, avg 6µs/call
# 2 times (12µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 370, avg 6µs/call
# 2 times (12µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 354, avg 6µs/call
# 2 times (11µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 351, avg 6µs/call | ||||
1951 | 12 | 24µs | my ($inValue) = @_; | ||
1952 | |||||
1953 | 12 | 65µs | return undef if !$inValue; | ||
1954 | |||||
1955 | 2 | 15µs | 2 | 4µs | $inValue =~ s/ //go; # remove spaces # spent 4µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::CORE:subst, avg 2µs/call |
1956 | 2 | 7µs | my @list = split( /,/, $inValue ); | ||
1957 | 2 | 14µs | return \@list; | ||
1958 | } | ||||
1959 | |||||
1960 | =pod | ||||
1961 | |||||
1962 | Shorthand debugging call. | ||||
1963 | |||||
1964 | =cut | ||||
1965 | |||||
1966 | # spent 275µs (175+100) within Foswiki::Plugins::TablePlugin::Core::_debug which was called 14 times, avg 20µs/call:
# 5 times (93µs+40µs) by Foswiki::Plugins::TablePlugin::Core::handler at line 1825, avg 27µs/call
# 2 times (18µs+14µs) by Foswiki::Plugins::TablePlugin::Core::emitTable at line 1333, avg 16µs/call
# 2 times (18µs+13µs) by Foswiki::Plugins::TablePlugin::Core::_resetReusedVariables at line 160, avg 16µs/call
# 2 times (18µs+14µs) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 970, avg 16µs/call
# once (9µs+7µs) by Foswiki::Plugins::TablePlugin::Core::_initDefaults at line 134
# once (9µs+6µs) by Foswiki::Plugins::TablePlugin::Core::_parseDefaultAttributes at line 190
# once (9µs+6µs) by Foswiki::Plugins::TablePlugin::Core::_parseTableSpecificTableAttributes at line 202 | ||||
1967 | 14 | 146µs | 14 | 100µs | return Foswiki::Plugins::TablePlugin::debug( 'TablePlugin::Core', @_ ); # spent 100µs making 14 calls to Foswiki::Plugins::TablePlugin::debug, avg 7µs/call |
1968 | } | ||||
1969 | |||||
1970 | # spent 99µs (58+41) within Foswiki::Plugins::TablePlugin::Core::_debugData which was called 6 times, avg 17µs/call:
# 2 times (22µs+17µs) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 231, avg 19µs/call
# 2 times (18µs+12µs) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 380, avg 15µs/call
# once (9µs+6µs) by Foswiki::Plugins::TablePlugin::Core::_parseTableSpecificTableAttributes at line 213
# once (9µs+6µs) by Foswiki::Plugins::TablePlugin::Core::_parseTableSpecificTableAttributes at line 217 | ||||
1971 | 6 | 54µs | 6 | 41µs | return Foswiki::Plugins::TablePlugin::debugData( 'TablePlugin::Core', @_ ); # spent 41µs making 6 calls to Foswiki::Plugins::TablePlugin::debugData, avg 7µs/call |
1972 | } | ||||
1973 | |||||
1974 | 1 | 51µs | 1; | ||
1975 | __END__ | ||||
# spent 287µs within Foswiki::Plugins::TablePlugin::Core::CORE:match which was called 83 times, avg 3µs/call:
# 22 times (110µs+0s) by Foswiki::Plugins::TablePlugin::Core::_processTableRow at line 577, avg 5µs/call
# 22 times (67µs+0s) by Foswiki::Plugins::TablePlugin::Core::_processTableRow at line 653, avg 3µs/call
# 22 times (42µs+0s) by Foswiki::Plugins::TablePlugin::Core::_processTableRow at line 609, avg 2µs/call
# 11 times (52µs+0s) by Foswiki::Plugins::TablePlugin::Core::_processTableRow at line 685, avg 5µs/call
# once (5µs+0s) by Foswiki::Plugins::TablePlugin::Core::addDefaultSizeUnit at line 1323
# once (4µs+0s) by Foswiki::Plugins::TablePlugin::Core::handler at line 1869
# once (2µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1106
# once (2µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1116
# once (2µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1142
# once (2µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1157 | |||||
sub Foswiki::Plugins::TablePlugin::Core::CORE:qr; # opcode | |||||
# spent 478µs within Foswiki::Plugins::TablePlugin::Core::CORE:regcomp which was called 212 times, avg 2µs/call:
# 189 times (410µs+0s) by Foswiki::Plugins::TablePlugin::Core::handler at line 1888, avg 2µs/call
# 22 times (66µs+0s) by Foswiki::Plugins::TablePlugin::Core::_processTableRow at line 571, avg 3µs/call
# once (2µs+0s) by Foswiki::Plugins::TablePlugin::Core::addDefaultSizeUnit at line 1323 | |||||
# spent 25µs within Foswiki::Plugins::TablePlugin::Core::CORE:sort which was called 4 times, avg 6µs/call:
# 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1244, avg 7µs/call
# once (8µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1245
# once (4µs+0s) by Foswiki::Plugins::TablePlugin::Core::_writeStyleToHead at line 1297 | |||||
# spent 4.05ms within Foswiki::Plugins::TablePlugin::Core::CORE:subst which was called 462 times, avg 9µs/call:
# 377 times (734µs+0s) by Foswiki::Plugins::TablePlugin::Core::handler at line 1888, avg 2µs/call
# 22 times (61µs+0s) by Foswiki::Plugins::TablePlugin::Core::_processTableRow at line 575, avg 3µs/call
# 22 times (35µs+0s) by Foswiki::Plugins::TablePlugin::Core::_processTableRow at line 571, avg 2µs/call
# 12 times (25µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1248, avg 2µs/call
# 8 times (80µs+0s) by Foswiki::Plugins::TablePlugin::Core::_processTableRow at line 558, avg 10µs/call
# 8 times (15µs+0s) by Foswiki::Plugins::TablePlugin::Core::_processTableRow at line 557, avg 2µs/call
# 8 times (13µs+0s) by Foswiki::Plugins::TablePlugin::Core::_processTableRow at line 560, avg 2µs/call
# 2 times (4µs+0s) by Foswiki::Plugins::TablePlugin::Core::_arrayRefFromParam at line 1955, avg 2µs/call
# 2 times (3µs+0s) by Foswiki::Plugins::TablePlugin::Core::_cleanParamValue at line 1942, avg 2µs/call
# once (3.08ms+0s) by Foswiki::Plugins::TablePlugin::Core::_writeStyleToHead at line 1307 | |||||
# spent 47µs within Foswiki::Plugins::TablePlugin::Core::CORE:substcont which was called 20 times, avg 2µs/call:
# 18 times (41µs+0s) by Foswiki::Plugins::TablePlugin::Core::handler at line 1888, avg 2µs/call
# 2 times (7µs+0s) by Foswiki::Plugins::TablePlugin::Core::_writeStyleToHead at line 1307, avg 3µs/call |