Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/JQueryPlugin.pm |
Statements | Executed 36 statements in 3.00ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 2.19ms | 2.30ms | BEGIN@15 | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 182µs | 9.16ms | initPlugin | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 32µs | 107µs | registerPlugin | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 28µs | 36µs | BEGIN@3 | Foswiki::Plugins::JQueryPlugin::
2 | 1 | 1 | 27µs | 3.64ms | createPlugin | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 24µs | 235µs | modifyHeaderHandler | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 19µs | 162µs | BEGIN@17 | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 18µs | 37µs | BEGIN@4 | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 12µs | 110µs | createTheme | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 10µs | 10µs | BEGIN@14 | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleButton | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleEndTab | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleEndTabPane | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleJQueryIcon | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleJQueryIconPath | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleJQueryPlugins | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleJQueryRequire | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleJQueryTheme | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handlePopUpWindow | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleTab | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleTabPane | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleToggle | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | registerTheme | Foswiki::Plugins::JQueryPlugin::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | package Foswiki::Plugins::JQueryPlugin; | ||||
3 | 2 | 52µs | 2 | 45µs | # spent 36µs (28+8) within Foswiki::Plugins::JQueryPlugin::BEGIN@3 which was called:
# once (28µs+8µs) by Foswiki::Plugin::BEGIN@2.10 at line 3 # spent 36µs making 1 call to Foswiki::Plugins::JQueryPlugin::BEGIN@3
# spent 8µs making 1 call to strict::import |
4 | 2 | 60µs | 2 | 56µs | # spent 37µs (18+19) within Foswiki::Plugins::JQueryPlugin::BEGIN@4 which was called:
# once (18µs+19µs) by Foswiki::Plugin::BEGIN@2.10 at line 4 # spent 37µs making 1 call to Foswiki::Plugins::JQueryPlugin::BEGIN@4
# spent 19µs making 1 call to warnings::import |
5 | |||||
6 | =begin TML | ||||
7 | |||||
8 | ---+ package Foswiki::Plugins::JQueryPlugin | ||||
9 | |||||
10 | Container for jQuery and plugins | ||||
11 | |||||
12 | =cut | ||||
13 | |||||
14 | 2 | 39µs | 1 | 10µs | # spent 10µs within Foswiki::Plugins::JQueryPlugin::BEGIN@14 which was called:
# once (10µs+0s) by Foswiki::Plugin::BEGIN@2.10 at line 14 # spent 10µs making 1 call to Foswiki::Plugins::JQueryPlugin::BEGIN@14 |
15 | 2 | 184µs | 1 | 2.30ms | # spent 2.30ms (2.19+102µs) within Foswiki::Plugins::JQueryPlugin::BEGIN@15 which was called:
# once (2.19ms+102µs) by Foswiki::Plugin::BEGIN@2.10 at line 15 # spent 2.30ms making 1 call to Foswiki::Plugins::JQueryPlugin::BEGIN@15 |
16 | |||||
17 | 1 | 11µs | 1 | 143µs | # spent 162µs (19+143) within Foswiki::Plugins::JQueryPlugin::BEGIN@17 which was called:
# once (19µs+143µs) by Foswiki::Plugin::BEGIN@2.10 at line 20 # spent 143µs making 1 call to vars::import |
18 | $VERSION $RELEASE $SHORTDESCRIPTION | ||||
19 | $NO_PREFS_IN_TOPIC | ||||
20 | 1 | 2.43ms | 1 | 162µs | ); # spent 162µs making 1 call to Foswiki::Plugins::JQueryPlugin::BEGIN@17 |
21 | |||||
22 | 1 | 2µs | $VERSION = '$Rev$'; | ||
23 | 1 | 1µs | $RELEASE = '4.30'; | ||
24 | 1 | 1µs | $SHORTDESCRIPTION = 'jQuery <nop>JavaScript library for Foswiki'; | ||
25 | 1 | 1µs | $NO_PREFS_IN_TOPIC = 1; | ||
26 | |||||
27 | =begin TML | ||||
28 | |||||
29 | ---++ initPlugin($topic, $web, $user) -> $boolean | ||||
30 | |||||
31 | =cut | ||||
32 | |||||
33 | # spent 9.16ms (182µs+8.98) within Foswiki::Plugins::JQueryPlugin::initPlugin which was called:
# once (182µs+8.98ms) by Foswiki::Plugin::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugin.pm:235] at line 228 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugin.pm | ||||
34 | 1 | 4µs | my ( $topic, $web, $user ) = @_; | ||
35 | |||||
36 | # check for prerequisites | ||||
37 | 1 | 3µs | unless ( defined(&Foswiki::Func::addToZone) ) { | ||
38 | Foswiki::Func::writeWarning( | ||||
39 | "ZonePlugin not installed/enabled...disabling JQueryPlugin"); | ||||
40 | return 0; | ||||
41 | } | ||||
42 | |||||
43 | 1 | 23µs | 1 | 107µs | Foswiki::Func::registerTagHandler( 'JQTHEME', \&handleJQueryTheme ); # spent 107µs making 1 call to Foswiki::Func::registerTagHandler |
44 | 1 | 10µs | 1 | 60µs | Foswiki::Func::registerTagHandler( 'JQREQUIRE', \&handleJQueryRequire ); # spent 60µs making 1 call to Foswiki::Func::registerTagHandler |
45 | 1 | 7µs | 1 | 55µs | Foswiki::Func::registerTagHandler( 'JQICON', \&handleJQueryIcon ); # spent 55µs making 1 call to Foswiki::Func::registerTagHandler |
46 | 1 | 7µs | 1 | 55µs | Foswiki::Func::registerTagHandler( 'JQICONPATH', \&handleJQueryIconPath ); # spent 55µs making 1 call to Foswiki::Func::registerTagHandler |
47 | 1 | 9µs | 1 | 56µs | Foswiki::Func::registerTagHandler( 'JQPLUGINS', \&handleJQueryPlugins ); # spent 56µs making 1 call to Foswiki::Func::registerTagHandler |
48 | |||||
49 | # jquery.tabpane | ||||
50 | 1 | 10µs | 1 | 57µs | Foswiki::Func::registerTagHandler( 'TABPANE', \&handleTabPane ); # spent 57µs making 1 call to Foswiki::Func::registerTagHandler |
51 | 1 | 7µs | 1 | 56µs | Foswiki::Func::registerTagHandler( 'ENDTABPANE', \&handleEndTabPane ); # spent 56µs making 1 call to Foswiki::Func::registerTagHandler |
52 | 1 | 7µs | 1 | 54µs | Foswiki::Func::registerTagHandler( 'TAB', \&handleTab ); # spent 54µs making 1 call to Foswiki::Func::registerTagHandler |
53 | 1 | 7µs | 1 | 56µs | Foswiki::Func::registerTagHandler( 'ENDTAB', \&handleEndTab ); # spent 56µs making 1 call to Foswiki::Func::registerTagHandler |
54 | |||||
55 | # jquery.button | ||||
56 | 1 | 8µs | 1 | 73µs | Foswiki::Func::registerTagHandler( 'BUTTON', \&handleButton ); # spent 73µs making 1 call to Foswiki::Func::registerTagHandler |
57 | |||||
58 | # jquery.popupwindow | ||||
59 | 1 | 7µs | 1 | 81µs | Foswiki::Func::registerTagHandler( 'POPUPWINDOW', \&handlePopUpWindow ); # spent 81µs making 1 call to Foswiki::Func::registerTagHandler |
60 | |||||
61 | # init plugin handler and preload default plugins | ||||
62 | 1 | 16µs | 1 | 8.27ms | Foswiki::Plugins::JQueryPlugin::Plugins::init(); # spent 8.27ms making 1 call to Foswiki::Plugins::JQueryPlugin::Plugins::init |
63 | |||||
64 | # backwards compatibility | ||||
65 | 1 | 2µs | if ( $Foswiki::Plugins::VERSION < 2.1 ) { | ||
66 | Foswiki::Func::setPreferencesValue( "CLEAR", | ||||
67 | "<span class='foswikiClear'></span>" ); | ||||
68 | } | ||||
69 | |||||
70 | 1 | 11µs | return 1; | ||
71 | } | ||||
72 | |||||
73 | =begin TML | ||||
74 | |||||
75 | finish up the plugins container | ||||
76 | |||||
77 | SMELL: I'd prefer a proper finishHandler, alas it does not exist | ||||
78 | |||||
79 | =cut | ||||
80 | |||||
81 | # spent 235µs (24+211) within Foswiki::Plugins::JQueryPlugin::modifyHeaderHandler which was called:
# once (24µs+211µs) by Foswiki::Plugin::invoke at line 287 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugin.pm | ||||
82 | 1 | 15µs | 1 | 211µs | Foswiki::Plugins::JQueryPlugin::Plugins::finish(); # spent 211µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugins::finish |
83 | } | ||||
84 | |||||
85 | =begin TML | ||||
86 | |||||
87 | ---++ createPlugin($pluginName, ...) -> $plugin | ||||
88 | |||||
89 | API to create a jQuery plugin. Instantiating it adds all required javascript | ||||
90 | and css files to the html page header. | ||||
91 | |||||
92 | =cut | ||||
93 | |||||
94 | # spent 3.64ms (27µs+3.62) within Foswiki::Plugins::JQueryPlugin::createPlugin which was called 2 times, avg 1.82ms/call:
# 2 times (27µs+3.62ms) by Foswiki::Form::Textboxlist::new at line 15 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Form/Textboxlist.pm, avg 1.82ms/call | ||||
95 | 2 | 29µs | 2 | 3.62ms | return Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin(@_); # spent 3.62ms making 2 calls to Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin, avg 1.81ms/call |
96 | } | ||||
97 | |||||
98 | =begin TML | ||||
99 | |||||
100 | ---++ createTheme($themeName) -> $boolean | ||||
101 | |||||
102 | API to load a jQuery UI theme. Returns true if the theme has | ||||
103 | been loaded successfully. | ||||
104 | |||||
105 | =cut | ||||
106 | |||||
107 | # spent 110µs (12+99) within Foswiki::Plugins::JQueryPlugin::createTheme which was called:
# once (12µs+99µs) by Foswiki::Plugins::JQueryPlugin::UI::init at line 59 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/JQueryPlugin/UI.pm | ||||
108 | 1 | 13µs | 1 | 99µs | return Foswiki::Plugins::JQueryPlugin::Plugins::createTheme(@_); # spent 99µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugins::createTheme |
109 | } | ||||
110 | |||||
111 | =begin TML | ||||
112 | |||||
113 | ---++ registerPlugin($pluginName, $class) -> $plugin | ||||
114 | |||||
115 | API to register a jQuery plugin. this is of use for other Foswiki plugins | ||||
116 | to register their javascript modules as a jQuery plugin. Registering a plugin 'foobar' | ||||
117 | will make it available via =%<nop>JQREQUIRE{"foobar"}%=. | ||||
118 | |||||
119 | Class will default to 'Foswiki::Plugins::JQueryPlugin::FOOBAR, | ||||
120 | |||||
121 | The FOOBAR.pm stub must be derived from Foswiki::Plugins::JQueryPlugin::PLUGIN class. | ||||
122 | |||||
123 | =cut | ||||
124 | |||||
125 | # spent 107µs (32+75) within Foswiki::Plugins::JQueryPlugin::registerPlugin which was called:
# once (32µs+75µs) by Foswiki::Plugins::TwistyPlugin::initPlugin at line 48 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TwistyPlugin.pm | ||||
126 | 1 | 19µs | 1 | 75µs | return Foswiki::Plugins::JQueryPlugin::Plugins::registerPlugin(@_); # spent 75µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugins::registerPlugin |
127 | } | ||||
128 | |||||
129 | =begin TML | ||||
130 | |||||
131 | ---++ registerTheme($themeName, $url) | ||||
132 | |||||
133 | API to register a jQuery theme. this is of use for other Foswiki plugins | ||||
134 | to register their theme. Registering a theme 'foobar' | ||||
135 | will make it available via =%<nop>JQTHEME{"foobar"}%=. | ||||
136 | |||||
137 | The =$url= parameter will default to '%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/ui/$themeName/jquery-ui.css'. | ||||
138 | |||||
139 | =cut | ||||
140 | |||||
141 | sub registerTheme { | ||||
142 | return Foswiki::Plugins::JQueryPlugin::Plugins::registerTheme(@_); | ||||
143 | } | ||||
144 | |||||
145 | =begin TML | ||||
146 | |||||
147 | ---++ handleButton($session, $params, $topic, $web) -> $result | ||||
148 | |||||
149 | Handles the =%<nop>BUTTON% tag. | ||||
150 | |||||
151 | =cut | ||||
152 | |||||
153 | sub handleButton { | ||||
154 | my $session = shift; | ||||
155 | my $plugin = createPlugin( 'Button', $session ); | ||||
156 | return $plugin->handleButton(@_) if $plugin; | ||||
157 | return ''; | ||||
158 | } | ||||
159 | |||||
160 | =begin TML | ||||
161 | |||||
162 | ---++ handlePopUpWindow($session, $params, $topic, $web) -> $result | ||||
163 | |||||
164 | Handles the =%<nop>POPUPWINDOW% tag. | ||||
165 | |||||
166 | =cut | ||||
167 | |||||
168 | sub handlePopUpWindow { | ||||
169 | my $session = shift; | ||||
170 | my $plugin = createPlugin( 'PopUpWindow', $session ); | ||||
171 | return $plugin->handlePopUpWindow(@_) if $plugin; | ||||
172 | return ''; | ||||
173 | } | ||||
174 | |||||
175 | =begin TML | ||||
176 | |||||
177 | ---++ handleToggle($session, $params, $topic, $web) -> $result | ||||
178 | |||||
179 | Handles the =%<nop>TOGGLE% tag. | ||||
180 | |||||
181 | =cut | ||||
182 | |||||
183 | sub handleToggle { | ||||
184 | my $session = shift; | ||||
185 | my $plugin = createPlugin( 'Toggle', $session ); | ||||
186 | return $plugin->handleToggle(@_) if $plugin; | ||||
187 | return ''; | ||||
188 | } | ||||
189 | |||||
190 | =begin TML | ||||
191 | |||||
192 | ---++ handleTabPane($session, $params, $topic, $web) -> $result | ||||
193 | |||||
194 | Handles the =%<nop>TABPANE% tag. | ||||
195 | |||||
196 | =cut | ||||
197 | |||||
198 | sub handleTabPane { | ||||
199 | my $session = shift; | ||||
200 | my $plugin = createPlugin( 'Tabpane', $session ); | ||||
201 | return $plugin->handleTabPane(@_) if $plugin; | ||||
202 | return ''; | ||||
203 | } | ||||
204 | |||||
205 | =begin TML | ||||
206 | |||||
207 | ---++ handleTab($session, $params, $topic, $web) -> $result | ||||
208 | |||||
209 | Handles the =%<nop>TAB% tag. | ||||
210 | |||||
211 | =cut | ||||
212 | |||||
213 | sub handleTab { | ||||
214 | my $session = shift; | ||||
215 | my $plugin = createPlugin( 'Tabpane', $session ); | ||||
216 | return $plugin->handleTab(@_) if $plugin; | ||||
217 | return ''; | ||||
218 | } | ||||
219 | |||||
220 | =begin TML | ||||
221 | |||||
222 | ---++ handleEndTab($session, $params, $topic, $web) -> $result | ||||
223 | |||||
224 | Handles the =%<nop>ENDTAB% tag. | ||||
225 | |||||
226 | =cut | ||||
227 | |||||
228 | sub handleEndTab { | ||||
229 | my $session = shift; | ||||
230 | my $plugin = createPlugin( 'Tabpane', $session ); | ||||
231 | return $plugin->handleEndTab(@_) if $plugin; | ||||
232 | return ''; | ||||
233 | } | ||||
234 | |||||
235 | =begin TML | ||||
236 | |||||
237 | ---++ handleEndTabPane($session, $params, $topic, $web) -> $result | ||||
238 | |||||
239 | Handles the =%<nop>ENDTABPANE% tag. | ||||
240 | |||||
241 | =cut | ||||
242 | |||||
243 | sub handleEndTabPane { | ||||
244 | my $session = shift; | ||||
245 | my $plugin = createPlugin( 'Tabpane', $session ); | ||||
246 | return $plugin->handleEndTabPane(@_) if $plugin; | ||||
247 | return ''; | ||||
248 | } | ||||
249 | |||||
250 | =begin TML | ||||
251 | |||||
252 | ---++ handleJQueryRequire($session, $params, $topic, $web) -> $result | ||||
253 | |||||
254 | Handles the =%<nop>JQREQUIRE% tag. | ||||
255 | |||||
256 | =cut | ||||
257 | |||||
258 | sub handleJQueryRequire { | ||||
259 | my ( $session, $params, $theTopic, $theWeb ) = @_; | ||||
260 | |||||
261 | my $plugins = $params->{_DEFAULT} || ''; | ||||
262 | my $warn = Foswiki::Func::isTrue( $params->{warn}, 1 ); | ||||
263 | my $errorMsg = ''; | ||||
264 | foreach my $pluginName ( split( /\s*,\s*/, $plugins ) ) { | ||||
265 | my $plugin = createPlugin( $pluginName, $session ); | ||||
266 | $errorMsg .= | ||||
267 | "<div class='foswikiAlert'>Error: no such plugin $pluginName</div>" | ||||
268 | if !$plugin && $warn; | ||||
269 | } | ||||
270 | |||||
271 | return $errorMsg; | ||||
272 | } | ||||
273 | |||||
274 | =begin TML | ||||
275 | |||||
276 | ---++ handleJQueryTheme($session, $params, $topic, $web) -> $result | ||||
277 | |||||
278 | Handles the =%<nop>JQTHEME% tag. | ||||
279 | |||||
280 | =cut | ||||
281 | |||||
282 | sub handleJQueryTheme { | ||||
283 | my ( $session, $params, $theTopic, $theWeb ) = @_; | ||||
284 | |||||
285 | my $themeName = $params->{_DEFAULT} | ||||
286 | || $Foswiki::cfg{JQueryPlugin}{JQueryTheme}; | ||||
287 | |||||
288 | my $warn = $params->{warn} || ''; | ||||
289 | |||||
290 | return "<div class='foswikiAlert'>Error: no such theme $themeName</div>" | ||||
291 | if !createTheme($themeName) && $warn ne 'off'; | ||||
292 | |||||
293 | return ''; | ||||
294 | } | ||||
295 | |||||
296 | =begin TML | ||||
297 | |||||
298 | ---++ handleJQueryIconPath($session, $params, $topic, $web) -> $result | ||||
299 | |||||
300 | Handles the =%<nop>JQICONPATH% tag. | ||||
301 | |||||
302 | =cut | ||||
303 | |||||
304 | sub handleJQueryIconPath { | ||||
305 | my ( $session, $params, $theTopic, $theWeb ) = @_; | ||||
306 | |||||
307 | my $iconName = $params->{_DEFAULT} || ''; | ||||
308 | return Foswiki::Plugins::JQueryPlugin::Plugins::getIconUrlPath($iconName); | ||||
309 | } | ||||
310 | |||||
311 | =begin TML | ||||
312 | |||||
313 | ---++ handleJQueryIcon($session, $params, $topic, $web) -> $result | ||||
314 | |||||
315 | Handles the =%<nop>JQICON% tag. | ||||
316 | |||||
317 | =cut | ||||
318 | |||||
319 | sub handleJQueryIcon { | ||||
320 | my ( $session, $params, $theTopic, $theWeb ) = @_; | ||||
321 | |||||
322 | my $iconName = $params->{_DEFAULT} || ''; | ||||
323 | my $iconAlt = $params->{alt} || $iconName; | ||||
324 | my $iconTitle = $params->{title} || ''; | ||||
325 | my $iconFormat = $params->{format} | ||||
326 | || '<img src=\'$iconPath\' class=\'$iconClass\' $iconAlt$iconTitle/>'; | ||||
327 | my $iconPath = | ||||
328 | Foswiki::Plugins::JQueryPlugin::Plugins::getIconUrlPath($iconName); | ||||
329 | |||||
330 | return '' unless $iconPath; | ||||
331 | |||||
332 | my $iconClass = "foswikiIcon jqIcon"; | ||||
333 | $iconClass .= " $params->{class}" if $params->{class}; | ||||
334 | |||||
335 | my $img = $iconFormat; | ||||
336 | $img =~ s/\$iconPath/$iconPath/g; | ||||
337 | $img =~ s/\$iconClass/$iconClass/g; | ||||
338 | $img =~ s/\$iconAlt/alt='$iconAlt' /g if $iconAlt; | ||||
339 | $img =~ s/\$iconTitle/title='$iconTitle' /g if $iconTitle; | ||||
340 | $img =~ s/\$(iconAlt|iconTitle)//go; | ||||
341 | |||||
342 | return $img; | ||||
343 | } | ||||
344 | |||||
345 | =begin TML | ||||
346 | |||||
347 | ---++ handleJQueryPlugins($session, $params, $topic, $web) -> $result | ||||
348 | |||||
349 | Handles the =%<nop>JQPLUGINS% tag. | ||||
350 | |||||
351 | =cut | ||||
352 | |||||
353 | sub handleJQueryPlugins { | ||||
354 | my ( $session, $params, $theTopic, $theWeb ) = @_; | ||||
355 | |||||
356 | my $thePlugin = $params->{_DEFAULT} || ''; | ||||
357 | my $theFormat = $params->{format}; | ||||
358 | my $theHeader = $params->{header} || ''; | ||||
359 | my $theFooter = $params->{footer} || ''; | ||||
360 | my $theSeparator = $params->{separator}; | ||||
361 | my $theTagFormat = $params->{tagformat}; | ||||
362 | |||||
363 | $theFormat = ' 1 <a href="$homepage">$name</a> $active $version $author' | ||||
364 | unless defined $theFormat; | ||||
365 | $theSeparator = '$n' | ||||
366 | unless defined $theSeparator; | ||||
367 | $theTagFormat = '[[%SYSTEMWEB%.Var$tag][$tag]]' | ||||
368 | unless defined $theTagFormat; | ||||
369 | |||||
370 | my @plugins = | ||||
371 | Foswiki::Plugins::JQueryPlugin::Plugins::getPlugins($thePlugin); | ||||
372 | |||||
373 | my @result; | ||||
374 | my $counter = 0; | ||||
375 | foreach my $plugin (@plugins) { | ||||
376 | my $summary = $plugin->getSummary(); | ||||
377 | $summary =~ s/^\s+//; | ||||
378 | $summary =~ s/\s+$//; | ||||
379 | my $tags = ''; | ||||
380 | if ( $theFormat =~ /\$tags/ ) { | ||||
381 | my @tags = (); | ||||
382 | foreach my $tag ( sort split( /\s*,\s*/, $plugin->{tags} ) ) { | ||||
383 | my $line = $theTagFormat; | ||||
384 | $line =~ s/\$tag/$tag/g; | ||||
385 | push @tags, $line if $line; | ||||
386 | } | ||||
387 | $tags = join( ', ', @tags ); | ||||
388 | } | ||||
389 | my $active = | ||||
390 | defined( $plugin->{isInit} ) | ||||
391 | ? '<span class="foswikiAlert">(active)</span>' | ||||
392 | : ''; | ||||
393 | my $line = Foswiki::Plugins::JQueryPlugin::Plugins::expandVariables( | ||||
394 | $theFormat, | ||||
395 | 'index' => ( $counter + 1 ), | ||||
396 | name => $plugin->{name}, | ||||
397 | version => $plugin->{version}, | ||||
398 | summary => $summary, | ||||
399 | documentation => $plugin->{documentation}, | ||||
400 | author => $plugin->{author}, | ||||
401 | homepage => $plugin->{homepage}, | ||||
402 | tags => $tags, | ||||
403 | active => $active, | ||||
404 | ); | ||||
405 | next unless $line; | ||||
406 | push @result, $line; | ||||
407 | $counter++; | ||||
408 | } | ||||
409 | |||||
410 | $theHeader = | ||||
411 | Foswiki::Plugins::JQueryPlugin::Plugins::expandVariables( $theHeader, | ||||
412 | counter => $counter, ); | ||||
413 | $theFooter = | ||||
414 | Foswiki::Plugins::JQueryPlugin::Plugins::expandVariables( $theFooter, | ||||
415 | counter => $counter, ); | ||||
416 | $theSeparator = | ||||
417 | Foswiki::Plugins::JQueryPlugin::Plugins::expandVariables($theSeparator); | ||||
418 | |||||
419 | return $theHeader . join( $theSeparator, @result ) . $theFooter; | ||||
420 | } | ||||
421 | |||||
422 | 1 | 7µs | 1; | ||
423 | __END__ |