← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/local/src/github.com/foswiki/core/bin/view
  Run on Sun Dec 4 17:17:59 2011
Reported on Sun Dec 4 17:26:58 2011

Filename/usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TablePlugin/Core.pm
StatementsExecuted 3456 statements in 33.3ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
4621014.05ms4.05msFoswiki::Plugins::TablePlugin::Core::::CORE:substFoswiki::Plugins::TablePlugin::Core::CORE:subst (opcode)
5113.86ms26.7msFoswiki::Plugins::TablePlugin::Core::::handlerFoswiki::Plugins::TablePlugin::Core::handler
2112.66ms14.8msFoswiki::Plugins::TablePlugin::Core::::emitTableFoswiki::Plugins::TablePlugin::Core::emitTable
8112.39ms3.43msFoswiki::Plugins::TablePlugin::Core::::_processTableRowFoswiki::Plugins::TablePlugin::Core::_processTableRow
221816µs1.69msFoswiki::Plugins::TablePlugin::Core::::_parseAttributesFoswiki::Plugins::TablePlugin::Core::_parseAttributes
221720µs1.16msFoswiki::Plugins::TablePlugin::Core::::_createCssStylesFoswiki::Plugins::TablePlugin::Core::_createCssStyles
6961569µs569µsFoswiki::Plugins::TablePlugin::Core::::_appendToClassListFoswiki::Plugins::TablePlugin::Core::_appendToClassList
21231478µs478µsFoswiki::Plugins::TablePlugin::Core::::CORE:regcompFoswiki::Plugins::TablePlugin::Core::CORE:regcomp (opcode)
48271437µs437µsFoswiki::Plugins::TablePlugin::Core::::_storeAttributeFoswiki::Plugins::TablePlugin::Core::_storeAttribute
431385µs385µsFoswiki::Plugins::TablePlugin::Core::::_mergeHashesFoswiki::Plugins::TablePlugin::Core::_mergeHashes
17151323µs323µsFoswiki::Plugins::TablePlugin::Core::::__ANON__[:985]Foswiki::Plugins::TablePlugin::Core::__ANON__[:985]
2211305µs499µsFoswiki::Plugins::TablePlugin::Core::::_appendColNumberCssClassFoswiki::Plugins::TablePlugin::Core::_appendColNumberCssClass
83101287µs287µsFoswiki::Plugins::TablePlugin::Core::::CORE:matchFoswiki::Plugins::TablePlugin::Core::CORE:match (opcode)
211223µs223µsFoswiki::Plugins::TablePlugin::Core::::_headerRowCountFoswiki::Plugins::TablePlugin::Core::_headerRowCount
1621206µs329µsFoswiki::Plugins::TablePlugin::Core::::_appendRowNumberCssClassFoswiki::Plugins::TablePlugin::Core::_appendRowNumberCssClass
1471175µs275µsFoswiki::Plugins::TablePlugin::Core::::_debugFoswiki::Plugins::TablePlugin::Core::_debug
811165µs229µsFoswiki::Plugins::TablePlugin::Core::::_appendLastColumnCssClassFoswiki::Plugins::TablePlugin::Core::_appendLastColumnCssClass
111104µs1.19msFoswiki::Plugins::TablePlugin::Core::::_parseTableSpecificTableAttributesFoswiki::Plugins::TablePlugin::Core::_parseTableSpecificTableAttributes
221196µs96µsFoswiki::Plugins::TablePlugin::Core::::_getDefaultSortDirectionFoswiki::Plugins::TablePlugin::Core::_getDefaultSortDirection
81193µs159µsFoswiki::Plugins::TablePlugin::Core::::_appendFirstColumnCssClassFoswiki::Plugins::TablePlugin::Core::_appendFirstColumnCssClass
126191µs95µsFoswiki::Plugins::TablePlugin::Core::::_arrayRefFromParamFoswiki::Plugins::TablePlugin::Core::_arrayRefFromParam
71177µs131µsFoswiki::Plugins::TablePlugin::Core::::_appendLastRowCssClassFoswiki::Plugins::TablePlugin::Core::_appendLastRowCssClass
21173µs304µsFoswiki::Plugins::TablePlugin::Core::::_resetReusedVariablesFoswiki::Plugins::TablePlugin::Core::_resetReusedVariables
11168µs3.23msFoswiki::Plugins::TablePlugin::Core::::_writeStyleToHeadFoswiki::Plugins::TablePlugin::Core::_writeStyleToHead
64158µs99µsFoswiki::Plugins::TablePlugin::Core::::_debugDataFoswiki::Plugins::TablePlugin::Core::_debugData
202147µs47µsFoswiki::Plugins::TablePlugin::Core::::CORE:substcontFoswiki::Plugins::TablePlugin::Core::CORE:substcont (opcode)
11140µs1.04msFoswiki::Plugins::TablePlugin::Core::::_initDefaultsFoswiki::Plugins::TablePlugin::Core::_initDefaults
11137µs47µsFoswiki::Plugins::TablePlugin::::BEGIN@3 Foswiki::Plugins::TablePlugin::BEGIN@3
21134µs4.34msFoswiki::Plugins::TablePlugin::Core::::_addDefaultStylesFoswiki::Plugins::TablePlugin::Core::_addDefaultStyles
11129µs3.26msFoswiki::Plugins::TablePlugin::Core::::_addHeadStylesFoswiki::Plugins::TablePlugin::Core::_addHeadStyles
11129µs902µsFoswiki::Plugins::TablePlugin::Core::::_parseDefaultAttributesFoswiki::Plugins::TablePlugin::Core::_parseDefaultAttributes
22129µs32µsFoswiki::Plugins::TablePlugin::Core::::_cleanParamValueFoswiki::Plugins::TablePlugin::Core::_cleanParamValue
11128µs28µsFoswiki::Plugins::TablePlugin::Core::::BEGIN@10Foswiki::Plugins::TablePlugin::Core::BEGIN@10
11126µs574µsFoswiki::Plugins::TablePlugin::Core::::BEGIN@11Foswiki::Plugins::TablePlugin::Core::BEGIN@11
11125µs33µsFoswiki::Plugins::TablePlugin::Core::::addDefaultSizeUnitFoswiki::Plugins::TablePlugin::Core::addDefaultSizeUnit
43125µs25µsFoswiki::Plugins::TablePlugin::Core::::CORE:sortFoswiki::Plugins::TablePlugin::Core::CORE:sort (opcode)
11125µs74µsFoswiki::Plugins::TablePlugin::Core::::BEGIN@1714Foswiki::Plugins::TablePlugin::Core::BEGIN@1714
11120µs42µsFoswiki::Plugins::TablePlugin::::BEGIN@4 Foswiki::Plugins::TablePlugin::BEGIN@4
11118µs18µsFoswiki::Plugins::TablePlugin::Core::::BEGIN@121Foswiki::Plugins::TablePlugin::Core::BEGIN@121
11117µs52µsFoswiki::Plugins::TablePlugin::Core::::BEGIN@1716Foswiki::Plugins::TablePlugin::Core::BEGIN@1716
11116µs16µsFoswiki::Plugins::TablePlugin::Core::::BEGIN@8Foswiki::Plugins::TablePlugin::Core::BEGIN@8
11110µs10µsFoswiki::Plugins::TablePlugin::Core::::BEGIN@9Foswiki::Plugins::TablePlugin::Core::BEGIN@9
22110µs10µsFoswiki::Plugins::TablePlugin::Core::::CORE:qrFoswiki::Plugins::TablePlugin::Core::CORE:qr (opcode)
0000s0sFoswiki::Plugins::TablePlugin::Core::::__ANON__[:454]Foswiki::Plugins::TablePlugin::Core::__ANON__[:454]
0000s0sFoswiki::Plugins::TablePlugin::Core::::__ANON__[:459]Foswiki::Plugins::TablePlugin::Core::__ANON__[:459]
0000s0sFoswiki::Plugins::TablePlugin::Core::::_appendSortedAscendingCssClassFoswiki::Plugins::TablePlugin::Core::_appendSortedAscendingCssClass
0000s0sFoswiki::Plugins::TablePlugin::Core::::_appendSortedCssClassFoswiki::Plugins::TablePlugin::Core::_appendSortedCssClass
0000s0sFoswiki::Plugins::TablePlugin::Core::::_appendSortedDescendingCssClassFoswiki::Plugins::TablePlugin::Core::_appendSortedDescendingCssClass
0000s0sFoswiki::Plugins::TablePlugin::Core::::_convertStringToDateFoswiki::Plugins::TablePlugin::Core::_convertStringToDate
0000s0sFoswiki::Plugins::TablePlugin::Core::::_convertStringToNumberFoswiki::Plugins::TablePlugin::Core::_convertStringToNumber
0000s0sFoswiki::Plugins::TablePlugin::Core::::_getCurrentSortDirectionFoswiki::Plugins::TablePlugin::Core::_getCurrentSortDirection
0000s0sFoswiki::Plugins::TablePlugin::Core::::_getImageTextForSortingFoswiki::Plugins::TablePlugin::Core::_getImageTextForSorting
0000s0sFoswiki::Plugins::TablePlugin::Core::::_getIncludeParamsFoswiki::Plugins::TablePlugin::Core::_getIncludeParams
0000s0sFoswiki::Plugins::TablePlugin::Core::::_getInlineMarkupStyleFoswiki::Plugins::TablePlugin::Core::_getInlineMarkupStyle
0000s0sFoswiki::Plugins::TablePlugin::Core::::_getNewSortDirectionFoswiki::Plugins::TablePlugin::Core::_getNewSortDirection
0000s0sFoswiki::Plugins::TablePlugin::Core::::_setSortTypeForCellsFoswiki::Plugins::TablePlugin::Core::_setSortTypeForCells
0000s0sFoswiki::Plugins::TablePlugin::Core::::_stripHtmlFoswiki::Plugins::TablePlugin::Core::_stripHtml
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# See bottom of file for license and copyright information
2
3259µs256µ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
use strict;
# spent 47µs making 1 call to Foswiki::Plugins::TablePlugin::BEGIN@3 # spent 9µs making 1 call to strict::import
4262µs264µ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
use warnings;
# spent 42µs making 1 call to Foswiki::Plugins::TablePlugin::BEGIN@4 # spent 22µs making 1 call to warnings::import
5
6package Foswiki::Plugins::TablePlugin::Core;
7
8250µs116µ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
use Foswiki::Func;
# spent 16µs making 1 call to Foswiki::Plugins::TablePlugin::Core::BEGIN@8
9242µs110µ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
use Foswiki::Plugins::TablePlugin ();
# spent 10µs making 1 call to Foswiki::Plugins::TablePlugin::Core::BEGIN@9
10264µs128µ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
use Foswiki::Time;
# spent 28µs making 1 call to Foswiki::Plugins::TablePlugin::Core::BEGIN@10
112721µs21.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
use Error qw(:try);
# spent 574µs making 1 call to Foswiki::Plugins::TablePlugin::Core::BEGIN@11 # spent 548µs making 1 call to Error::import
12
1311µsmy @curTable;
1411µsmy $translationToken;
151900nsmy $insideTABLE;
161700nsmy $currTablePre;
1711µsmy $didWriteDefaultStyle;
181800nsmy $defaultAttrs; # to write generic table CSS
191800nsmy $tableSpecificAttrs; # to write table specific table CSS
201900nsmy $combinedTableAttrs; # default and specific table attributes
2112µsmy $styles = {}; # hash of default and specific styles
22
23# not yet refactored:
2411µsmy $tableCount;
251800nsmy $sortCol;
261800nsmy $MAX_SORT_COLS;
271700nsmy $requestedTable;
281800nsmy $up;
291800nsmy $sortTablesInText;
301800nsmy $sortAttachments;
311900nsmy $sortColFromUrl;
321900nsmy $url;
331800nsmy $currentSortDirection;
3411µsmy @rowspan;
35
3612µsmy $HEAD_ID_DEFAULT_STYLE =
37 'TABLEPLUGIN_default'; # this name is part of the API, do not change
3811µsmy $HEAD_ID_SPECIFIC_STYLE =
39 'TABLEPLUGIN_specific'; # this name is part of the API, do not change
40
41121µs16µsmy $PATTERN_TABLE = qr/%TABLE(?:{(.*?)})?%/;
# spent 6µs making 1 call to Foswiki::Plugins::TablePlugin::Core::CORE:qr
42110µs18µsmy $URL_ICON =
# spent 8µs making 1 call to Foswiki::Func::getPubUrlPath
43 Foswiki::Func::getPubUrlPath() . '/'
44 . $Foswiki::cfg{SystemWebName}
45 . '/DocumentGraphics/';
46124µs1525µsmy $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
57111µs1352µsmy $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
68110µs1350µsmy $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);
7819µs1134µsmy $CHAR_SORT_ASCENDING = CGI::span( { class => 'tableSortIcon tableSortUp' },
# spent 134µs making 1 call to CGI::span
79 $GIF_TABLE_SORT_ASCENDING );
8017µs1122µsmy $CHAR_SORT_DESCENDING =
# spent 122µs making 1 call to CGI::span
81 CGI::span( { class => 'tableSortIcon tableSortDown' },
82 $GIF_TABLE_SORT_DESCENDING );
8317µs1122µsmy $CHAR_SORT_BOTH =
# spent 122µs making 1 call to CGI::span
84 CGI::span( { class => 'tableSortIcon tableSortUp' }, $GIF_TABLE_SORT_BOTH );
85
8613µsmy $SORT_DIRECTION = {
87 'ASCENDING' => 0,
88 'DESCENDING' => 1,
89 'NONE' => 2,
90};
91
92110µs14µsmy $PATTERN_ATTRIBUTE_SIZE = qr'([0-9]+)(px|%)*'o;
# spent 4µs making 1 call to Foswiki::Plugins::TablePlugin::Core::CORE:qr
93
9411µsmy $TABLE_RULES = {};
9515µs$TABLE_RULES->{all}->{TD} = $TABLE_RULES->{all}->{TH} =
96 $TABLE_RULES->{data_all}->{TD} = $TABLE_RULES->{header_all}->{TH} =
97 'border-style:solid';
9814µs$TABLE_RULES->{none}->{TD} = $TABLE_RULES->{none}->{TH} =
99 $TABLE_RULES->{data_none}->{TD} = $TABLE_RULES->{header_none}->{TH} =
100 'border-style:none';
10115µ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';
10414µ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';
10712µs$TABLE_RULES->{groups}->{TD} = 'border-style:none';
10812µs$TABLE_RULES->{groups}->{TH} = 'border-style:solid none';
109
11012µsmy $TABLE_FRAME = {};
11112µs$TABLE_FRAME->{void} = 'border-style:none';
11212µs$TABLE_FRAME->{above} = 'border-style:solid none none none';
11312µs$TABLE_FRAME->{below} = 'border-style:none none solid none';
11412µs$TABLE_FRAME->{lhs} = 'border-style:none none none solid';
11512µs$TABLE_FRAME->{rhs} = 'border-style:none solid none none';
11612µs$TABLE_FRAME->{hsides} = 'border-style:solid none solid none';
11712µs$TABLE_FRAME->{vsides} = 'border-style:none solid none solid';
11812µs$TABLE_FRAME->{box} = 'border-style:solid';
11912µ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
BEGIN {
122719µs $translationToken = "\0";
123
124 # the maximum number of columns we will handle
125 $MAX_SORT_COLS = 10000;
126 $didWriteDefaultStyle = 0;
127 $tableCount = 0;
128 $currTablePre = '';
129 $combinedTableAttrs = {};
130 $tableSpecificAttrs = {};
131111.1ms118µ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
sub _initDefaults {
134433µs116µs _debug('_initDefaults');
# spent 16µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_debug
135 $defaultAttrs = {
136 headerrows => 0,
137 footerrows => 0,
138 sort => 1,
139 class => 'foswikiTable',
140 sortAllTables => $sortTablesInText,
141 };
142
1431902µs _parseDefaultAttributes(
144 %{Foswiki::Plugins::TablePlugin::pluginAttributes} );
145
146186µs $combinedTableAttrs = _mergeHashes( {}, $defaultAttrs );
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
sub _addDefaultStyles {
150
151532µs return if $Foswiki::Plugins::TablePlugin::writtenToHead;
152 $Foswiki::Plugins::TablePlugin::writtenToHead = 1;
153
154 # create CSS styles tables in general
15511.05ms my ( $id, @styles ) = _createCssStyles( 1, $defaultAttrs );
15613.26ms _addHeadStyles( $HEAD_ID_DEFAULT_STYLE, @styles ) if scalar @styles;
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
sub _resetReusedVariables {
1601069µs232µs _debug('_resetReusedVariables');
# spent 32µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_debug, avg 16µs/call
161 $currTablePre = '';
1622199µs $combinedTableAttrs = _mergeHashes( {}, $defaultAttrs );
# spent 199µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_mergeHashes, avg 100µs/call
163 $tableSpecificAttrs = {};
164 $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
sub _storeAttribute {
172168554µs my ( $inAttrName, $inValue, $inCollection ) = @_;
173
174 if ( !$inCollection ) {
175 _debug('_storeAttribute -- missing inCollection!');
176 return;
177 }
178 return if !defined $inValue;
179 return if !defined $inAttrName || $inAttrName eq '';
180 $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
sub _parseDefaultAttributes {
188324µs my (%params) = @_;
189
190115µs _debug('_parseDefaultAttributes');
# spent 15µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_debug
191
1921857µs _parseAttributes( 0, $defaultAttrs, \%params );
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
sub _parseTableSpecificTableAttributes {
2001074µs my (%params) = @_;
201
202115µs _debug('_parseTableSpecificTableAttributes');
# spent 15µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_debug
203
2041829µs _parseAttributes( 1, $tableSpecificAttrs, \%params );
205
206 # remove default values from hash
207915µs while ( my ( $key, $value ) = each %{$tableSpecificAttrs} ) {
208 delete $tableSpecificAttrs->{$key}
209 if $defaultAttrs->{$key} && $value eq $defaultAttrs->{$key};
210 }
211 $combinedTableAttrs =
2121100µs _mergeHashes( $combinedTableAttrs, $tableSpecificAttrs );
# spent 100µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_mergeHashes
213115µ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
2161110µs my ( $id, @styles ) = _createCssStyles( 0, $tableSpecificAttrs );
217115µs _debugData( "after _createCssStyles, id=$id; styles", \@styles );
# spent 15µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_debugData
218
219 _addHeadStyles( $id, @styles ) if scalar @styles;
220
221 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
sub _parseAttributes {
22984528µs my ( $isTableSpecific, $inCollection, $inParams ) = @_;
230
231238µ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 my $includeTopicParam = $inParams->{include};
236 $inParams = _getIncludeParams($includeTopicParam) if $includeTopicParam;
237
238 # table attributes
239 # some will be used for css styling as well
240
241 _storeAttribute( 'generateInlineMarkup',
242 Foswiki::Func::isTrue( $inParams->{inlinemarkup} ),
243 $inCollection )
244 if defined $inParams->{inlinemarkup};
245
246 # sort attributes
247316µs if ( defined $inParams->{sort} ) {
248164µs my $sort = Foswiki::Func::isTrue( $inParams->{sort} );
# spent 64µs making 1 call to Foswiki::Func::isTrue
249112µs _storeAttribute( 'sort', $sort, $inCollection );
250110µs _storeAttribute( 'sortAllTables', $sort, $inCollection );
251 }
252 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 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)
273243µs my $cgi = Foswiki::Func::getCgiQuery();
# spent 43µs making 2 calls to Foswiki::Func::getCgiQuery, avg 21µs/call
274295µs my $urlParamSort = $cgi->param('sort');
# spent 95µs making 2 calls to Foswiki::Request::param, avg 47µs/call
275 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)
282235µ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
287527µs if ($isTableSpecific) {
288
28918µs _storeAttribute( 'summary', $inParams->{summary}, $inCollection );
290 my $id =
291 defined $inParams->{id}
292 ? $inParams->{id}
293 : 'table'
294 . $Foswiki::Plugins::TablePlugin::topic
295 . ( $tableCount + 1 );
296110µs _storeAttribute( 'id', $id, $inCollection );
29717µs _storeAttribute( 'headerrows', $inParams->{headerrows}, $inCollection );
29816µs _storeAttribute( 'footerrows', $inParams->{footerrows}, $inCollection );
299 }
300220µs _storeAttribute( 'border', $inParams->{tableborder}, $inCollection );
# spent 20µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 10µs/call
301215µs _storeAttribute( 'tableBorderColor', $inParams->{tablebordercolor},
# spent 15µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call
302 $inCollection );
303214µs _storeAttribute( 'cellpadding', $inParams->{cellpadding}, $inCollection );
# spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call
304214µs _storeAttribute( 'cellspacing', $inParams->{cellspacing}, $inCollection );
# spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call
305214µ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 my @tableRulesList = ();
30929µs if ( $inParams->{tablerules} ) {
310
311 # store tablerules as array, so that headerrules and datarules
312 # can be appended to that list
313119µs my $param = _cleanParamValue( $inParams->{tablerules} );
31412µs if ($param) {
315 push( @tableRulesList, $param );
316 }
317 }
31828µs if ( $inParams->{headerrules} ) {
319114µs my $param = _cleanParamValue( $inParams->{headerrules} );
32024µs if ($param) {
321 $param = "header_$param";
322 push( @tableRulesList, $param );
323 }
324 }
325 if ( $inParams->{datarules} ) {
326 my $param = _cleanParamValue( $inParams->{datarules} );
327 if ($param) {
328 $param = "data_$param";
329 push( @tableRulesList, $param );
330 }
331 }
332 $inCollection->{tableRules} = \@tableRulesList if scalar @tableRulesList;
333
334 # use 'rules' as table attribute only (not to define css styles)
335 # but set to
336 my $rules =
337 ( defined $inParams->{headerrules} || defined $inParams->{datarules} )
338 ? 'none'
339 : $inParams->{tablerules};
340217µs _storeAttribute( 'rules', $rules, $inCollection );
# spent 17µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 8µs/call
341
342214µ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
345218µs _storeAttribute( 'headerColor', $inParams->{headercolor}, $inCollection );
# spent 18µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 9µs/call
346217µs _storeAttribute( 'headerBg', $inParams->{headerbg}, $inCollection );
# spent 17µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 8µs/call
347214µs _storeAttribute( 'cellBorder', $inParams->{cellborder}, $inCollection );
# spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call
348426µ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 );
351425µ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 );
354425µ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 );
357220µs _storeAttribute( 'vAlign', $inParams->{valign} || 'top', $inCollection );
# spent 20µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 10µs/call
358214µs _storeAttribute( 'dataVAlign', $inParams->{datavalign}, $inCollection );
# spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call
359214µs _storeAttribute( 'headerVAlign', $inParams->{headervalign}, $inCollection );
# spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call
360217µ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 );
3634102µ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 );
365440µ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 );
370425µ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 );
373214µ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
3763854µs while ( my ( $key, $value ) = each %{$inCollection} ) {
377 delete $inCollection->{$key} if !defined $value || $value eq '';
378 }
379
380231µ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
387From $includeTopic read the first TABLE tag and return its parameters.
388
389=cut
390
391sub _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
433Convert text to number if syntactically possible, otherwise return undef.
434Assumes that the text has been stripped from HTML markup.
435
436=cut
437
438sub _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
469Convert text to number if syntactically possible, otherwise return undef.
470Assumes that the text has been stripped from HTML markup.
471
472=cut
473
474sub _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
sub _processTableRow {
526128490µs my ( $thePre, $theRow ) = @_;
527
528 $currTablePre = $thePre || '';
529 my $span = 0;
530 my $l1 = 0;
531 my $l2 = 0;
532
5331078µs if ( !$insideTABLE ) {
534 @curTable = ();
535 @rowspan = ();
536
537 $tableCount++;
538 $currentSortDirection = $SORT_DIRECTION->{'NONE'};
539
540 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
557815µ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
558880µ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 =~
560813µ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 my $colCount = 0;
562 my @row = ();
563 $span = 0;
564 my $value = '';
565
566 foreach ( split( /\|/, $theRow ) ) {
5672641.24ms my $attr = {};
568 $span = 1;
569
570 #AS 25-5-01 Fix to avoid matching also single columns
57144102µ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 }
5752261µs s/^\s+$/ &nbsp; /o;
# spent 61µs making 22 calls to Foswiki::Plugins::TablePlugin::Core::CORE:subst, avg 3µs/call
576 ( $l1, $l2 ) = ( 0, 0 );
5774483µs22110µs if (/^(\s*).*?(\s*)$/) {
# spent 110µs making 22 calls to Foswiki::Plugins::TablePlugin::Core::CORE:match, avg 5µs/call
578 $l1 = length($1);
579 $l2 = length($2);
580 }
581 if ( $l1 >= 2 ) {
582 if ( $l2 <= 1 ) {
583 $attr->{align} = 'right';
584 }
585 else {
586 $attr->{align} = 'center';
587 }
588 }
58922185µs if ( $span <= 2 ) {
59022499µ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 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
609110521µs2242µ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 {
6142238µs for ( my $col = $colCount ; $col < ( $colCount + $span ) ; $col++ )
615 {
616 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 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 my $type = '';
65399262µs2267µs if (/^\s*\*(.*)\*\s*$/) {
# spent 67µs making 22 calls to Foswiki::Plugins::TablePlugin::Core::CORE:match, avg 3µs/call
654 $value = $1;
655 $type = 'th';
656
657 # html attribute: align
658 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 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 {
6851130µs1152µ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 $_ = $1;
687 }
688 $value = $_;
689 $type = 'td';
690
691 # html attribute: align
692 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 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 push @row, { text => $value, attrs => $attr, type => $type };
720 }
721 while ( $span > 1 ) {
722 push @row, { text => $value, type => 'X' };
723 $colCount++;
724 $span--;
725 }
726 $colCount++;
727 }
728 push @curTable, \@row;
729 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
sub _headerRowCount {
7341441µs my ($table) = @_;
735
736 my $headerCount = 0;
737 my $footerCount = 0;
738 my $endheader = 0;
739
740 # All cells in header are headings?
741 foreach my $row (@$table) {
7422464µs my $isHeader = 1;
743 foreach my $cell (@$row) {
74455115µs if ( $cell->{type} ne 'th' ) {
745 $isHeader = 0;
746 $endheader = 1;
747 $footerCount = 0 if $footerCount;
748 }
749 }
750810µs unless ($endheader) {
751 $headerCount++ if $isHeader;
752 }
753 else {
754 $footerCount++ if $isHeader;
755 }
756 }
757
758 # Some cells came after the footer - so there isn't one.
759 $footerCount = 0 if ( $endheader > 1 );
760
761 return ( $headerCount, $footerCount );
762}
763
764=pod
765
766_setSortTypeForCells ( $col, \@table )
767
768Sets a sort key for each cell.
769
770=cut
771
772sub _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
808sub _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/\&nbsp;/ /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
828Retrieve text data from an image html tag to be used for sorting.
829First try the alt tag string. If not available, return the url string.
830If not available, return the original string.
831
832=cut
833
834sub _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
860Appends $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
sub _appendToClassList {
865276805µs my ( $classList, $className ) = @_;
866 $classList = $classList ? $classList .= ' ' : '';
867 $classList .= $className;
868 return $classList;
869}
870
871sub _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
sub _appendRowNumberCssClass {
87848186µs my ( $classList, $colListName, $rowNum ) = @_;
879
880 my $rowClassName = 'foswikiTableRow' . $colListName . $rowNum;
88116123µ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
sub _appendColNumberCssClass {
88566269µs my ( $classList, $colNum ) = @_;
886
887 my $colClassName = 'foswikiTableCol' . $colNum;
88822194µ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
sub _appendFirstColumnCssClass {
8921680µs my ($classList) = @_;
893
894866µ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
sub _appendLastColumnCssClass {
8981682µs my ($classList) = @_;
899
900864µ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
sub _appendLastRowCssClass {
9041468µs my ($classList) = @_;
905
906754µs return _appendToClassList( $classList, 'foswikiLast' );
# spent 54µs making 7 calls to Foswiki::Plugins::TablePlugin::Core::_appendToClassList, avg 8µs/call
907}
908
909sub _appendSortedAscendingCssClass {
910 my ($classList) = @_;
911
912 return _appendToClassList( $classList, 'foswikiSortedAscendingCol' );
913}
914
915sub _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
sub _getDefaultSortDirection {
92322132µs return $SORT_DIRECTION->{'ASCENDING'};
924}
925
926# Gets the current sort direction.
927sub _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.
937sub _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
963Explicitly 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
sub _createCssStyles {
96862205µs my ( $writeDefaults, $inAttrs ) = @_;
969
970231µs _debug("_createCssStyles; writeDefaults=$writeDefaults");
# spent 31µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_debug, avg 16µs/call
971
972 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
my $setAttribute = sub {
974102278µs my ( $tableSelector, $type, $rule ) = @_;
975
976 return if !$rule;
977 $type ||= '#'; # for table selector only, if no type
978 my $storedType = $_styles->{$tableSelector}->{$type} || '';
979 if ( !defined $storedType ) {
980 @{ $_styles->{$tableSelector}->{$type} } = ();
981 }
9821752µs if ( $rule ne $storedType ) {
9831752µs push @{ $_styles->{$tableSelector}->{$type} }, $rule;
984 }
985 };
986
987412µs if ( $writeDefaults && !$didWriteDefaultStyle ) {
988 my $tableSelector = '.foswikiTable';
989 my $attr = 'padding-left:.3em; vertical-align:text-bottom';
990123µs &$setAttribute( $tableSelector, '.tableSortIcon img', $attr );
991
992 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 my $tableSelector;
1001 my $id;
100248µs if ($writeDefaults) {
1003 $id = 'default';
1004 $tableSelector = ".foswikiTable";
1005 }
1006 else {
1007 $id = $inAttrs->{id};
1008 $tableSelector = ".foswikiTable#$id";
1009 }
1010
1011 # tablerules
1012622µs if ( $inAttrs->{tableRules} ) {
101312µs my @rules = @{ $inAttrs->{tableRules} };
1014
1015 my $attr_td;
1016 my $attr_th;
1017 foreach my $rule (@rules) {
1018413µs $attr_td = $TABLE_RULES->{$rule}->{TD}
1019 if $TABLE_RULES->{$rule}->{TD};
1020 $attr_th = $TABLE_RULES->{$rule}->{TH}
1021 if $TABLE_RULES->{$rule}->{TH};
1022 }
1023124µs &$setAttribute( $tableSelector, 'th', $attr_th );
1024120µs &$setAttribute( $tableSelector, 'td', $attr_td );
1025 }
1026
1027 # tableframe
1028 if ( $inAttrs->{frame} ) {
1029 my $attr = $TABLE_FRAME->{ $inAttrs->{frame} };
1030 &$setAttribute( $tableSelector, '', $attr );
1031 }
1032
1033 # tableborder
1034315µs if ( defined $inAttrs->{border} ) {
1035 my $tableBorderWidth = $inAttrs->{border} || 0;
1036133µs my $attr = 'border-width:' . addDefaultSizeUnit($tableBorderWidth);
1037121µs &$setAttribute( $tableSelector, '', $attr );
1038 }
1039
1040 # tableBorderColor
1041 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 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 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 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 if ( defined $inAttrs->{width} ) {
1080 my $width = addDefaultSizeUnit( $inAttrs->{width} );
1081 my $attr = 'width:' . $width;
1082 &$setAttribute( $tableSelector, '', $attr );
1083 }
1084
1085 # valign
1086313µs if ( defined $inAttrs->{vAlign} ) {
1087 my $attr = 'vertical-align:' . $inAttrs->{vAlign};
1088118µs &$setAttribute( $tableSelector, 'td', $attr );
1089117µs &$setAttribute( $tableSelector, 'th', $attr );
1090 }
1091
1092 # headerVAlign
1093 if ( defined $inAttrs->{headerVAlign} ) {
1094 my $attr = 'vertical-align:' . $inAttrs->{headerVAlign};
1095 &$setAttribute( $tableSelector, 'th', $attr );
1096 }
1097
1098 # dataVAlign
1099 if ( defined $inAttrs->{dataVAlign} ) {
1100 my $attr = 'vertical-align:' . $inAttrs->{dataVAlign};
1101 &$setAttribute( $tableSelector, 'td', $attr );
1102 }
1103
1104 # headerbg
1105320µs if ( defined $inAttrs->{headerBg} ) {
110612µs my $color =
1107 ( $inAttrs->{headerBg} =~ /none/i )
1108 ? 'transparent'
1109 : $inAttrs->{headerBg};
1110 my $attr = 'background-color:' . $color;
1111118µs &$setAttribute( $tableSelector, 'th', $attr );
1112 }
1113
1114 # headerbgsorted
1115317µs if ( defined $inAttrs->{headerBgSorted} ) {
111612µs my $color =
1117 ( $inAttrs->{headerBgSorted} =~ /none/i )
1118 ? 'transparent'
1119 : $inAttrs->{headerBgSorted};
1120 my $attr = 'background-color:' . $color;
1121118µs &$setAttribute( $tableSelector, 'th.foswikiSortedCol', $attr );
1122 }
1123
1124 # headercolor
1125626µs if ( defined $inAttrs->{headerColor} ) {
1126 my $attr = 'color:' . $inAttrs->{headerColor};
1127117µs &$setAttribute( $tableSelector, 'th', $attr );
1128118µs &$setAttribute( $tableSelector, 'th a:link', $attr );
1129118µs &$setAttribute( $tableSelector, 'th a:visited', $attr );
1130117µs &$setAttribute( $tableSelector, 'th a:xhover', $attr )
1131 ; # just to make sorting work: hover should be last. below we will remove the x again.
113239µs if ( defined $inAttrs->{headerBg} ) {
1133 my $hoverBackgroundColor = $inAttrs->{headerBg};
1134 $attr = 'background-color:' . $hoverBackgroundColor;
1135118µs &$setAttribute( $tableSelector, 'th a:xhover', $attr );
1136 }
1137 }
1138
1139 # databg (array)
1140418µs if ( defined $inAttrs->{dataBgListRef} ) {
114112µs my @dataBg = @{ $inAttrs->{dataBgListRef} };
114212µs my $noneColor = ( $dataBg[0] =~ /none/i ) ? 'transparent' : '';
1143 my $count = 0;
1144 foreach my $color (@dataBg) {
11451230µs $color = $noneColor if $noneColor;
1146 next if !$color;
1147 my $rowSelector = 'foswikiTableRow' . 'dataBg' . $count;
1148 my $attr = "background-color:$color";
1149238µs &$setAttribute( $tableSelector, "tr.$rowSelector td", $attr );
1150 $count++;
1151 }
1152 }
1153
1154 # databgsorted (array)
1155418µs if ( defined $inAttrs->{dataBgSortedListRef} ) {
115612µs my @dataBgSorted = @{ $inAttrs->{dataBgSortedListRef} };
115712µs my $noneColor = ( $dataBgSorted[0] =~ /none/i ) ? 'transparent' : '';
1158 my $count = 0;
1159 foreach my $color (@dataBgSorted) {
11601230µs $color = $noneColor if $noneColor;
1161 next if !$color;
1162 my $rowSelector = 'foswikiTableRow' . 'dataBg' . $count;
1163 my $attr = "background-color:$color";
1164237µs &$setAttribute( $tableSelector,
1165 "tr.$rowSelector td.foswikiSortedCol", $attr );
1166 $count++;
1167 }
1168 }
1169
1170 # datacolor (array)
1171 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 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 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 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 my @styles = ();
124423µs214µs foreach my $tableSelector ( sort keys %{$_styles} ) {
# spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::CORE:sort, avg 7µs/call
1245224µs18µs foreach my $selector ( sort keys %{ $_styles->{$tableSelector} } ) {
# spent 8µs making 1 call to Foswiki::Plugins::TablePlugin::Core::CORE:sort
1246 my $selectors =
124748195µs join( '; ', @{ $_styles->{$tableSelector}->{$selector} } );
12481225µ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
12501232µs if ( $selector eq '#' ) {
1251 push @styles, "$tableSelector {$selectors}";
1252 }
1253 else {
1254 push @styles, "$tableSelector $selector {$selectors}";
1255 }
1256 }
1257 }
1258
1259 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
sub _addHeadStyles {
1263418µs my ( $inId, @inStyles ) = @_;
1264
1265 return if !scalar @inStyles;
1266
1267 $styles->{seendIds}->{$inId} = 1;
126829µs if ( $inId eq $HEAD_ID_DEFAULT_STYLE ) {
1269 $styles->{$HEAD_ID_DEFAULT_STYLE}->{'default'} = \@inStyles;
127013.23ms _writeStyleToHead( $HEAD_ID_DEFAULT_STYLE,
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
1284Creates an inline HTML markup
1285
1286=cut
1287
1288sub _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
sub _writeStyleToHead {
129473.15ms my ( $inId, $inStyles ) = @_;
1295
1296 my @allStyles = ();
129712µs14µs foreach my $id ( sort keys %{$inStyles} ) {
# spent 4µs making 1 call to Foswiki::Plugins::TablePlugin::Core::CORE:sort
1298210µs push @allStyles, @{ $inStyles->{$id} };
1299 }
1300 my $styleText = join( "\n", @allStyles );
1301
1302 my $header = <<EOS;
1303<style type="text/css" media="all">
1304$styleText
1305</style>
1306EOS
130733.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
1308168µ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
1313StaticMethod addDefaultSizeUnit ($text) -> $text
1314
1315Adds 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
sub addDefaultSizeUnit {
1320434µs my ($inSize) = @_;
1321
1322 my $unit = '';
132313µs28µs if ( $inSize =~ m/$PATTERN_ATTRIBUTE_SIZE/ ) {
1324 $unit = 'px' if !$2;
1325 }
1326 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
sub emitTable {
1330
133188404µs24.34ms _addDefaultStyles();
# spent 4.34ms making 2 calls to Foswiki::Plugins::TablePlugin::Core::_addDefaultStyles, avg 2.17ms/call
1332
1333232µ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 if ( $combinedTableAttrs->{headerrows} > scalar @curTable ) {
1337 $combinedTableAttrs->{headerrows} =
1338 scalar @curTable; # limit header to size of table!
1339 }
1340 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 my $sortThisTable =
1348 ( !defined $combinedTableAttrs->{sortAllTables}
1349 || $combinedTableAttrs->{sortAllTables} == 0 )
1350 ? 0
1351 : $combinedTableAttrs->{sort};
1352
1353623µs if ( $combinedTableAttrs->{headerrows} == 0 ) {
13542223µ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 $combinedTableAttrs->{headerrows} = $headerRowCount;
1358 $combinedTableAttrs->{footerrows} = $footerRowCount;
1359 }
1360
1361 my $tableTagAttributes = {};
1362 $tableTagAttributes->{class} = $combinedTableAttrs->{class};
1363 $tableTagAttributes->{border} = $combinedTableAttrs->{border};
1364 $tableTagAttributes->{cellspacing} = $combinedTableAttrs->{cellspacing};
1365 $tableTagAttributes->{cellpadding} = $combinedTableAttrs->{cellpadding};
1366 $tableTagAttributes->{id} = $combinedTableAttrs->{id}
1367 || undef;
1368 $tableTagAttributes->{summary} = $combinedTableAttrs->{summary};
1369 $tableTagAttributes->{frame} = $combinedTableAttrs->{frame};
1370 $tableTagAttributes->{rules} = $combinedTableAttrs->{rules};
1371 $tableTagAttributes->{width} = $combinedTableAttrs->{width};
1372
1373 # remove empty attributes
13743854µs while ( my ( $key, $value ) = each %{$tableTagAttributes} ) {
1375 delete $tableTagAttributes->{$key} if !defined $value || $value eq '';
1376 }
1377
13782584µ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 $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 my $maxCols = 0;
1384
1385 # Flush out any remaining rowspans
1386 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 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 my $rowCount = 0;
1482 my $numberOfRows = scalar(@curTable);
1483 my $dataColorCount = 0;
1484
1485 my @headerRowList = ();
1486 my @bodyRowList = ();
1487 my @footerRowList = ();
1488
1489 my $isPastHeaderRows = 0;
1490 my $singleIndent = "\n\t";
1491 my $doubleIndent = "\n\t\t";
1492 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 my $sortLinksWritten = 0;
1497
1498 foreach my $row (@curTable) {
1499160428µs my $rowtext = '';
1500 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 my $headerCellCount = 0;
1505 my $numberOfCols = scalar(@$row);
1506 my $writingSortLinks = 0;
1507
1508 foreach my $fcell (@$row) {
1509
1510 # check if cell exists
15114841.06ms next if ( !$fcell || !$fcell->{type} );
1512
1513 my $tableAnchor = '';
1514 next
1515 if ( $fcell->{type} eq 'X' )
1516 ; # data was there so sort could work with col spanning
1517 my $type = $fcell->{type};
1518 my $cell = $fcell->{text};
1519 my $attr = $fcell->{attrs} || {};
1520
1521 my $newDirection;
1522 my $isSorted = 0;
1523
152422123µ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 {
15392296µs $newDirection = _getDefaultSortDirection();
# spent 96µs making 22 calls to Foswiki::Plugins::TablePlugin::Core::_getDefaultSortDirection, avg 4µs/call
1540 }
1541
154299157µs if ( $type eq 'th' ) {
1543 $headerCellCount++;
1544
1545 # html attribute: bgcolor
1546 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 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 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 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 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 $type = 'td' unless $type eq 'Y';
1643
1644 # html attribute: bgcolor
1645 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 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 if ($isSorted) {
1687 $attr->{class} = _appendSortedCssClass( $attr->{class} );
1688 }
1689
1690 if ($writingSortLinks) {
1691 $sortLinksWritten = 1;
1692 }
1693
1694 my $isLastRow = ( $rowCount == $numberOfRows - 1 );
1695 if ( $attr->{rowspan} ) {
1696 $isLastRow =
1697 ( ( $rowCount + ( $attr->{rowspan} - 1 ) ) ==
1698 $numberOfRows - 1 );
1699 }
1700
1701 # CSS class name
17028159µ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 my $isLastCol = ( $colCount == $numberOfCols - 1 );
17058229µ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
17087131µ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 $colCount++;
1712 next if ( $type eq 'Y' );
1713 my $fn = 'CGI::' . $type;
1714283µs2123µ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
no strict 'refs';
# spent 74µs making 1 call to Foswiki::Plugins::TablePlugin::Core::BEGIN@1714 # spent 49µs making 1 call to strict::unimport
1715223.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
171622.09ms286µ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
use strict 'refs';
# 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 my $trClassName = '';
1722
1723 # just 2 css names is too limited, but we will keep it for compatibility
1724 # with existing style sheets
1725 my $rowTypeName =
1726 ( $rowCount % 2 ) ? 'foswikiTableEven' : 'foswikiTableOdd';
1727868µs $trClassName = _appendToClassList( $trClassName, $rowTypeName );
# spent 68µs making 8 calls to Foswiki::Plugins::TablePlugin::Core::_appendToClassList, avg 8µs/call
1728
17292494µs if ( $combinedTableAttrs->{dataBgSortedListRef} ) {
1730814µs my @dataBgSorted = @{ $combinedTableAttrs->{dataBgSortedListRef} };
1731 my $modRowNum = $dataColorCount % ( $#dataBgSorted + 1 );
17328170µ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 }
17362490µs if ( $combinedTableAttrs->{dataBgListRef} ) {
1737812µs my @dataBg = @{ $combinedTableAttrs->{dataBgListRef} };
1738 my $modRowNum = $dataColorCount % ( $#dataBg + 1 );
17398159µ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 if ( $combinedTableAttrs->{dataColorListRef} ) {
1743 my @dataColor = @{ $combinedTableAttrs->{dataColorListRef} };
1744 my $modRowNum = $dataColorCount % ( $#dataColor + 1 );
1745 $trClassName =
1746 _appendRowNumberCssClass( $trClassName, 'dataColor', $modRowNum );
1747 }
1748 $rowtext .= $doubleIndent;
174981.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 my $isHeaderRow =
1753 $rowCount <
1754 $combinedTableAttrs->{headerrows}; #( $headerCellCount == $colCount );
1755 my $isFooterRow =
1756 ( ( $numberOfRows - $rowCount ) <=
1757 $combinedTableAttrs->{footerrows} );
1758
1759710µs if ( !$isHeaderRow && !$isFooterRow ) {
1760
1761 # don't include non-adjacent header rows to the top block of header rows
1762 $isPastHeaderRows = 1;
1763 }
1764
17651526µs if ($isFooterRow) {
1766 push @footerRowList, $rowHTML;
1767 }
1768 elsif ( $isHeaderRow && !$isPastHeaderRows ) {
1769 push( @headerRowList, $rowHTML );
1770 }
1771 else {
1772 push @bodyRowList, $rowHTML;
1773 $dataColorCount++;
1774 }
1775
177612µs if ($isHeaderRow) {
1777
1778 # reset data color count to start with first color after
1779 # each table heading
1780 $dataColorCount = 0;
1781 }
1782
1783 $rowCount++;
1784 } # foreach my $row ( @curTable )
1785
1786 my $thead =
1787 "$singleIndent<thead>"
1788 . join( "", @headerRowList )
1789 . "$singleIndent</thead>";
1790 $text .= $currTablePre . $thead if scalar @headerRowList;
1791
1792 my $tfoot =
1793 "$singleIndent<tfoot>"
1794 . join( "", @footerRowList )
1795 . "$singleIndent</tfoot>";
1796 $text .= $currTablePre . $tfoot if scalar @footerRowList;
1797
1798 my $tbody;
1799214µs if ( scalar @bodyRowList ) {
1800 $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 $text .= $currTablePre . $tbody;
1813
18142310µ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
18172304µs _resetReusedVariables();
# spent 304µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_resetReusedVariables, avg 152µs/call
1818
1819 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
sub handler {
1823 ### my ( $text, $removed ) = @_;
1824
182545948µs5133µs _debug('handler');
# spent 133µs making 5 calls to Foswiki::Plugins::TablePlugin::Core::_debug, avg 27µs/call
1826
182726122µs unless ($Foswiki::Plugins::TablePlugin::initialised) {
1828 $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 $tableCount = 0;
1834
1835132µs my $cgi = Foswiki::Func::getCgiQuery();
# spent 32µs making 1 call to Foswiki::Func::getCgiQuery
1836 return unless $cgi;
1837
1838 # Copy existing values
1839 my ( @origSort, @origTable, @origUp );
1840159µs @origSort = $cgi->param('sortcol');
# spent 59µs making 1 call to Foswiki::Request::param
1841144µs @origTable = $cgi->param('table');
# spent 44µs making 1 call to Foswiki::Request::param
1842141µs @origUp = $cgi->param('up'); # NOTE: internal parameter
# spent 41µs making 1 call to Foswiki::Request::param
1843126µs $cgi->delete( 'sortcol', 'table', 'up' );
# spent 26µs making 1 call to Foswiki::Request::delete
18441322µs $url = $cgi->url( -absolute => 1, -path => 1 ) . '?';
# spent 322µs making 1 call to Foswiki::Request::url
1845151µs my $queryString = $cgi->query_string();
# spent 51µs making 1 call to Foswiki::Request::queryString
1846 $url .= $queryString . ';' if $queryString;
1847
1848 # Restore parameters, so we don't interfere on the remaining execution
1849 $cgi->param( -name => 'sortcol', -value => \@origSort ) if @origSort;
1850 $cgi->param( -name => 'table', -value => \@origTable ) if @origTable;
1851 $cgi->param( -name => 'up', -value => \@origUp ) if @origUp;
1852
1853145µs $sortColFromUrl =
# spent 45µs making 1 call to Foswiki::Request::param
1854 $cgi->param('sortcol'); # zero based: 0 is first column
1855 if ( defined $sortColFromUrl && $sortColFromUrl !~ m/^[0-9]+$/ ) {
1856 $sortColFromUrl = 0;
1857 }
1858
1859144µs $requestedTable = $cgi->param('table');
# spent 44µs making 1 call to Foswiki::Request::param
1860 $requestedTable = 0
1861 unless ( defined $requestedTable && $requestedTable =~ m/^[0-9]+$/ );
1862
1863144µs $up = $cgi->param('up');
# spent 44µs making 1 call to Foswiki::Request::param
1864
1865 $sortTablesInText = 0;
1866 $sortAttachments = 0;
18671139µs my $tmp = Foswiki::Func::getPreferencesValue('TABLEPLUGIN_SORT')
# spent 139µs making 1 call to Foswiki::Func::getPreferencesValue
1868 || 'all';
186923µs14µs if ( !$tmp || $tmp =~ /^all$/oi ) {
1870 $sortTablesInText = 1;
1871 $sortAttachments = 1;
1872 }
1873 elsif ( $tmp =~ /^attachments$/oi ) {
1874 $sortAttachments = 1;
1875 }
1876
187711.04ms _initDefaults(); # first time
1878 $Foswiki::Plugins::TablePlugin::initialised = 1;
1879 }
1880
1881 $insideTABLE = 0;
1882
1883 my $defaultSort = $combinedTableAttrs->{sortAllTables};
1884
1885 my $acceptable = $combinedTableAttrs->{sortAllTables};
1886 my @lines = split( /\r?\n/, $_[0] );
1887 for (@lines) {
18882153.92ms5841.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
188921.35mss/$PATTERN_TABLE/_parseTableSpecificTableAttributes(Foswiki::Func::extractParameters($1))/se
1890 )
189183.43ms {
# spent 3.43ms making 8 calls to Foswiki::Plugins::TablePlugin::Core::_processTableRow, avg 429µs/call
1892 $acceptable = 1;
1893 }
1894 elsif (s/^(\s*)\|(.*\|\s*)$/_processTableRow($1,$2)/eo) {
1895 $insideTABLE = 1;
1896 }
1897 elsif ($insideTABLE) {
1898214.8ms $_ = emitTable() . $_;
# spent 14.8ms making 2 calls to Foswiki::Plugins::TablePlugin::Core::emitTable, avg 7.40ms/call
1899 $insideTABLE = 0;
1900
1901 $combinedTableAttrs->{sortAllTables} = $defaultSort;
1902 $acceptable = $defaultSort;
1903 }
1904 }
1905 $_[0] = join( "\n", @lines );
1906
1907 if ($insideTABLE) {
1908 $_[0] .= emitTable();
1909 }
1910}
1911
1912=pod
1913
1914_mergeHashes (\%a, \%b ) -> \%merged
1915
1916Merges 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
sub _mergeHashes {
192120292µs my ( $A, $B ) = @_;
1922
1923 my %merged = ();
19241424µs while ( my ( $k, $v ) = each(%$A) ) {
1925 $merged{$k} = $v;
1926 }
19274580µs while ( my ( $k, $v ) = each(%$B) ) {
1928 $merged{$k} = $v;
1929 }
1930 return \%merged;
1931}
1932
1933=pod
1934
1935=cut
1936
1937
# spent 32µs (29+3) within Foswiki::Plugins::TablePlugin::Core::_cleanParamValue which was called 2 times, avg 16µs/call: # once (17µs+2µs) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 313 # once (12µs+2µs) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 319
sub _cleanParamValue {
1938838µs my ($inValue) = @_;
1939
1940 return undef if !$inValue;
1941
194223µs $inValue =~ s/ //go; # remove spaces
# spent 3µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::CORE:subst, avg 2µs/call
1943 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
sub _arrayRefFromParam {
195130125µs my ($inValue) = @_;
1952
1953 return undef if !$inValue;
1954
195524µs $inValue =~ s/ //go; # remove spaces
# spent 4µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::CORE:subst, avg 2µs/call
1956 my @list = split( /,/, $inValue );
1957 return \@list;
1958}
1959
1960=pod
1961
1962Shorthand 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
sub _debug {
196714146µs14100µ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
sub _debugData {
1971654µs641µ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
1974151µs1;
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:match; # opcode
# spent 10µs within Foswiki::Plugins::TablePlugin::Core::CORE:qr which was called 2 times, avg 5µs/call: # once (6µs+0s) by Foswiki::Plugins::TablePlugin::BEGIN@1 at line 41 # once (4µs+0s) by Foswiki::Plugins::TablePlugin::BEGIN@1 at line 92
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
sub Foswiki::Plugins::TablePlugin::Core::CORE:regcomp; # opcode
# 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
sub Foswiki::Plugins::TablePlugin::Core::CORE:sort; # opcode
# 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
sub Foswiki::Plugins::TablePlugin::Core::CORE:subst; # opcode
# 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
sub Foswiki::Plugins::TablePlugin::Core::CORE:substcont; # opcode