← 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:27:24 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 {
12212µs $translationToken = "\0";
123
124 # the maximum number of columns we will handle
12512µs $MAX_SORT_COLS = 10000;
12611µs $didWriteDefaultStyle = 0;
12711µs $tableCount = 0;
12811µs $currTablePre = '';
12912µs $combinedTableAttrs = {};
13019µs $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 {
13415µs116µs _debug('_initDefaults');
# spent 16µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_debug
13515µs $defaultAttrs = {
136 headerrows => 0,
137 footerrows => 0,
138 sort => 1,
139 class => 'foswikiTable',
140 sortAllTables => $sortTablesInText,
141 };
142
143113µs1902µs _parseDefaultAttributes(
144 %{Foswiki::Plugins::TablePlugin::pluginAttributes} );
145
146111µs186µ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
15128µs return if $Foswiki::Plugins::TablePlugin::writtenToHead;
15212µs $Foswiki::Plugins::TablePlugin::writtenToHead = 1;
153
154 # create CSS styles tables in general
15518µs11.05ms my ( $id, @styles ) = _createCssStyles( 1, $defaultAttrs );
156114µs13.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 {
160210µs232µs _debug('_resetReusedVariables');
# spent 32µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_debug, avg 16µs/call
16123µs $currTablePre = '';
162234µs2199µs $combinedTableAttrs = _mergeHashes( {}, $defaultAttrs );
# spent 199µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_mergeHashes, avg 100µs/call
16325µs $tableSpecificAttrs = {};
164216µs $sortCol = 0;
165}
166
167=pod
168
169=cut
170
171
# spent 437µs within Foswiki::Plugins::TablePlugin::Core::_storeAttribute which was called 48 times, avg 9µs/call: # 2 times (77µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 363, avg 39µs/call # 2 times (20µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 357, avg 10µs/call # 2 times (20µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 300, avg 10µs/call # 2 times (18µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 345, avg 9µs/call # 2 times (17µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 365, avg 8µs/call # 2 times (17µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 360, avg 8µs/call # 2 times (17µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 346, avg 8µs/call # 2 times (17µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 340, avg 8µs/call # 2 times (15µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 301, avg 7µs/call # 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 342, avg 7µs/call # 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 347, avg 7µs/call # 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 303, avg 7µs/call # 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 359, avg 7µs/call # 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 305, avg 7µs/call # 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 304, avg 7µs/call # 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 373, avg 7µs/call # 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 358, avg 7µs/call # 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 351, avg 7µs/call # 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 348, avg 7µs/call # 2 times (14µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 354, avg 7µs/call # 2 times (13µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 370, avg 7µs/call # once (12µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 249 # once (10µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 250 # once (10µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 296 # once (8µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 289 # once (7µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 297 # once (6µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 298
sub _storeAttribute {
1724894µs my ( $inAttrName, $inValue, $inCollection ) = @_;
173
17448119µs if ( !$inCollection ) {
175 _debug('_storeAttribute -- missing inCollection!');
176 return;
177 }
17848232µs return if !defined $inValue;
1791218µs return if !defined $inAttrName || $inAttrName eq '';
1801291µs $inCollection->{$inAttrName} = $inValue;
181}
182
183=pod
184
185=cut
186
187
# spent 902µs (29+873) within Foswiki::Plugins::TablePlugin::Core::_parseDefaultAttributes which was called: # once (29µs+873µs) by Foswiki::Plugins::TablePlugin::Core::_initDefaults at line 143
sub _parseDefaultAttributes {
18818µs my (%params) = @_;
189
19015µs115µs _debug('_parseDefaultAttributes');
# spent 15µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_debug
191
192111µs1857µ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 {
20014µs my (%params) = @_;
201
20214µs115µs _debug('_parseTableSpecificTableAttributes');
# spent 15µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_debug
203
20416µs1829µs _parseAttributes( 1, $tableSpecificAttrs, \%params );
205
206 # remove default values from hash
207630µs while ( my ( $key, $value ) = each %{$tableSpecificAttrs} ) {
20849µs delete $tableSpecificAttrs->{$key}
209 if $defaultAttrs->{$key} && $value eq $defaultAttrs->{$key};
210 }
211 $combinedTableAttrs =
21218µs1100µs _mergeHashes( $combinedTableAttrs, $tableSpecificAttrs );
# spent 100µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_mergeHashes
21315µs115µ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
21617µs1110µs my ( $id, @styles ) = _createCssStyles( 0, $tableSpecificAttrs );
21716µs115µs _debugData( "after _createCssStyles, id=$id; styles", \@styles );
# spent 15µs making 1 call to Foswiki::Plugins::TablePlugin::Core::_debugData
218
21912µs _addHeadStyles( $id, @styles ) if scalar @styles;
220
22119µs return $currTablePre . '<nop>';
222}
223
224=pod
225
226=cut
227
228
# spent 1.69ms (816µs+870µs) within Foswiki::Plugins::TablePlugin::Core::_parseAttributes which was called 2 times, avg 843µs/call: # once (459µs+398µs) by Foswiki::Plugins::TablePlugin::Core::_parseDefaultAttributes at line 192 # once (357µs+471µs) by Foswiki::Plugins::TablePlugin::Core::_parseTableSpecificTableAttributes at line 204
sub _parseAttributes {
22924µs my ( $isTableSpecific, $inCollection, $inParams ) = @_;
230
231212µs238µ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
23524µs my $includeTopicParam = $inParams->{include};
23622µs $inParams = _getIncludeParams($includeTopicParam) if $includeTopicParam;
237
238 # table attributes
239 # some will be used for css styling as well
240
24123µs _storeAttribute( 'generateInlineMarkup',
242 Foswiki::Func::isTrue( $inParams->{inlinemarkup} ),
243 $inCollection )
244 if defined $inParams->{inlinemarkup};
245
246 # sort attributes
247210µs if ( defined $inParams->{sort} ) {
24815µs164µs my $sort = Foswiki::Func::isTrue( $inParams->{sort} );
# spent 64µs making 1 call to Foswiki::Func::isTrue
24916µs112µs _storeAttribute( 'sort', $sort, $inCollection );
25015µs110µs _storeAttribute( 'sortAllTables', $sort, $inCollection );
251 }
25224µs if ( defined( $inParams->{initsort} )
253 and int( $inParams->{initsort} ) > 0 )
254 {
255 _storeAttribute( 'initSort', $inParams->{initsort}, $inCollection );
256
257 # override sort attribute: we are sorting after all
258 _storeAttribute( 'sort', 1, $inCollection );
259 }
260
26123µs if ( $inParams->{initdirection} ) {
262 _storeAttribute( 'initDirection', $SORT_DIRECTION->{'ASCENDING'},
263 $inCollection )
264 if $inParams->{initdirection} =~ /^down$/i;
265 _storeAttribute( 'initDirection', $SORT_DIRECTION->{'DESCENDING'},
266 $inCollection )
267 if $inParams->{initdirection} =~ /^up$/i;
268 }
269
270 # If EditTablePlugin is installed and we are editing a table,
271 # the CGI parameter 'sort' is defined as "off" to disable all
272 # header sorting ((Item5135)
273211µs243µs my $cgi = Foswiki::Func::getCgiQuery();
# spent 43µs making 2 calls to Foswiki::Func::getCgiQuery, avg 21µs/call
274211µs295µs my $urlParamSort = $cgi->param('sort');
# spent 95µs making 2 calls to Foswiki::Request::param, avg 47µs/call
27523µs if ( $urlParamSort && $urlParamSort =~ /^off$/oi ) {
276 delete $inCollection->{sortAllTables};
277 }
278
279 # If EditTablePlugin is installed and we are editing a table, the
280 # 'disableallsort' TABLE parameter is added to disable initsort and header
281 # sorting in the table that is being edited. (Item5135)
282216µs235µ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
28724µs if ($isTableSpecific) {
288
28917µs18µs _storeAttribute( 'summary', $inParams->{summary}, $inCollection );
29013µs my $id =
291 defined $inParams->{id}
292 ? $inParams->{id}
293 : 'table'
294 . $Foswiki::Plugins::TablePlugin::topic
295 . ( $tableCount + 1 );
29615µs110µs _storeAttribute( 'id', $id, $inCollection );
29716µs17µs _storeAttribute( 'headerrows', $inParams->{headerrows}, $inCollection );
29816µs16µs _storeAttribute( 'footerrows', $inParams->{footerrows}, $inCollection );
299 }
300212µs220µs _storeAttribute( 'border', $inParams->{tableborder}, $inCollection );
# spent 20µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 10µs/call
301212µs215µs _storeAttribute( 'tableBorderColor', $inParams->{tablebordercolor},
# spent 15µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call
302 $inCollection );
303212µs214µs _storeAttribute( 'cellpadding', $inParams->{cellpadding}, $inCollection );
# spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call
304212µs214µs _storeAttribute( 'cellspacing', $inParams->{cellspacing}, $inCollection );
# spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call
305212µs214µ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
30824µs my @tableRulesList = ();
30925µs if ( $inParams->{tablerules} ) {
310
311 # store tablerules as array, so that headerrules and datarules
312 # can be appended to that list
31316µs119µs my $param = _cleanParamValue( $inParams->{tablerules} );
31413µs if ($param) {
31512µs push( @tableRulesList, $param );
316 }
317 }
31824µs if ( $inParams->{headerrules} ) {
31915µs114µs my $param = _cleanParamValue( $inParams->{headerrules} );
32013µs if ($param) {
32112µs $param = "header_$param";
32212µs push( @tableRulesList, $param );
323 }
324 }
32523µs if ( $inParams->{datarules} ) {
326 my $param = _cleanParamValue( $inParams->{datarules} );
327 if ($param) {
328 $param = "data_$param";
329 push( @tableRulesList, $param );
330 }
331 }
33224µs $inCollection->{tableRules} = \@tableRulesList if scalar @tableRulesList;
333
334 # use 'rules' as table attribute only (not to define css styles)
335 # but set to
33624µs my $rules =
337 ( defined $inParams->{headerrules} || defined $inParams->{datarules} )
338 ? 'none'
339 : $inParams->{tablerules};
34029µs217µs _storeAttribute( 'rules', $rules, $inCollection );
# spent 17µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 8µs/call
341
342213µs214µ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
345212µs218µs _storeAttribute( 'headerColor', $inParams->{headercolor}, $inCollection );
# spent 18µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 9µs/call
346211µs217µs _storeAttribute( 'headerBg', $inParams->{headerbg}, $inCollection );
# spent 17µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 8µs/call
347212µs214µs _storeAttribute( 'cellBorder', $inParams->{cellborder}, $inCollection );
# spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call
348220µs426µ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 );
351220µs425µ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 );
354220µs425µ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 );
357210µs220µs _storeAttribute( 'vAlign', $inParams->{valign} || 'top', $inCollection );
# spent 20µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 10µs/call
358212µs214µs _storeAttribute( 'dataVAlign', $inParams->{datavalign}, $inCollection );
# spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call
359212µs214µs _storeAttribute( 'headerVAlign', $inParams->{headervalign}, $inCollection );
# spent 14µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_storeAttribute, avg 7µs/call
360211µs217µ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 );
363219µs4102µ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 );
365219µs440µ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 );
370220µs425µ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 );
373212µs214µ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
37622123µs while ( my ( $key, $value ) = each %{$inCollection} ) {
3771828µs delete $inCollection->{$key} if !defined $value || $value eq '';
378 }
379
380224µs231µ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 {
526830µs my ( $thePre, $theRow ) = @_;
527
528816µs $currTablePre = $thePre || '';
529811µs my $span = 0;
530810µs my $l1 = 0;
531811µs my $l2 = 0;
532
533814µs if ( !$insideTABLE ) {
534261µs @curTable = ();
53523µs @rowspan = ();
536
53723µs $tableCount++;
53825µs $currentSortDirection = $SORT_DIRECTION->{'NONE'};
539
54026µs if ( defined $requestedTable
541 && $requestedTable == $tableCount
542 && defined $sortColFromUrl )
543 {
544 $sortCol = $sortColFromUrl;
545 $sortCol = 0 unless ( $sortCol =~ m/^[0-9]+$/ );
546 $sortCol = $MAX_SORT_COLS if ( $sortCol > $MAX_SORT_COLS );
547 $currentSortDirection = _getCurrentSortDirection($up);
548 }
549 elsif ( defined $combinedTableAttrs->{initSort} ) {
550 $sortCol = $combinedTableAttrs->{initSort} - 1;
551 $sortCol = $MAX_SORT_COLS if ( $sortCol > $MAX_SORT_COLS );
552 $currentSortDirection =
553 _getCurrentSortDirection( $combinedTableAttrs->{initDirection} );
554 }
555 }
556
557857µs815µ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
5588118µs880µ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 =~
560847µs813µ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
561811µs my $colCount = 0;
562815µs my @row = ();
563812µs $span = 0;
564815µs my $value = '';
565
566847µs foreach ( split( /\|/, $theRow ) ) {
5672238µs my $attr = {};
5682228µs $span = 1;
569
570 #AS 25-5-01 Fix to avoid matching also single columns
57122286µs44102µ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 }
57522157µs2261µs s/^\s+$/ &nbsp; /o;
# spent 61µs making 22 calls to Foswiki::Plugins::TablePlugin::Core::CORE:subst, avg 3µs/call
5762236µs ( $l1, $l2 ) = ( 0, 0 );
57722243µs22110µs if (/^(\s*).*?(\s*)$/) {
# spent 110µs making 22 calls to Foswiki::Plugins::TablePlugin::Core::CORE:match, avg 5µs/call
5782248µs $l1 = length($1);
5792235µs $l2 = length($2);
580 }
5812232µs if ( $l1 >= 2 ) {
582 if ( $l2 <= 1 ) {
583 $attr->{align} = 'right';
584 }
585 else {
586 $attr->{align} = 'center';
587 }
588 }
5892273µs if ( $span <= 2 ) {
59022185µs22499µ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
5952236µs if ( $combinedTableAttrs->{generateInlineMarkup}
596 && defined $combinedTableAttrs->{columnWidthsListRef} )
597 {
598 my @columnWidths = @{ $combinedTableAttrs->{columnWidthsListRef} };
599 if ( defined $columnWidths[$colCount]
600 && $columnWidths[$colCount]
601 && $span <= 2 )
602 {
603 $attr->{width} = $columnWidths[$colCount];
604 }
605 }
606
607 # END html attribute
608
60922183µ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 {
61422155µs for ( my $col = $colCount ; $col < ( $colCount + $span ) ; $col++ )
615 {
6162238µs if ( defined( $rowspan[$col] ) && $rowspan[$col] ) {
617 my $nRows = scalar(@curTable);
618 my $rspan = $rowspan[$col] + 1;
619 if ( $rspan > 1 ) {
620 $curTable[ $nRows - $rspan ][$col]->{attrs}->{rowspan} =
621 $rspan;
622 }
623 undef( $rowspan[$col] );
624 }
625 }
626
6272245µs if (
628 (
629 (
630 defined $requestedTable
631 && $requestedTable == $tableCount
632 )
633 || defined $combinedTableAttrs->{initSort}
634 )
635 && defined $sortCol
636 && $colCount == $sortCol
637 )
638 {
639
640 # CSS class name
641 if ( $currentSortDirection == $SORT_DIRECTION->{'ASCENDING'} ) {
642 $attr->{class} =
643 _appendSortedAscendingCssClass( $attr->{class} );
644 }
645 if ( $currentSortDirection == $SORT_DIRECTION->{'DESCENDING'} )
646 {
647 $attr->{class} =
648 _appendSortedDescendingCssClass( $attr->{class} );
649 }
650 }
651
6522234µs my $type = '';
65322196µs2267µs if (/^\s*\*(.*)\*\s*$/) {
# spent 67µs making 22 calls to Foswiki::Plugins::TablePlugin::Core::CORE:match, avg 3µs/call
6541128µs $value = $1;
6551115µs $type = 'th';
656
657 # html attribute: align
6581118µs if ( $combinedTableAttrs->{generateInlineMarkup}
659 && defined $combinedTableAttrs->{headerAlignListRef} )
660 {
661 my @headerAlign =
662 @{ $combinedTableAttrs->{headerAlignListRef} };
663 if (@headerAlign) {
664 my $align =
665 @headerAlign[ $colCount % ( $#headerAlign + 1 ) ];
666 $attr->{align} = $align;
667 }
668 }
669
670 # END html attribute
671
672 # html attribute: valign
6731117µs if ( $combinedTableAttrs->{generateInlineMarkup} ) {
674 if ( defined $combinedTableAttrs->{headerVAlign} ) {
675 $attr->{valign} = $combinedTableAttrs->{headerVAlign};
676 }
677 elsif ( defined $combinedTableAttrs->{vAlign} ) {
678 $attr->{valign} = $combinedTableAttrs->{vAlign};
679 }
680 }
681
682 # END html attribute
683 }
684 else {
68511118µ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
6861130µs $_ = $1;
687 }
6881114µs $value = $_;
6891116µs $type = 'td';
690
691 # html attribute: align
6921118µs if ( $combinedTableAttrs->{generateInlineMarkup}
693 && defined $combinedTableAttrs->{dataAlignListRef} )
694 {
695 my @dataAlign =
696 @{ $combinedTableAttrs->{dataAlignListRef} };
697 if (@dataAlign) {
698 my $align =
699 @dataAlign[ $colCount % ( $#dataAlign + 1 ) ];
700 $attr->{align} = $align;
701 }
702 }
703
704 # END html attribute
705
706 # html attribute: valign
7071117µs if ( $combinedTableAttrs->{generateInlineMarkup} ) {
708 if ( defined $combinedTableAttrs->{dataVAlign} ) {
709 $attr->{valign} = $combinedTableAttrs->{dataVAlign};
710 }
711 elsif ( defined $combinedTableAttrs->{vAlign} ) {
712 $attr->{valign} = $combinedTableAttrs->{vAlign};
713 }
714 }
715
716 # END html attribute
717 }
718
7192291µs push @row, { text => $value, attrs => $attr, type => $type };
720 }
7212257µs while ( $span > 1 ) {
722 push @row, { text => $value, type => 'X' };
723 $colCount++;
724 $span--;
725 }
7262272µs $colCount++;
727 }
728815µs push @curTable, \@row;
729860µs return $currTablePre
730 . '<nop>'; # Avoid Foswiki converting empty lines to new paras
731}
732
733
# spent 223µs within Foswiki::Plugins::TablePlugin::Core::_headerRowCount which was called 2 times, avg 111µs/call: # 2 times (223µs+0s) by Foswiki::Plugins::TablePlugin::Core::emitTable at line 1354, avg 111µs/call
sub _headerRowCount {
73424µs my ($table) = @_;
735
73623µs my $headerCount = 0;
73723µs my $footerCount = 0;
73823µs my $endheader = 0;
739
740 # All cells in header are headings?
74128µs foreach my $row (@$table) {
742810µs my $isHeader = 1;
743822µs foreach my $cell (@$row) {
7442276µs if ( $cell->{type} ne 'th' ) {
7451114µs $isHeader = 0;
7461111µs $endheader = 1;
7471114µs $footerCount = 0 if $footerCount;
748 }
749 }
750832µs unless ($endheader) {
75112µs $headerCount++ if $isHeader;
752 }
753 else {
75479µs $footerCount++ if $isHeader;
755 }
756 }
757
758 # Some cells came after the footer - so there isn't one.
75923µs $footerCount = 0 if ( $endheader > 1 );
760
761217µs 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 {
86569113µs my ( $classList, $className ) = @_;
86669100µs $classList = $classList ? $classList .= ' ' : '';
8676991µs $classList .= $className;
86869500µs 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 {
8781629µs my ( $classList, $colListName, $rowNum ) = @_;
879
8801631µs my $rowClassName = 'foswikiTableRow' . $colListName . $rowNum;
88116126µs16123µ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 {
8852247µs my ( $classList, $colNum ) = @_;
886
8872241µs my $colClassName = 'foswikiTableCol' . $colNum;
88822181µs22194µ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 {
892815µs my ($classList) = @_;
893
894864µs866µ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 {
898814µs my ($classList) = @_;
899
900868µs864µ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 {
904712µs my ($classList) = @_;
905
906756µs754µ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 {
96824µs my ( $writeDefaults, $inAttrs ) = @_;
969
970210µs231µs _debug("_createCssStyles; writeDefaults=$writeDefaults");
# spent 31µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_debug, avg 16µs/call
971
97224µs my $_styles = {};
973
# spent 323µs within Foswiki::Plugins::TablePlugin::Core::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TablePlugin/Core.pm:985] which was called 17 times, avg 19µs/call: # 2 times (38µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1149, avg 19µs/call # 2 times (37µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1164, avg 19µs/call # once (24µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1023 # once (23µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 990 # once (21µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1037 # once (20µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1024 # once (18µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1129 # once (18µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1128 # once (18µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1088 # once (18µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1121 # once (18µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1111 # once (18µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1135 # once (17µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1089 # once (17µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1130 # once (17µs+0s) by Foswiki::Plugins::TablePlugin::Core::_createCssStyles at line 1127
my $setAttribute = sub {
9741731µs my ( $tableSelector, $type, $rule ) = @_;
975
9761721µs return if !$rule;
9771720µs $type ||= '#'; # for table selector only, if no type
9781735µs my $storedType = $_styles->{$tableSelector}->{$type} || '';
9791722µs if ( !defined $storedType ) {
980 @{ $_styles->{$tableSelector}->{$type} } = ();
981 }
98217150µs if ( $rule ne $storedType ) {
98334104µs push @{ $_styles->{$tableSelector}->{$type} }, $rule;
984 }
985215µs };
986
98724µs if ( $writeDefaults && !$didWriteDefaultStyle ) {
98812µs my $tableSelector = '.foswikiTable';
98912µs my $attr = 'padding-left:.3em; vertical-align:text-bottom';
99016µs123µs &$setAttribute( $tableSelector, '.tableSortIcon img', $attr );
991
99213µs if ( $inAttrs->{cellpadding} ) {
993 my $attr =
994 'padding:' . addDefaultSizeUnit( $inAttrs->{cellpadding} );
995 &$setAttribute( $tableSelector, 'td', $attr );
996 &$setAttribute( $tableSelector, 'th', $attr );
997 }
998 }
999
100022µs my $tableSelector;
100122µs my $id;
100225µs if ($writeDefaults) {
100312µs $id = 'default';
100411µs $tableSelector = ".foswikiTable";
1005 }
1006 else {
100712µs $id = $inAttrs->{id};
100812µs $tableSelector = ".foswikiTable#$id";
1009 }
1010
1011 # tablerules
101225µs if ( $inAttrs->{tableRules} ) {
101326µs my @rules = @{ $inAttrs->{tableRules} };
1014
101511µs my $attr_td;
101611µs my $attr_th;
101714µs foreach my $rule (@rules) {
101826µs $attr_td = $TABLE_RULES->{$rule}->{TD}
1019 if $TABLE_RULES->{$rule}->{TD};
102028µs $attr_th = $TABLE_RULES->{$rule}->{TH}
1021 if $TABLE_RULES->{$rule}->{TH};
1022 }
102315µs124µs &$setAttribute( $tableSelector, 'th', $attr_th );
102416µs120µs &$setAttribute( $tableSelector, 'td', $attr_td );
1025 }
1026
1027 # tableframe
102824µs if ( $inAttrs->{frame} ) {
1029 my $attr = $TABLE_FRAME->{ $inAttrs->{frame} };
1030 &$setAttribute( $tableSelector, '', $attr );
1031 }
1032
1033 # tableborder
103425µs if ( defined $inAttrs->{border} ) {
103512µs my $tableBorderWidth = $inAttrs->{border} || 0;
103617µs133µs my $attr = 'border-width:' . addDefaultSizeUnit($tableBorderWidth);
103716µs121µs &$setAttribute( $tableSelector, '', $attr );
1038 }
1039
1040 # tableBorderColor
104123µs if ( defined $inAttrs->{tableBorderColor} ) {
1042 my $attr;
1043 $attr = 'border-color:' . $inAttrs->{tableBorderColor};
1044 &$setAttribute( $tableSelector, '', $attr );
1045 $attr = 'border-top-color:' . $inAttrs->{tableBorderColor};
1046 &$setAttribute( $tableSelector, '', $attr );
1047 $attr = 'border-bottom-color:' . $inAttrs->{tableBorderColor};
1048 &$setAttribute( $tableSelector, '', $attr );
1049 $attr = 'border-left-color:' . $inAttrs->{tableBorderColor};
1050 &$setAttribute( $tableSelector, '', $attr );
1051 $attr = 'border-right-color:' . $inAttrs->{tableBorderColor};
1052 &$setAttribute( $tableSelector, '', $attr );
1053 }
1054
1055 # cellSpacing
105623µs if ( defined $inAttrs->{cellspacing} ) {
1057
1058 # do not use border-collapse:collapse
1059 my $attr = 'border-collapse:separate';
1060 &$setAttribute( $tableSelector, '', $attr );
1061 }
1062
1063 # cellpadding
106423µs if ( defined $inAttrs->{cellpadding} ) {
1065 my $attr = 'padding:' . addDefaultSizeUnit( $inAttrs->{cellpadding} );
1066 &$setAttribute( $tableSelector, 'td', $attr );
1067 &$setAttribute( $tableSelector, 'th', $attr );
1068 }
1069
1070 # cellborder
107123µs if ( defined $inAttrs->{cellBorder} ) {
1072 my $cellBorderWidth = $inAttrs->{cellBorder} || 0;
1073 my $attr = 'border-width:' . addDefaultSizeUnit($cellBorderWidth);
1074 &$setAttribute( $tableSelector, 'td', $attr );
1075 &$setAttribute( $tableSelector, 'th', $attr );
1076 }
1077
1078 # tablewidth
107923µs if ( defined $inAttrs->{width} ) {
1080 my $width = addDefaultSizeUnit( $inAttrs->{width} );
1081 my $attr = 'width:' . $width;
1082 &$setAttribute( $tableSelector, '', $attr );
1083 }
1084
1085 # valign
108625µs if ( defined $inAttrs->{vAlign} ) {
108713µs my $attr = 'vertical-align:' . $inAttrs->{vAlign};
108815µs118µs &$setAttribute( $tableSelector, 'td', $attr );
108915µs117µs &$setAttribute( $tableSelector, 'th', $attr );
1090 }
1091
1092 # headerVAlign
109323µs if ( defined $inAttrs->{headerVAlign} ) {
1094 my $attr = 'vertical-align:' . $inAttrs->{headerVAlign};
1095 &$setAttribute( $tableSelector, 'th', $attr );
1096 }
1097
1098 # dataVAlign
109923µs if ( defined $inAttrs->{dataVAlign} ) {
1100 my $attr = 'vertical-align:' . $inAttrs->{dataVAlign};
1101 &$setAttribute( $tableSelector, 'td', $attr );
1102 }
1103
1104 # headerbg
110524µs if ( defined $inAttrs->{headerBg} ) {
1106112µs12µs my $color =
1107 ( $inAttrs->{headerBg} =~ /none/i )
1108 ? 'transparent'
1109 : $inAttrs->{headerBg};
111013µs my $attr = 'background-color:' . $color;
111115µs118µs &$setAttribute( $tableSelector, 'th', $attr );
1112 }
1113
1114 # headerbgsorted
111524µs if ( defined $inAttrs->{headerBgSorted} ) {
1116110µs12µs my $color =
1117 ( $inAttrs->{headerBgSorted} =~ /none/i )
1118 ? 'transparent'
1119 : $inAttrs->{headerBgSorted};
112013µs my $attr = 'background-color:' . $color;
112115µs118µs &$setAttribute( $tableSelector, 'th.foswikiSortedCol', $attr );
1122 }
1123
1124 # headercolor
112524µs if ( defined $inAttrs->{headerColor} ) {
112612µs my $attr = 'color:' . $inAttrs->{headerColor};
112715µs117µs &$setAttribute( $tableSelector, 'th', $attr );
112815µs118µs &$setAttribute( $tableSelector, 'th a:link', $attr );
112915µs118µs &$setAttribute( $tableSelector, 'th a:visited', $attr );
113015µs117µs &$setAttribute( $tableSelector, 'th a:xhover', $attr )
1131 ; # just to make sorting work: hover should be last. below we will remove the x again.
113213µs if ( defined $inAttrs->{headerBg} ) {
113312µs my $hoverBackgroundColor = $inAttrs->{headerBg};
113412µs $attr = 'background-color:' . $hoverBackgroundColor;
113515µs118µs &$setAttribute( $tableSelector, 'th a:xhover', $attr );
1136 }
1137 }
1138
1139 # databg (array)
114025µs if ( defined $inAttrs->{dataBgListRef} ) {
114126µs my @dataBg = @{ $inAttrs->{dataBgListRef} };
114219µs12µs my $noneColor = ( $dataBg[0] =~ /none/i ) ? 'transparent' : '';
114311µs my $count = 0;
114414µs foreach my $color (@dataBg) {
114522µs $color = $noneColor if $noneColor;
114622µs next if !$color;
114725µs my $rowSelector = 'foswikiTableRow' . 'dataBg' . $count;
114824µs my $attr = "background-color:$color";
1149211µs238µs &$setAttribute( $tableSelector, "tr.$rowSelector td", $attr );
115027µs $count++;
1151 }
1152 }
1153
1154 # databgsorted (array)
115524µs if ( defined $inAttrs->{dataBgSortedListRef} ) {
115625µs my @dataBgSorted = @{ $inAttrs->{dataBgSortedListRef} };
115719µs12µs my $noneColor = ( $dataBgSorted[0] =~ /none/i ) ? 'transparent' : '';
115811µs my $count = 0;
115914µs foreach my $color (@dataBgSorted) {
116023µs $color = $noneColor if $noneColor;
116122µs next if !$color;
116225µs my $rowSelector = 'foswikiTableRow' . 'dataBg' . $count;
116323µs my $attr = "background-color:$color";
1164211µs237µs &$setAttribute( $tableSelector,
1165 "tr.$rowSelector td.foswikiSortedCol", $attr );
116626µs $count++;
1167 }
1168 }
1169
1170 # datacolor (array)
117123µs if ( defined $inAttrs->{dataColorListRef} ) {
1172 my @dataColor = @{ $inAttrs->{dataColorListRef} };
1173 unless ( $dataColor[0] =~ /none/i ) {
1174 my $count = 0;
1175 foreach my $color (@dataColor) {
1176 next if !$color;
1177 my $rowSelector = 'foswikiTableRow' . 'dataColor' . $count;
1178 my $attr = "color:$color";
1179 &$setAttribute( $tableSelector, "tr.$rowSelector td", $attr );
1180 $count++;
1181 }
1182 }
1183 }
1184
1185 # columnwidths
118623µs if ( defined $inAttrs->{columnWidthsListRef} ) {
1187 my @columnWidths = @{ $inAttrs->{columnWidthsListRef} };
1188 my $count = 0;
1189 foreach my $width (@columnWidths) {
1190 next if !$width;
1191 $width = addDefaultSizeUnit($width);
1192 my $colSelector = 'foswikiTableCol';
1193 $colSelector .= $count;
1194 my $attr = 'width:' . $width;
1195 &$setAttribute( $tableSelector, "td.$colSelector", $attr );
1196 &$setAttribute( $tableSelector, "th.$colSelector", $attr );
1197 $count++;
1198 }
1199 }
1200
1201 # headeralign
120223µs if ( defined $inAttrs->{headerAlignListRef} ) {
1203 my @headerAlign = @{ $inAttrs->{headerAlignListRef} };
1204 if ( scalar @headerAlign == 1 ) {
1205 my $align = $headerAlign[0];
1206 my $attr = 'text-align:' . $align;
1207 &$setAttribute( $tableSelector, 'th', $attr );
1208 }
1209 else {
1210 my $count = 0;
1211 foreach my $align (@headerAlign) {
1212 next if !$align;
1213 my $colSelector = 'foswikiTableCol';
1214 $colSelector .= $count;
1215 my $attr = 'text-align:' . $align;
1216 &$setAttribute( $tableSelector, "th.$colSelector", $attr );
1217 $count++;
1218 }
1219 }
1220 }
1221
1222 # dataAlign
122323µs if ( defined $inAttrs->{dataAlignListRef} ) {
1224 my @dataAlign = @{ $inAttrs->{dataAlignListRef} };
1225 if ( scalar @dataAlign == 1 ) {
1226 my $align = $dataAlign[0];
1227 my $attr = 'text-align:' . $align;
1228 &$setAttribute( $tableSelector, 'td', $attr );
1229 }
1230 else {
1231 my $count = 0;
1232 foreach my $align (@dataAlign) {
1233 next if !$align;
1234 my $colSelector = 'foswikiTableCol';
1235 $colSelector .= $count;
1236 my $attr = 'text-align:' . $align;
1237 &$setAttribute( $tableSelector, "td.$colSelector", $attr );
1238 $count++;
1239 }
1240 }
1241 }
1242
124324µs my @styles = ();
1244442µ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
12461222µs my $selectors =
12471241µs join( '; ', @{ $_styles->{$tableSelector}->{$selector} } );
12481282µs1225µ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
12501250µs if ( $selector eq '#' ) {
125114µs push @styles, "$tableSelector {$selectors}";
1252 }
1253 else {
12541129µs push @styles, "$tableSelector $selector {$selectors}";
1255 }
1256 }
1257 }
1258
1259240µs return ( $id, @styles );
1260}
1261
1262
# spent 3.26ms (29µs+3.23) within Foswiki::Plugins::TablePlugin::Core::_addHeadStyles which was called: # once (29µs+3.23ms) by Foswiki::Plugins::TablePlugin::Core::_addDefaultStyles at line 156
sub _addHeadStyles {
126315µs my ( $inId, @inStyles ) = @_;
1264
126512µs return if !scalar @inStyles;
1266
126714µs $styles->{seendIds}->{$inId} = 1;
126818µs if ( $inId eq $HEAD_ID_DEFAULT_STYLE ) {
126913µs $styles->{$HEAD_ID_DEFAULT_STYLE}->{'default'} = \@inStyles;
127016µs13.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 {
129412µs my ( $inId, $inStyles ) = @_;
1295
129612µs my @allStyles = ();
1297217µ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 }
130016µs my $styleText = join( "\n", @allStyles );
1301
130214µs my $header = <<EOS;
1303<style type="text/css" media="all">
1304$styleText
1305</style>
1306EOS
130713.10ms33.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
1308115µs168µ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 {
132012µs my ($inSize) = @_;
1321
132212µs my $unit = '';
1323121µs28µs if ( $inSize =~ m/$PATTERN_ATTRIBUTE_SIZE/ ) {
132413µs $unit = 'px' if !$2;
1325 }
132619µs return "$inSize$unit";
1327}
1328
1329
# spent 14.8ms (2.66+12.2) within Foswiki::Plugins::TablePlugin::Core::emitTable which was called 2 times, avg 7.40ms/call: # 2 times (2.66ms+12.2ms) by Foswiki::Plugins::TablePlugin::Core::handler at line 1898, avg 7.40ms/call
sub emitTable {
1330
1331214µs24.34ms _addDefaultStyles();
# spent 4.34ms making 2 calls to Foswiki::Plugins::TablePlugin::Core::_addDefaultStyles, avg 2.17ms/call
1332
1333211µs232µ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
133625µs if ( $combinedTableAttrs->{headerrows} > scalar @curTable ) {
1337 $combinedTableAttrs->{headerrows} =
1338 scalar @curTable; # limit header to size of table!
1339 }
134025µs if ( $combinedTableAttrs->{headerrows} + $combinedTableAttrs->{footerrows} >
1341 @curTable )
1342 {
1343 $combinedTableAttrs->{footerrows} = scalar @curTable -
1344 $combinedTableAttrs->{headerrows}; # and footer to whatever is left
1345 }
1346
134727µs my $sortThisTable =
1348 ( !defined $combinedTableAttrs->{sortAllTables}
1349 || $combinedTableAttrs->{sortAllTables} == 0 )
1350 ? 0
1351 : $combinedTableAttrs->{sort};
1352
135326µs if ( $combinedTableAttrs->{headerrows} == 0 ) {
1354214µs2223µ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
135725µs $combinedTableAttrs->{headerrows} = $headerRowCount;
135824µs $combinedTableAttrs->{footerrows} = $footerRowCount;
1359 }
1360
136124µs my $tableTagAttributes = {};
136226µs $tableTagAttributes->{class} = $combinedTableAttrs->{class};
136326µs $tableTagAttributes->{border} = $combinedTableAttrs->{border};
136426µs $tableTagAttributes->{cellspacing} = $combinedTableAttrs->{cellspacing};
136524µs $tableTagAttributes->{cellpadding} = $combinedTableAttrs->{cellpadding};
136624µs $tableTagAttributes->{id} = $combinedTableAttrs->{id}
1367 || undef;
136826µs $tableTagAttributes->{summary} = $combinedTableAttrs->{summary};
136924µs $tableTagAttributes->{frame} = $combinedTableAttrs->{frame};
137026µs $tableTagAttributes->{rules} = $combinedTableAttrs->{rules};
137124µs $tableTagAttributes->{width} = $combinedTableAttrs->{width};
1372
1373 # remove empty attributes
137422129µs while ( my ( $key, $value ) = each %{$tableTagAttributes} ) {
13751829µs delete $tableTagAttributes->{$key} if !defined $value || $value eq '';
1376 }
1377
1378224µs2584µ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
137924µs $text .= $currTablePre . CGI::caption( $combinedTableAttrs->{tableCaption} )
1380 if $combinedTableAttrs->{tableCaption};
1381
1382 # count the number of cols to prevent looping over non-existing columns
138323µs my $maxCols = 0;
1384
1385 # Flush out any remaining rowspans
1386210µs for ( my $i = 0 ; $i < @rowspan ; $i++ ) {
1387 if ( defined( $rowspan[$i] ) && $rowspan[$i] ) {
1388 my $nRows = scalar(@curTable);
1389 my $rspan = $rowspan[$i] + 1;
1390 my $r = $nRows - $rspan;
1391 $curTable[$r][$i]->{attrs} ||= {};
1392 if ( $rspan > 1 ) {
1393 $curTable[$r][$i]->{attrs}->{rowspan} = $rspan;
1394 }
1395 }
1396 }
1397
139825µs if (
1399 (
1400 $sortThisTable
1401 && defined $sortCol
1402 && defined $requestedTable
1403 && $requestedTable == $tableCount
1404 )
1405 || defined $combinedTableAttrs->{initSort}
1406 )
1407 {
1408
1409 # DG 08 Aug 2002: Allow multi-line headers
1410 my @header = splice( @curTable, 0, $combinedTableAttrs->{headerrows} );
1411
1412 # DG 08 Aug 2002: Skip sorting any trailers as well
1413 my @trailer = ();
1414 if ( $combinedTableAttrs->{footerrows}
1415 && scalar(@curTable) > $combinedTableAttrs->{footerrows} )
1416 {
1417 @trailer = splice( @curTable, -$combinedTableAttrs->{footerrows} );
1418 }
1419
1420 # Count the maximum number of columns of this table
1421 for my $row ( 0 .. $#curTable ) {
1422 my $thisRowMaxColCount = 0;
1423 for my $col ( 0 .. $#{ $curTable[$row] } ) {
1424 $thisRowMaxColCount++;
1425 }
1426 $maxCols = $thisRowMaxColCount
1427 if ( $thisRowMaxColCount > $maxCols );
1428 }
1429
1430 # Handle multi-row labels by killing rowspans in sorted tables
1431 for my $row ( 0 .. $#curTable ) {
1432 for my $col ( 0 .. $#{ $curTable[$row] } ) {
1433
1434 # SMELL: why do we need to specify a rowspan of 1?
1435 $curTable[$row][$col]->{attrs}->{rowspan} = 1;
1436 if ( $curTable[$row][$col]->{type} eq 'Y' ) {
1437 $curTable[$row][$col]->{text} =
1438 $curTable[ $row - 1 ][$col]->{text};
1439 $curTable[$row][$col]->{type} = 'td';
1440 }
1441 }
1442 }
1443
1444 # url requested sort on column beyond end of table. Force to last column
1445 $sortCol = 0 unless ( $sortCol =~ m/^[0-9]+$/ );
1446 $sortCol = $maxCols - 1 if ( $sortCol >= $maxCols );
1447
1448 # only get the column type if within bounds
1449 if ( $sortCol < $maxCols ) {
1450 _setSortTypeForCells( $sortCol, \@curTable );
1451 }
1452
1453 _debug("currentSortDirection:$currentSortDirection");
1454
1455 if ( $combinedTableAttrs->{sort}
1456 && $currentSortDirection == $SORT_DIRECTION->{'ASCENDING'} )
1457 {
1458 @curTable = sort {
1459 $a->[$sortCol]->{sortText} cmp $b->[$sortCol]->{sortText}
1460 || $a->[$sortCol]->{number} <=> $b->[$sortCol]->{number}
1461 || $a->[$sortCol]->{dateString}
1462 cmp $b->[$sortCol]->{dateString}
1463 } @curTable;
1464 }
1465 elsif ($combinedTableAttrs->{sort}
1466 && $currentSortDirection == $SORT_DIRECTION->{'DESCENDING'} )
1467 {
1468 @curTable = sort {
1469 $b->[$sortCol]->{sortText} cmp $a->[$sortCol]->{sortText}
1470 || $b->[$sortCol]->{number} <=> $a->[$sortCol]->{number}
1471 || $b->[$sortCol]->{dateString}
1472 cmp $a->[$sortCol]->{dateString}
1473 } @curTable;
1474 }
1475
1476 # DG 08 Aug 2002: Cleanup after the header/trailer splicing
1477 # this is probably awfully inefficient - but how big is a table?
1478 @curTable = ( @header, @curTable, @trailer );
1479 } # if defined $sortCol ...
1480
148125µs my $rowCount = 0;
148224µs my $numberOfRows = scalar(@curTable);
148323µs my $dataColorCount = 0;
1484
148526µs my @headerRowList = ();
148623µs my @bodyRowList = ();
148723µs my @footerRowList = ();
1488
148923µs my $isPastHeaderRows = 0;
149025µs my $singleIndent = "\n\t";
149124µs my $doubleIndent = "\n\t\t";
149226µs my $tripleIndent = "\n\t\t\t";
1493
1494 # Only *one* row of the table has sort links, and it will either
1495 # be the last row in the header or the first row in the footer.
149623µs my $sortLinksWritten = 0;
1497
149828µs foreach my $row (@curTable) {
1499812µs my $rowtext = '';
1500811µs my $colCount = 0;
1501
1502 # keep track of header cells: if all cells are header cells, do not
1503 # update the data color count
1504810µs my $headerCellCount = 0;
1505812µs my $numberOfCols = scalar(@$row);
1506810µs my $writingSortLinks = 0;
1507
1508825µs foreach my $fcell (@$row) {
1509
1510 # check if cell exists
15112239µs next if ( !$fcell || !$fcell->{type} );
1512
15132232µs my $tableAnchor = '';
1514 next
15152234µs if ( $fcell->{type} eq 'X' )
1516 ; # data was there so sort could work with col spanning
15172232µs my $type = $fcell->{type};
15182234µs my $cell = $fcell->{text};
15192233µs my $attr = $fcell->{attrs} || {};
1520
15212227µs my $newDirection;
15222227µs my $isSorted = 0;
1523
15242265µ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 {
153922123µs2296µs $newDirection = _getDefaultSortDirection();
# spent 96µs making 22 calls to Foswiki::Plugins::TablePlugin::Core::_getDefaultSortDirection, avg 4µs/call
1540 }
1541
15422257µs if ( $type eq 'th' ) {
15431114µs $headerCellCount++;
1544
1545 # html attribute: bgcolor
15461118µs if ( $combinedTableAttrs->{generateInlineMarkup}
1547 && defined $combinedTableAttrs->{headerBg} )
1548 {
1549 $attr->{bgcolor} = $combinedTableAttrs->{headerBg}
1550 unless ( $combinedTableAttrs->{headerBg} =~ /none/i );
1551 }
1552
1553 # END html attribute
1554
15551114µs if ($isSorted) {
1556 if ( $currentSortDirection ==
1557 $SORT_DIRECTION->{'ASCENDING'} )
1558 {
1559 $tableAnchor = $CHAR_SORT_ASCENDING;
1560 }
1561 if ( $currentSortDirection ==
1562 $SORT_DIRECTION->{'DESCENDING'} )
1563 {
1564 $tableAnchor = $CHAR_SORT_DESCENDING;
1565 }
1566
1567 # html attribute: (sorted header cell) bgcolor
1568 # overrides earlier set bgcolor
1569 if ( $combinedTableAttrs->{generateInlineMarkup}
1570 && defined $combinedTableAttrs->{headerBgSorted} )
1571 {
1572 $attr->{bgcolor} = $combinedTableAttrs->{headerBgSorted}
1573 unless (
1574 $combinedTableAttrs->{headerBgSorted} =~ /none/i );
1575 }
1576
1577 # END html attribute
1578 }
1579
15801117µs if (
1581 defined $sortCol
1582 && $colCount == $sortCol
1583 && defined $requestedTable
1584 && $requestedTable == $tableCount
1585 && ( $combinedTableAttrs->{headerrows}
1586 || $combinedTableAttrs->{footerrows} )
1587 )
1588 {
1589
1590 $tableAnchor =
1591 CGI::a( { name => 'sorted_table' }, '<!-- -->' )
1592 . $tableAnchor;
1593 }
1594
1595 # html attribute: headercolor (font style)
15961117µs if ( $combinedTableAttrs->{generateInlineMarkup}
1597 && defined $combinedTableAttrs->{headerColor} )
1598 {
1599 my $fontStyle =
1600 { color => $combinedTableAttrs->{headerColor} };
1601 $cell = CGI::font( $fontStyle, $cell );
1602 }
1603
1604 # END html attribute
1605
16061126µs if (
1607 $sortThisTable
1608 && (
1609 ( $rowCount == $combinedTableAttrs->{headerrows} - 1 )
1610 || ( !$combinedTableAttrs->{headerrows}
1611 && $rowCount ==
1612 $numberOfRows - $combinedTableAttrs->{footerrows} )
1613 )
1614 && ( $writingSortLinks || !$sortLinksWritten )
1615 )
1616 {
1617 $writingSortLinks = 1;
1618 my $linkAttributes = {
1619 href => $url
1620 . 'sortcol='
1621 . $colCount
1622 . ';table='
1623 . $tableCount . ';up='
1624 . $newDirection
1625 . '#sorted_table',
1626 rel => 'nofollow',
1627 title => 'Sort by this column'
1628 };
1629
1630 if ( $cell =~ /\[\[|href/o ) {
1631 $cell .= CGI::a( $linkAttributes, $CHAR_SORT_BOTH )
1632 . $tableAnchor;
1633 }
1634 else {
1635 $cell = CGI::a( $linkAttributes, $cell ) . $tableAnchor;
1636 }
1637 }
1638
1639 }
1640 else {
1641
16421118µs $type = 'td' unless $type eq 'Y';
1643
1644 # html attribute: bgcolor
16451118µs if ( $combinedTableAttrs->{generateInlineMarkup} ) {
1646 if ( $isSorted
1647 && defined $combinedTableAttrs->{dataBgSortedListRef} )
1648 {
1649 my @dataBg =
1650 @{ $combinedTableAttrs->{dataBgSortedListRef} };
1651
1652 unless ( $dataBg[0] =~ /none/ ) {
1653 $attr->{bgcolor} =
1654 $dataBg[ $dataColorCount % ( $#dataBg + 1 ) ];
1655 }
1656 }
1657 elsif ( defined $combinedTableAttrs->{dataBgListRef} ) {
1658 my @dataBg = @{ $combinedTableAttrs->{dataBgListRef} };
1659 unless ( $dataBg[0] =~ /none/i ) {
1660 $attr->{bgcolor} =
1661 $dataBg[ $dataColorCount % ( $#dataBg + 1 ) ];
1662 }
1663 }
1664 }
1665
1666 # END html attribute
1667
1668 # html attribute: datacolor (font style)
16691117µs if ( $combinedTableAttrs->{generateInlineMarkup}
1670 && defined $combinedTableAttrs->{dataColorListRef} )
1671 {
1672 my @dataColor =
1673 @{ $combinedTableAttrs->{dataColorListRef} };
1674 my $color =
1675 $dataColor[ $dataColorCount % ( $#dataColor + 1 ) ];
1676 unless ( $color =~ /^(none)$/i ) {
1677 my $cellAttrs = { color => $color };
1678 $cell = CGI::font( $cellAttrs, ' ' . $cell . ' ' );
1679 }
1680 }
1681
1682 # END html attribute
1683
1684 } ###if( $type eq 'th' )
1685
16862224µs if ($isSorted) {
1687 $attr->{class} = _appendSortedCssClass( $attr->{class} );
1688 }
1689
16902221µs if ($writingSortLinks) {
1691 $sortLinksWritten = 1;
1692 }
1693
16942244µs my $isLastRow = ( $rowCount == $numberOfRows - 1 );
16952231µs if ( $attr->{rowspan} ) {
1696 $isLastRow =
1697 ( ( $rowCount + ( $attr->{rowspan} - 1 ) ) ==
1698 $numberOfRows - 1 );
1699 }
1700
1701 # CSS class name
17022270µs8159µ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;
17042233µs my $isLastCol = ( $colCount == $numberOfCols - 1 );
17052268µs8229µ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
17082259µs7131µ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
17112227µs $colCount++;
17122228µs next if ( $type eq 'Y' );
17132238µs 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
171522235µs223.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
1721812µs my $trClassName = '';
1722
1723 # just 2 css names is too limited, but we will keep it for compatibility
1724 # with existing style sheets
1725816µs my $rowTypeName =
1726 ( $rowCount % 2 ) ? 'foswikiTableEven' : 'foswikiTableOdd';
1727843µs868µs $trClassName = _appendToClassList( $trClassName, $rowTypeName );
# spent 68µs making 8 calls to Foswiki::Plugins::TablePlugin::Core::_appendToClassList, avg 8µs/call
1728
1729826µs if ( $combinedTableAttrs->{dataBgSortedListRef} ) {
17301644µs my @dataBgSorted = @{ $combinedTableAttrs->{dataBgSortedListRef} };
1731818µs my $modRowNum = $dataColorCount % ( $#dataBgSorted + 1 );
1732846µs8170µ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 }
1736825µs if ( $combinedTableAttrs->{dataBgListRef} ) {
17371643µs my @dataBg = @{ $combinedTableAttrs->{dataBgListRef} };
1738816µs my $modRowNum = $dataColorCount % ( $#dataBg + 1 );
1739843µs8159µs $trClassName =
# spent 159µs making 8 calls to Foswiki::Plugins::TablePlugin::Core::_appendRowNumberCssClass, avg 20µs/call
1740 _appendRowNumberCssClass( $trClassName, 'dataBg', $modRowNum );
1741 }
1742814µs if ( $combinedTableAttrs->{dataColorListRef} ) {
1743 my @dataColor = @{ $combinedTableAttrs->{dataColorListRef} };
1744 my $modRowNum = $dataColorCount % ( $#dataColor + 1 );
1745 $trClassName =
1746 _appendRowNumberCssClass( $trClassName, 'dataColor', $modRowNum );
1747 }
1748810µs $rowtext .= $doubleIndent;
1749868µs81.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
1752817µs my $isHeaderRow =
1753 $rowCount <
1754 $combinedTableAttrs->{headerrows}; #( $headerCellCount == $colCount );
1755816µs my $isFooterRow =
1756 ( ( $numberOfRows - $rowCount ) <=
1757 $combinedTableAttrs->{footerrows} );
1758
1759820µs if ( !$isHeaderRow && !$isFooterRow ) {
1760
1761 # don't include non-adjacent header rows to the top block of header rows
1762710µs $isPastHeaderRows = 1;
1763 }
1764
1765820µs if ($isFooterRow) {
1766 push @footerRowList, $rowHTML;
1767 }
1768 elsif ( $isHeaderRow && !$isPastHeaderRows ) {
176912µs push( @headerRowList, $rowHTML );
1770 }
1771 else {
1772715µs push @bodyRowList, $rowHTML;
177379µs $dataColorCount++;
1774 }
1775
1776811µs if ($isHeaderRow) {
1777
1778 # reset data color count to start with first color after
1779 # each table heading
178012µs $dataColorCount = 0;
1781 }
1782
1783850µs $rowCount++;
1784 } # foreach my $row ( @curTable )
1785
1786213µs my $thead =
1787 "$singleIndent<thead>"
1788 . join( "", @headerRowList )
1789 . "$singleIndent</thead>";
179025µs $text .= $currTablePre . $thead if scalar @headerRowList;
1791
179226µs my $tfoot =
1793 "$singleIndent<tfoot>"
1794 . join( "", @footerRowList )
1795 . "$singleIndent</tfoot>";
179623µs $text .= $currTablePre . $tfoot if scalar @footerRowList;
1797
179823µs my $tbody;
179926µs if ( scalar @bodyRowList ) {
1800214µs $tbody =
1801 "$singleIndent<tbody>"
1802 . join( "", @bodyRowList )
1803 . "$singleIndent</tbody>";
1804 }
1805 else {
1806
1807 # A HTML table requires a body, which cannot be empty (Item8991).
1808 # So we provide one, but prevent it from being displayed.
1809 $tbody =
1810"$singleIndent<tbody>$doubleIndent<tr style=\"display:none;\">$tripleIndent<td></td>$doubleIndent</tr>$singleIndent</tbody>\n";
1811 }
1812216µs $text .= $currTablePre . $tbody;
1813
1814220µs2310µ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
1817214µs2304µs _resetReusedVariables();
# spent 304µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::_resetReusedVariables, avg 152µs/call
1818
1819221µs return $text;
1820}
1821
1822
# spent 26.7ms (3.86+22.8) within Foswiki::Plugins::TablePlugin::Core::handler which was called 5 times, avg 5.33ms/call: # 5 times (3.86ms+22.8ms) by Foswiki::Plugins::TablePlugin::preRenderingHandler at line 67 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TablePlugin.pm, avg 5.33ms/call
sub handler {
1823 ### my ( $text, $removed ) = @_;
1824
1825542µs5133µs _debug('handler');
# spent 133µs making 5 calls to Foswiki::Plugins::TablePlugin::Core::_debug, avg 27µs/call
1826
182759µs unless ($Foswiki::Plugins::TablePlugin::initialised) {
182812µs $insideTABLE = 0;
1829
1830 # Even if $tableCount is initialized already at plugin init
1831 # we need to reset it again each time preRenderingHandler
1832 # calls this handler sub. Important for initialiseWhenRender API
183311µs $tableCount = 0;
1834
183518µs132µs my $cgi = Foswiki::Func::getCgiQuery();
# spent 32µs making 1 call to Foswiki::Func::getCgiQuery
183611µs return unless $cgi;
1837
1838 # Copy existing values
183912µs my ( @origSort, @origTable, @origUp );
184018µs159µs @origSort = $cgi->param('sortcol');
# spent 59µs making 1 call to Foswiki::Request::param
184116µs144µs @origTable = $cgi->param('table');
# spent 44µs making 1 call to Foswiki::Request::param
184215µs141µs @origUp = $cgi->param('up'); # NOTE: internal parameter
# spent 41µs making 1 call to Foswiki::Request::param
1843112µs126µs $cgi->delete( 'sortcol', 'table', 'up' );
# spent 26µs making 1 call to Foswiki::Request::delete
1844113µs1322µs $url = $cgi->url( -absolute => 1, -path => 1 ) . '?';
# spent 322µs making 1 call to Foswiki::Request::url
184516µs151µs my $queryString = $cgi->query_string();
# spent 51µs making 1 call to Foswiki::Request::queryString
184611µs $url .= $queryString . ';' if $queryString;
1847
1848 # Restore parameters, so we don't interfere on the remaining execution
184911µs $cgi->param( -name => 'sortcol', -value => \@origSort ) if @origSort;
185011µs $cgi->param( -name => 'table', -value => \@origTable ) if @origTable;
18511800ns $cgi->param( -name => 'up', -value => \@origUp ) if @origUp;
1852
185315µs145µs $sortColFromUrl =
# spent 45µs making 1 call to Foswiki::Request::param
1854 $cgi->param('sortcol'); # zero based: 0 is first column
185511µs if ( defined $sortColFromUrl && $sortColFromUrl !~ m/^[0-9]+$/ ) {
1856 $sortColFromUrl = 0;
1857 }
1858
185916µs144µs $requestedTable = $cgi->param('table');
# spent 44µs making 1 call to Foswiki::Request::param
186012µs $requestedTable = 0
1861 unless ( defined $requestedTable && $requestedTable =~ m/^[0-9]+$/ );
1862
186316µs144µs $up = $cgi->param('up');
# spent 44µs making 1 call to Foswiki::Request::param
1864
186511µs $sortTablesInText = 0;
186611µs $sortAttachments = 0;
186717µs1139µs my $tmp = Foswiki::Func::getPreferencesValue('TABLEPLUGIN_SORT')
# spent 139µs making 1 call to Foswiki::Func::getPreferencesValue
1868 || 'all';
1869116µs14µs if ( !$tmp || $tmp =~ /^all$/oi ) {
187012µs $sortTablesInText = 1;
187112µs $sortAttachments = 1;
1872 }
1873 elsif ( $tmp =~ /^attachments$/oi ) {
1874 $sortAttachments = 1;
1875 }
1876
187717µs11.04ms _initDefaults(); # first time
187813µs $Foswiki::Plugins::TablePlugin::initialised = 1;
1879 }
1880
1881513µs $insideTABLE = 0;
1882
1883517µs my $defaultSort = $combinedTableAttrs->{sortAllTables};
1884
188558µs my $acceptable = $combinedTableAttrs->{sortAllTables};
18865531µs my @lines = split( /\r?\n/, $_[0] );
1887521µs for (@lines) {
18881893.81ms5841.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
1889111µs21.35mss/$PATTERN_TABLE/_parseTableSpecificTableAttributes(Foswiki::Func::extractParameters($1))/se
1890 )
1891846µs83.43ms {
# spent 3.43ms making 8 calls to Foswiki::Plugins::TablePlugin::Core::_processTableRow, avg 429µs/call
189212µs $acceptable = 1;
1893 }
1894 elsif (s/^(\s*)\|(.*\|\s*)$/_processTableRow($1,$2)/eo) {
1895812µs $insideTABLE = 1;
1896 }
1897 elsif ($insideTABLE) {
1898230µs214.8ms $_ = emitTable() . $_;
# spent 14.8ms making 2 calls to Foswiki::Plugins::TablePlugin::Core::emitTable, avg 7.40ms/call
189923µs $insideTABLE = 0;
1900
190124µs $combinedTableAttrs->{sortAllTables} = $defaultSort;
190223µs $acceptable = $defaultSort;
1903 }
1904 }
19055228µs $_[0] = join( "\n", @lines );
1906
1907578µs 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 {
192148µs my ( $A, $B ) = @_;
1922
192348µs my %merged = ();
1924465µs while ( my ( $k, $v ) = each(%$A) ) {
19251424µs $merged{$k} = $v;
1926 }
19274177µs while ( my ( $k, $v ) = each(%$B) ) {
19284580µs $merged{$k} = $v;
1929 }
1930434µs 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 {
193823µs my ($inValue) = @_;
1939
194023µs return undef if !$inValue;
1941
1942218µs23µs $inValue =~ s/ //go; # remove spaces
# spent 3µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::CORE:subst, avg 2µs/call
1943214µs return $inValue;
1944}
1945
1946=pod
1947
1948=cut
1949
1950
# spent 95µs (91+4) within Foswiki::Plugins::TablePlugin::Core::_arrayRefFromParam which was called 12 times, avg 8µs/call: # 2 times (23µs+2µs) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 363, avg 13µs/call # 2 times (21µs+2µs) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 365, avg 11µs/call # 2 times (12µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 348, avg 6µs/call # 2 times (12µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 370, avg 6µs/call # 2 times (12µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 354, avg 6µs/call # 2 times (11µs+0s) by Foswiki::Plugins::TablePlugin::Core::_parseAttributes at line 351, avg 6µs/call
sub _arrayRefFromParam {
19511224µs my ($inValue) = @_;
1952
19531265µs return undef if !$inValue;
1954
1955215µs24µs $inValue =~ s/ //go; # remove spaces
# spent 4µs making 2 calls to Foswiki::Plugins::TablePlugin::Core::CORE:subst, avg 2µs/call
195627µs my @list = split( /,/, $inValue );
1957214µs 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