← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 19:05:14 2015
Reported on Fri Jul 31 19:08:10 2015

Filename/var/www/foswiki11/lib/Foswiki/Plugins/JQueryPlugin.pm
StatementsExecuted 37 statements in 1.54ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.25ms1.30msFoswiki::Plugins::JQueryPlugin::::BEGIN@15Foswiki::Plugins::JQueryPlugin::BEGIN@15
111101µs4.42msFoswiki::Plugins::JQueryPlugin::::initPluginFoswiki::Plugins::JQueryPlugin::initPlugin
11119µs94µsFoswiki::Plugins::JQueryPlugin::::handleJQueryThemeFoswiki::Plugins::JQueryPlugin::handleJQueryTheme
11115µs142µsFoswiki::Plugins::JQueryPlugin::::finishPluginFoswiki::Plugins::JQueryPlugin::finishPlugin
11114µs27µsFoswiki::Plugins::JQueryPlugin::::BEGIN@3Foswiki::Plugins::JQueryPlugin::BEGIN@3
11113µs19µsFoswiki::Plugins::JQueryPlugin::::BEGIN@4Foswiki::Plugins::JQueryPlugin::BEGIN@4
11110µs75µsFoswiki::Plugins::JQueryPlugin::::createThemeFoswiki::Plugins::JQueryPlugin::createTheme
1116µs19µsFoswiki::Plugins::JQueryPlugin::::registerPluginFoswiki::Plugins::JQueryPlugin::registerPlugin
1114µs4µsFoswiki::Plugins::JQueryPlugin::::BEGIN@14Foswiki::Plugins::JQueryPlugin::BEGIN@14
0000s0sFoswiki::Plugins::JQueryPlugin::::createPluginFoswiki::Plugins::JQueryPlugin::createPlugin
0000s0sFoswiki::Plugins::JQueryPlugin::::handleButtonFoswiki::Plugins::JQueryPlugin::handleButton
0000s0sFoswiki::Plugins::JQueryPlugin::::handleEndTabFoswiki::Plugins::JQueryPlugin::handleEndTab
0000s0sFoswiki::Plugins::JQueryPlugin::::handleEndTabPaneFoswiki::Plugins::JQueryPlugin::handleEndTabPane
0000s0sFoswiki::Plugins::JQueryPlugin::::handleJQueryIconFoswiki::Plugins::JQueryPlugin::handleJQueryIcon
0000s0sFoswiki::Plugins::JQueryPlugin::::handleJQueryIconPathFoswiki::Plugins::JQueryPlugin::handleJQueryIconPath
0000s0sFoswiki::Plugins::JQueryPlugin::::handleJQueryPluginsFoswiki::Plugins::JQueryPlugin::handleJQueryPlugins
0000s0sFoswiki::Plugins::JQueryPlugin::::handleJQueryRequireFoswiki::Plugins::JQueryPlugin::handleJQueryRequire
0000s0sFoswiki::Plugins::JQueryPlugin::::handlePopUpWindowFoswiki::Plugins::JQueryPlugin::handlePopUpWindow
0000s0sFoswiki::Plugins::JQueryPlugin::::handleTabFoswiki::Plugins::JQueryPlugin::handleTab
0000s0sFoswiki::Plugins::JQueryPlugin::::handleTabPaneFoswiki::Plugins::JQueryPlugin::handleTabPane
0000s0sFoswiki::Plugins::JQueryPlugin::::handleToggleFoswiki::Plugins::JQueryPlugin::handleToggle
0000s0sFoswiki::Plugins::JQueryPlugin::::registerThemeFoswiki::Plugins::JQueryPlugin::registerTheme
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
2package Foswiki::Plugins::JQueryPlugin;
3229µs241µs
# spent 27µs (14+14) within Foswiki::Plugins::JQueryPlugin::BEGIN@3 which was called: # once (14µs+14µs) by Foswiki::Plugin::BEGIN@2.20 at line 3
use strict;
# spent 27µs making 1 call to Foswiki::Plugins::JQueryPlugin::BEGIN@3 # spent 14µs making 1 call to strict::import
4231µs224µs
# spent 19µs (13+6) within Foswiki::Plugins::JQueryPlugin::BEGIN@4 which was called: # once (13µs+6µs) by Foswiki::Plugin::BEGIN@2.20 at line 4
use warnings;
# spent 19µs making 1 call to Foswiki::Plugins::JQueryPlugin::BEGIN@4 # spent 6µs making 1 call to warnings::import
5
6=begin TML
7
8---+ package Foswiki::Plugins::JQueryPlugin
9
10Container for jQuery and plugins
11
12=cut
13
14220µs14µs
# spent 4µs within Foswiki::Plugins::JQueryPlugin::BEGIN@14 which was called: # once (4µs+0s) by Foswiki::Plugin::BEGIN@2.20 at line 14
use Foswiki::Plugins ();
# spent 4µs making 1 call to Foswiki::Plugins::JQueryPlugin::BEGIN@14
1521.34ms11.30ms
# spent 1.30ms (1.25+45µs) within Foswiki::Plugins::JQueryPlugin::BEGIN@15 which was called: # once (1.25ms+45µs) by Foswiki::Plugin::BEGIN@2.20 at line 15
use Foswiki::Plugins::JQueryPlugin::Plugins ();
# spent 1.30ms making 1 call to Foswiki::Plugins::JQueryPlugin::BEGIN@15
16
171600nsour $VERSION = '4.91';
181100nsour $RELEASE = '4.91';
191200nsour $SHORTDESCRIPTION = 'jQuery <nop>JavaScript library for Foswiki';
201200nsour $NO_PREFS_IN_TOPIC = 1;
21
22=begin TML
23
24---++ initPlugin($topic, $web, $user) -> $boolean
25
26=cut
27
28
# spent 4.42ms (101µs+4.31) within Foswiki::Plugins::JQueryPlugin::initPlugin which was called: # once (101µs+4.31ms) by Foswiki::Plugin::__ANON__[/var/www/foswiki11/lib/Foswiki/Plugin.pm:241] at line 234 of /var/www/foswiki11/lib/Foswiki/Plugin.pm
sub initPlugin {
2912µs my ( $topic, $web, $user ) = @_;
30
31 # check for prerequisites
321800ns unless ( defined(&Foswiki::Func::addToZone) ) {
33 Foswiki::Func::writeWarning(
34 "ZonePlugin not installed/enabled...disabling JQueryPlugin");
35 return 0;
36 }
37
38111µs131µs Foswiki::Func::registerTagHandler( 'JQTHEME', \&handleJQueryTheme );
# spent 31µs making 1 call to Foswiki::Func::registerTagHandler
3914µs123µs Foswiki::Func::registerTagHandler( 'JQREQUIRE', \&handleJQueryRequire );
# spent 23µs making 1 call to Foswiki::Func::registerTagHandler
4014µs122µs Foswiki::Func::registerTagHandler( 'JQICON', \&handleJQueryIcon );
# spent 22µs making 1 call to Foswiki::Func::registerTagHandler
4113µs121µs Foswiki::Func::registerTagHandler( 'JQICONPATH', \&handleJQueryIconPath );
# spent 21µs making 1 call to Foswiki::Func::registerTagHandler
4214µs122µs Foswiki::Func::registerTagHandler( 'JQPLUGINS', \&handleJQueryPlugins );
# spent 22µs making 1 call to Foswiki::Func::registerTagHandler
43
44 # jquery.tabpane
4514µs122µs Foswiki::Func::registerTagHandler( 'TABPANE', \&handleTabPane );
# spent 22µs making 1 call to Foswiki::Func::registerTagHandler
4613µs120µs Foswiki::Func::registerTagHandler( 'ENDTABPANE', \&handleEndTabPane );
# spent 20µs making 1 call to Foswiki::Func::registerTagHandler
4712µs120µs Foswiki::Func::registerTagHandler( 'TAB', \&handleTab );
# spent 20µs making 1 call to Foswiki::Func::registerTagHandler
4812µs121µs Foswiki::Func::registerTagHandler( 'ENDTAB', \&handleEndTab );
# spent 21µs making 1 call to Foswiki::Func::registerTagHandler
49
50 # jquery.button
5114µs121µs Foswiki::Func::registerTagHandler( 'BUTTON', \&handleButton );
# spent 21µs making 1 call to Foswiki::Func::registerTagHandler
52
53 # jquery.popupwindow
5412µs123µs Foswiki::Func::registerTagHandler( 'POPUPWINDOW', \&handlePopUpWindow );
# spent 23µs making 1 call to Foswiki::Func::registerTagHandler
55
56 # init plugin handler and preload default plugins
5714µs14.06ms Foswiki::Plugins::JQueryPlugin::Plugins::init();
# spent 4.06ms making 1 call to Foswiki::Plugins::JQueryPlugin::Plugins::init
58
59 # backwards compatibility
60121µs113µs if ( $Foswiki::Plugins::VERSION < 2.1 ) {
# spent 13µs making 1 call to version::vxs::VCMP
61 Foswiki::Func::setPreferencesValue( "CLEAR",
62 "<span class='foswikiClear'></span>" );
63 }
64
6516µs return 1;
66}
67
68=begin TML
69
70finish up the plugins container
71
72=cut
73
74
# spent 142µs (15+128) within Foswiki::Plugins::JQueryPlugin::finishPlugin which was called: # once (15µs+128µs) by Foswiki::Plugin::invoke at line 294 of /var/www/foswiki11/lib/Foswiki/Plugin.pm
sub finishPlugin {
7519µs1128µs Foswiki::Plugins::JQueryPlugin::Plugins::finish();
# spent 128µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugins::finish
76}
77
78=begin TML
79
80---++ createPlugin($pluginName, ...) -> $plugin
81
82API to create a jQuery plugin. Instantiating it adds all required javascript
83and css files to the html page header.
84
85=cut
86
87sub createPlugin {
88 return Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin(@_);
89}
90
91=begin TML
92
93---++ createTheme($themeName) -> $boolean
94
95API to load a jQuery UI theme. Returns true if the theme has
96been loaded successfully.
97
98=cut
99
100
# spent 75µs (10+65) within Foswiki::Plugins::JQueryPlugin::createTheme which was called: # once (10µs+65µs) by Foswiki::Plugins::JQueryPlugin::handleJQueryTheme at line 283
sub createTheme {
101112µs165µs return Foswiki::Plugins::JQueryPlugin::Plugins::createTheme(@_);
102}
103
104=begin TML
105
106---++ registerPlugin($pluginName, $class) -> $plugin
107
108API to register a jQuery plugin. this is of use for other Foswiki plugins
109to register their javascript modules as a jQuery plugin. Registering a plugin 'foobar'
110will make it available via =%<nop>JQREQUIRE{"foobar"}%=.
111
112Class will default to 'Foswiki::Plugins::JQueryPlugin::FOOBAR,
113
114The FOOBAR.pm stub must be derived from Foswiki::Plugins::JQueryPlugin::PLUGIN class.
115
116=cut
117
118
# spent 19µs (6+13) within Foswiki::Plugins::JQueryPlugin::registerPlugin which was called: # once (6µs+13µs) by Foswiki::Plugins::TwistyPlugin::initPlugin at line 47 of /var/www/foswiki11/lib/Foswiki/Plugins/TwistyPlugin.pm
sub registerPlugin {
11916µs112µs return Foswiki::Plugins::JQueryPlugin::Plugins::registerPlugin(@_);
120}
121
122=begin TML
123
124---++ registerTheme($themeName, $url)
125
126API to register a jQuery theme. this is of use for other Foswiki plugins
127to register their theme. Registering a theme 'foobar'
128will make it available via =%<nop>JQTHEME{"foobar"}%=.
129
130The =$url= parameter will default to '%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/ui/$themeName/jquery-ui.css'.
131
132=cut
133
134sub registerTheme {
135 return Foswiki::Plugins::JQueryPlugin::Plugins::registerTheme(@_);
136}
137
138=begin TML
139
140---++ handleButton($session, $params, $topic, $web) -> $result
141
142Handles the =%<nop>BUTTON% tag.
143
144=cut
145
146sub handleButton {
147 my $session = shift;
148 my $plugin = createPlugin( 'Button', $session );
149 return $plugin->handleButton(@_) if $plugin;
150 return '';
151}
152
153=begin TML
154
155---++ handlePopUpWindow($session, $params, $topic, $web) -> $result
156
157Handles the =%<nop>POPUPWINDOW% tag.
158
159=cut
160
161sub handlePopUpWindow {
162 my $session = shift;
163 my $plugin = createPlugin( 'PopUpWindow', $session );
164 return $plugin->handlePopUpWindow(@_) if $plugin;
165 return '';
166}
167
168=begin TML
169
170---++ handleToggle($session, $params, $topic, $web) -> $result
171
172Handles the =%<nop>TOGGLE% tag.
173
174=cut
175
176sub handleToggle {
177 my $session = shift;
178 my $plugin = createPlugin( 'Toggle', $session );
179 return $plugin->handleToggle(@_) if $plugin;
180 return '';
181}
182
183=begin TML
184
185---++ handleTabPane($session, $params, $topic, $web) -> $result
186
187Handles the =%<nop>TABPANE% tag.
188
189=cut
190
191sub handleTabPane {
192 my $session = shift;
193 my $plugin = createPlugin( 'Tabpane', $session );
194 return $plugin->handleTabPane(@_) if $plugin;
195 return '';
196}
197
198=begin TML
199
200---++ handleTab($session, $params, $topic, $web) -> $result
201
202Handles the =%<nop>TAB% tag.
203
204=cut
205
206sub handleTab {
207 my $session = shift;
208 my $plugin = createPlugin( 'Tabpane', $session );
209 return $plugin->handleTab(@_) if $plugin;
210 return '';
211}
212
213=begin TML
214
215---++ handleEndTab($session, $params, $topic, $web) -> $result
216
217Handles the =%<nop>ENDTAB% tag.
218
219=cut
220
221sub handleEndTab {
222 my $session = shift;
223 my $plugin = createPlugin( 'Tabpane', $session );
224 return $plugin->handleEndTab(@_) if $plugin;
225 return '';
226}
227
228=begin TML
229
230---++ handleEndTabPane($session, $params, $topic, $web) -> $result
231
232Handles the =%<nop>ENDTABPANE% tag.
233
234=cut
235
236sub handleEndTabPane {
237 my $session = shift;
238 my $plugin = createPlugin( 'Tabpane', $session );
239 return $plugin->handleEndTabPane(@_) if $plugin;
240 return '';
241}
242
243=begin TML
244
245---++ handleJQueryRequire($session, $params, $topic, $web) -> $result
246
247Handles the =%<nop>JQREQUIRE% tag.
248
249=cut
250
251sub handleJQueryRequire {
252 my ( $session, $params, $theTopic, $theWeb ) = @_;
253
254 my $plugins = $params->{_DEFAULT} || '';
255 my $warn = Foswiki::Func::isTrue( $params->{warn}, 1 );
256 my $errorMsg = '';
257 foreach my $pluginName ( split( /\s*,\s*/, $plugins ) ) {
258 my $plugin = createPlugin( $pluginName, $session );
259 $errorMsg .=
260 "<div class='foswikiAlert'>Error: no such plugin $pluginName</div>"
261 if !$plugin && $warn;
262 }
263
264 return $errorMsg;
265}
266
267=begin TML
268
269---++ handleJQueryTheme($session, $params, $topic, $web) -> $result
270
271Handles the =%<nop>JQTHEME% tag.
272
273=cut
274
275
# spent 94µs (19+75) within Foswiki::Plugins::JQueryPlugin::handleJQueryTheme which was called: # once (19µs+75µs) by Foswiki::Func::__ANON__[/var/www/foswiki11/lib/Foswiki/Func.pm:611] at line 609 of /var/www/foswiki11/lib/Foswiki/Func.pm
sub handleJQueryTheme {
27612µs my ( $session, $params, $theTopic, $theWeb ) = @_;
277
27812µs my $themeName = $params->{_DEFAULT}
279 || $Foswiki::cfg{JQueryPlugin}{JQueryTheme};
280
2811900ns my $warn = $params->{warn} || '';
282
28314µs175µs return "<div class='foswikiAlert'>Error: no such theme $themeName</div>"
# spent 75µs making 1 call to Foswiki::Plugins::JQueryPlugin::createTheme
284 if !createTheme($themeName) && $warn ne 'off';
285
28616µs return '';
287}
288
289=begin TML
290
291---++ handleJQueryIconPath($session, $params, $topic, $web) -> $result
292
293Handles the =%<nop>JQICONPATH% tag.
294
295=cut
296
297sub handleJQueryIconPath {
298 my ( $session, $params, $theTopic, $theWeb ) = @_;
299
300 my $iconName = $params->{_DEFAULT} || '';
301 return Foswiki::Plugins::JQueryPlugin::Plugins::getIconUrlPath($iconName);
302}
303
304=begin TML
305
306---++ handleJQueryIcon($session, $params, $topic, $web) -> $result
307
308Handles the =%<nop>JQICON% tag.
309
310=cut
311
312sub handleJQueryIcon {
313 my ( $session, $params, $theTopic, $theWeb ) = @_;
314
315 my $iconName = $params->{_DEFAULT} || '';
316 my $iconAlt = $params->{alt} || $iconName;
317 my $iconTitle = $params->{title} || '';
318 my $iconFormat = $params->{format}
319 || '<img src=\'$iconPath\' class=\'$iconClass\' $iconAlt$iconTitle/>';
320 my $iconPath =
321 Foswiki::Plugins::JQueryPlugin::Plugins::getIconUrlPath($iconName);
322
323 return '' unless $iconPath;
324
325 my $iconClass = "foswikiIcon jqIcon";
326 $iconClass .= " $params->{class}" if $params->{class};
327
328 my $img = $iconFormat;
329 $img =~ s/\$iconPath/$iconPath/g;
330 $img =~ s/\$iconClass/$iconClass/g;
331 $img =~ s/\$iconAlt/alt='$iconAlt' /g if $iconAlt;
332 $img =~ s/\$iconTitle/title='$iconTitle' /g if $iconTitle;
333 $img =~ s/\$(iconAlt|iconTitle)//go;
334
335 return $img;
336}
337
338=begin TML
339
340---++ handleJQueryPlugins($session, $params, $topic, $web) -> $result
341
342Handles the =%<nop>JQPLUGINS% tag.
343
344=cut
345
346sub handleJQueryPlugins {
347 my ( $session, $params, $theTopic, $theWeb ) = @_;
348
349 my $thePlugin = $params->{_DEFAULT} || '';
350 my $theFormat = $params->{format};
351 my $theHeader = $params->{header} || '';
352 my $theFooter = $params->{footer} || '';
353 my $theSeparator = $params->{separator};
354 my $theTagFormat = $params->{tagformat};
355
356 $theFormat = ' 1 <a href="$homepage">$name</a> $active $version $author'
357 unless defined $theFormat;
358 $theSeparator = '$n'
359 unless defined $theSeparator;
360 $theTagFormat = '[[%SYSTEMWEB%.Var$tag][$tag]]'
361 unless defined $theTagFormat;
362
363 my @plugins =
364 Foswiki::Plugins::JQueryPlugin::Plugins::getPlugins($thePlugin);
365
366 my @result;
367 my $counter = 0;
368 foreach my $plugin (@plugins) {
369 my $summary = $plugin->getSummary();
370 $summary =~ s/^\s+//;
371 $summary =~ s/\s+$//;
372 my $tags = '';
373 if ( $theFormat =~ /\$tags/ ) {
374 my @tags = ();
375 foreach my $tag ( sort split( /\s*,\s*/, $plugin->{tags} ) ) {
376 my $line = $theTagFormat;
377 $line =~ s/\$tag/$tag/g;
378 push @tags, $line if $line;
379 }
380 $tags = join( ', ', @tags );
381 }
382 my $active =
383 defined( $plugin->{isInit} )
384 ? '<span class="foswikiAlert">(active)</span>'
385 : '';
386 my $line = Foswiki::Plugins::JQueryPlugin::Plugins::expandVariables(
387 $theFormat,
388 'index' => ( $counter + 1 ),
389 name => $plugin->{name},
390 version => $plugin->{version},
391 summary => $summary,
392 documentation => $plugin->{documentation},
393 author => $plugin->{author},
394 homepage => $plugin->{homepage},
395 tags => $tags,
396 active => $active,
397 );
398 next unless $line;
399 push @result, $line;
400 $counter++;
401 }
402
403 $theHeader =
404 Foswiki::Plugins::JQueryPlugin::Plugins::expandVariables( $theHeader,
405 counter => $counter, );
406 $theFooter =
407 Foswiki::Plugins::JQueryPlugin::Plugins::expandVariables( $theFooter,
408 counter => $counter, );
409 $theSeparator =
410 Foswiki::Plugins::JQueryPlugin::Plugins::expandVariables($theSeparator);
411
412 return $theHeader . join( $theSeparator, @result ) . $theFooter;
413}
414
41514µs1;
416__END__