← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 18:42:36 2015
Reported on Fri Jul 31 18:48:14 2015

Filename/var/www/foswikidev/core/lib/Foswiki/Plugins.pm
StatementsExecuted 7239 statements in 8.20ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
3501345.43ms43.1msFoswiki::Plugins::::dispatchFoswiki::Plugins::dispatch (recurses: max depth 1, inclusive time 188µs)
1111.94ms3.98msFoswiki::Plugins::::BEGIN@21Foswiki::Plugins::BEGIN@21
111466µs118msFoswiki::Plugins::::preloadFoswiki::Plugins::preload
8611198µs198µsFoswiki::Plugins::::addListenerFoswiki::Plugins::addListener
111193µs3.06msFoswiki::Plugins::::loadFoswiki::Plugins::load
111179µs65.8msFoswiki::Plugins::::enableFoswiki::Plugins::enable
111165µs703µsFoswiki::Plugins::::finishFoswiki::Plugins::finish
11192µs12.0msFoswiki::Plugins::::settingsFoswiki::Plugins::settings
11132µs118msFoswiki::Plugins::::newFoswiki::Plugins::new
102124µs24µsFoswiki::Plugins::::haveHandlerForFoswiki::Plugins::haveHandlerFor
11117µs30µsFoswiki::Plugins::::BEGIN@17Foswiki::Plugins::BEGIN@17
11116µs55µsFoswiki::Plugins::::BEGIN@39Foswiki::Plugins::BEGIN@39
11110µs22µsFoswiki::Plugins::::BEGIN@379Foswiki::Plugins::BEGIN@379
1119µs34µsFoswiki::Plugins::::BEGIN@19Foswiki::Plugins::BEGIN@19
1119µs13µsFoswiki::Plugins::::BEGIN@18Foswiki::Plugins::BEGIN@18
1118µs17µsFoswiki::Plugins::::BEGIN@381Foswiki::Plugins::BEGIN@381
1115µs5µsFoswiki::Plugins::::BEGIN@23Foswiki::Plugins::BEGIN@23
0000s0sFoswiki::Plugins::::__ANON__[:159]Foswiki::Plugins::__ANON__[:159]
0000s0sFoswiki::Plugins::::_handleACTIVATEDPLUGINSFoswiki::Plugins::_handleACTIVATEDPLUGINS
0000s0sFoswiki::Plugins::::_handleFAILEDPLUGINSFoswiki::Plugins::_handleFAILEDPLUGINS
0000s0sFoswiki::Plugins::::_handlePLUGINDESCRIPTIONSFoswiki::Plugins::_handlePLUGINDESCRIPTIONS
0000s0sFoswiki::Plugins::::_handleRESTHANDLERSFoswiki::Plugins::_handleRESTHANDLERS
0000s0sFoswiki::Plugins::::getPluginVersionFoswiki::Plugins::getPluginVersion
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
3=begin TML
4
5---+ package Foswiki::Plugins
6
7This module defines the singleton object that handles Plugins
8loading, initialization and execution.
9
10This class uses Chain of Responsibility (GOF) pattern to dispatch
11handler calls to registered plugins.
12
13=cut
14
15package Foswiki::Plugins;
16
17228µs243µs
# spent 30µs (17+13) within Foswiki::Plugins::BEGIN@17 which was called: # once (17µs+13µs) by Foswiki::BEGIN@646 at line 17
use strict;
# spent 30µs making 1 call to Foswiki::Plugins::BEGIN@17 # spent 13µs making 1 call to strict::import
18223µs217µs
# spent 13µs (9+4) within Foswiki::Plugins::BEGIN@18 which was called: # once (9µs+4µs) by Foswiki::BEGIN@646 at line 18
use warnings;
# spent 13µs making 1 call to Foswiki::Plugins::BEGIN@18 # spent 4µs making 1 call to warnings::import
19225µs259µs
# spent 34µs (9+25) within Foswiki::Plugins::BEGIN@19 which was called: # once (9µs+25µs) by Foswiki::BEGIN@646 at line 19
use Assert;
# spent 34µs making 1 call to Foswiki::Plugins::BEGIN@19 # spent 25µs making 1 call to Exporter::import
20
212124µs13.98ms
# spent 3.98ms (1.94+2.03) within Foswiki::Plugins::BEGIN@21 which was called: # once (1.94ms+2.03ms) by Foswiki::BEGIN@646 at line 21
use Foswiki::Plugin ();
# spent 3.98ms making 1 call to Foswiki::Plugins::BEGIN@21
22
23
# spent 5µs within Foswiki::Plugins::BEGIN@23 which was called: # once (5µs+0s) by Foswiki::BEGIN@646 at line 28
BEGIN {
2415µs if ( $Foswiki::cfg{UseLocale} ) {
25 require locale;
26 import locale();
27 }
28127µs15µs}
# spent 5µs making 1 call to Foswiki::Plugins::BEGIN@23
29
30=begin TML
31
32---++ PUBLIC constant $VERSION
33
34This is the version number of the plugins package. Use it for checking
35if you have a recent enough version.
36
37=cut
38
3941.15ms4101µs
# spent 55µs (16+38) within Foswiki::Plugins::BEGIN@39 which was called: # once (16µs+38µs) by Foswiki::BEGIN@646 at line 39
use version 0.77; our $VERSION = version->parse("2.3");
# spent 55µs making 1 call to Foswiki::Plugins::BEGIN@39 # spent 26µs making 1 call to version::import # spent 13µs making 1 call to version::vxs::_VERSION # spent 8µs making 1 call to version::vxs::parse
40
411200nsour $inited = 0;
42
4314µsmy %onlyOnceHandlers = (
44 registrationHandler => 1,
45 writeHeaderHandler => 1,
46 redirectCgiQueryHandler => 1,
47 renderFormFieldForEditHandler => 1,
48 renderWikiWordHandler => 1,
49);
50
51=begin TML
52
53---++ PUBLIC $SESSION
54
55This is a reference to the Foswiki session object. It can be used in
56plugins to get at the methods of the Foswiki kernel.
57
58You are _highly_ recommended to only use the methods in the
59=Foswiki::Func= interface, unless you have no other choice,
60as kernel methods may change between Foswiki releases.
61
62=cut
63
641100nsour $SESSION;
65
66=begin TML
67
68---++ ClassMethod new( $session )
69
70Construct new singleton plugins collection object. The object is a
71container for a list of plugins and the handlers registered by the plugins.
72The plugins and the handlers are carefully ordered.
73
74=cut
75
76
# spent 118ms (32µs+118) within Foswiki::Plugins::new which was called: # once (32µs+118ms) by Foswiki::new at line 2089 of /var/www/foswikidev/core/lib/Foswiki.pm
sub new {
7711µs my ( $class, $session ) = @_;
7815µs my $this = bless( { session => $session }, $class );
79
80 # Load the plugins code and invoke preload handlers
8112µs1118ms $this->preload();
# spent 118ms making 1 call to Foswiki::Plugins::preload
82
831900ns unless ($inited) {
8414µs16µs Foswiki::registerTagHandler( 'PLUGINDESCRIPTIONS',
# spent 6µs making 1 call to Foswiki::registerTagHandler
85 \&_handlePLUGINDESCRIPTIONS );
8612µs12µs Foswiki::registerTagHandler( 'ACTIVATEDPLUGINS',
# spent 2µs making 1 call to Foswiki::registerTagHandler
87 \&_handleACTIVATEDPLUGINS );
8812µs12µs Foswiki::registerTagHandler( 'FAILEDPLUGINS', \&_handleFAILEDPLUGINS );
# spent 2µs making 1 call to Foswiki::registerTagHandler
8912µs12µs Foswiki::registerTagHandler( 'RESTHANDLERS', \&_handleRESTHANDLERS );
# spent 2µs making 1 call to Foswiki::registerTagHandler
901600ns $inited = 1;
91 }
92
9314µs return $this;
94}
95
96=begin TML
97
98---++ ObjectMethod finish()
99Break circular references.
100
101=cut
102
103# Note to developers; please undef *all* fields in the object explicitly,
104# whether they are references or not. That way this method is "golden
105# documentation" of the live fields in the object.
106
# spent 703µs (165+538) within Foswiki::Plugins::finish which was called: # once (165µs+538µs) by Foswiki::finish at line 2488 of /var/www/foswikidev/core/lib/Foswiki.pm
sub finish {
1071500ns my $this = shift;
108
10911µs1184µs $this->dispatch('finishPlugin');
# spent 184µs making 1 call to Foswiki::Plugins::dispatch
110
111137µs undef $this->{registeredHandlers};
11212µs foreach ( @{ $this->{plugins} } ) {
1134262µs42354µs $_->finish();
# spent 354µs making 42 calls to Foswiki::Plugin::finish, avg 8µs/call
114 }
115126µs undef $this->{plugins};
11615µs undef $this->{session};
117}
118
119=begin TML
120
121---++ ObjectMethod preload() -> $loginName
122
123Find all active plugins, load the code and and invoke the preload handler
124
125=cut
126
127
# spent 118ms (466µs+118) within Foswiki::Plugins::preload which was called: # once (466µs+118ms) by Foswiki::Plugins::new at line 81
sub preload {
1281800ns my ($this) = @_;
1291300ns my %lookup;
1301600ns our @pluginList = ();
131
1321500ns my $session = $this->{session};
1331300ns my $query = $session->{request};
134
1351200ns my %already;
13612µs unless ( $Foswiki::cfg{DisableAllPlugins} ) {
137
138 # debugenableplugins only supported in DEBUG and unit test modes
13913µs117µs if (
# spent 17µs making 1 call to Foswiki::Request::param
140 $query
141 && defined(
142 $query->param('debugenableplugins')
143 && ( DEBUG || $query->isa('Unit::Request') )
144 )
145 )
146 {
147 foreach
148 my $pn ( split( /[,\s]+/, $query->param('debugenableplugins') ) )
149 {
150 push(
151 @pluginList,
152 Foswiki::Sandbox::untaint(
153 $pn,
154 sub {
155 my $pn = shift;
156 throw Error::Simple('Bad debugenableplugins')
157 unless $pn =~ m/^[a-zA-Z0-9_]+$/;
158 return $pn;
159 }
160 )
161 );
162 }
163 }
164 else {
16512µs if ( $Foswiki::cfg{PluginsOrder} ) {
16615µs foreach
167 my $plugin ( split( /[,\s]+/, $Foswiki::cfg{PluginsOrder} ) )
168 {
169
170 # Note this allows the same plugin to be listed
171 # multiple times! Thus their handlers can be called
172 # more than once. This is *desireable*.
17335µs if ( $Foswiki::cfg{Plugins}{$plugin}{Enabled} ) {
17428µs27µs $plugin = Foswiki::Sandbox::untaintUnchecked($plugin)
# spent 7µs making 2 calls to Foswiki::Sandbox::untaintUnchecked, avg 3µs/call
175 ; # Item 11953
17622µs push( @pluginList, $plugin );
17722µs $already{$plugin} = 1;
178 }
179 }
180 }
181128µs foreach my $plugin ( sort keys %{ $Foswiki::cfg{Plugins} } ) {
1824619µs next unless ref( $Foswiki::cfg{Plugins}{$plugin} ) eq 'HASH';
1834541µs if ( $Foswiki::cfg{Plugins}{$plugin}{Enabled}
184 && !$already{$plugin} )
185 {
186408µs push( @pluginList, $plugin );
1874014µs $already{$plugin} = 1;
188 }
189 }
190 }
191 }
192
193116µs foreach my $pn (@pluginList) {
194426µs my $p;
19542164µs42117ms unless ( $p = $lookup{$pn} ) {
# spent 117ms making 42 calls to Foswiki::Plugin::new, avg 2.80ms/call
196
197 # The 'new' will call the preload handler
198 $p = new Foswiki::Plugin( $session, $pn );
199 }
2004232µs push @{ $this->{plugins} }, $p;
2014262µs $lookup{$pn} = $p;
202 }
203}
204
205=begin TML
206
207---++ ObjectMethod load($allDisabled) -> $loginName
208
209Find all active plugins, and invoke the early initialisation.
210Has to be done _after_ prefs are read.
211
212Returns the user returned by the last =initializeUserHandler= to be
213called.
214
215If allDisabled is set, no plugin handlers will be called.
216
217=cut
218
219
# spent 3.06ms (193µs+2.87) within Foswiki::Plugins::load which was called: # once (193µs+2.87ms) by Foswiki::Users::initialiseUser at line 267 of /var/www/foswikidev/core/lib/Foswiki/Users.pm
sub load {
2201600ns my ($this) = @_;
221
2221600ns my $session = $this->{session};
223
224 # Uncomment this to monitor plugin load times
225 #Monitor::MARK('About to initPlugins');
226
2271400ns my $user; # the user login name
2281200ns my $userDefiner; # the plugin that is defining the user
22911µs foreach my $p ( @{ $this->{plugins} } ) {
2304273µs422.87ms my $anotherUser = $p->load();
# spent 2.87ms making 42 calls to Foswiki::Plugin::load, avg 68µs/call
231428µs if ($anotherUser) {
2321400ns if ($userDefiner) {
233 die 'Two plugins - '
234 . $userDefiner->{name} . ' and '
235 . $p->{name}
236 . ' are both trying to define the user login name.';
237 }
238 else {
2391200ns $userDefiner = $p;
2401300ns $user = $anotherUser;
241 }
242 }
243
244 # Report initialisation errors
2454253µs if ( $p->{errors} && @{ $p->{errors} } ) {
246 $this->{session}
247 ->logger->log( 'error', join( "\n", @{ $p->{errors} } ) );
248 }
249
250 # Uncomment this to monitor plugin load times
251 #Monitor::MARK($pn);
252 }
253
25414µs return $user;
255}
256
257=begin TML
258
259---++ ObjectMethod settings()
260
261Push plugin settings onto preference stack
262
263=cut
264
265
# spent 12.0ms (92µs+11.9) within Foswiki::Plugins::settings which was called: # once (92µs+11.9ms) by Foswiki::new at line 2243 of /var/www/foswikidev/core/lib/Foswiki.pm
sub settings {
2661500ns my $this = shift;
267
268 # Set the session for this call stack
2691800ns local $Foswiki::Plugins::SESSION = $this->{session};
270 ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG;
271
27215µs foreach my $plugin ( @{ $this->{plugins} } ) {
2734253µs4211.9ms $plugin->registerSettings($this);
# spent 11.9ms making 42 calls to Foswiki::Plugin::registerSettings, avg 285µs/call
274 }
275}
276
277=begin TML
278
279---++ ObjectMethod enable()
280
281Initialisation that is done after the user is known.
282
283=cut
284
285
# spent 65.8ms (179µs+65.6) within Foswiki::Plugins::enable which was called: # once (179µs+65.6ms) by Foswiki::new at line 2267 of /var/www/foswikidev/core/lib/Foswiki.pm
sub enable {
2861700ns my $this = shift;
2871800ns my $prefs = $this->{session}->{prefs};
28813µs135µs my $dissed = $prefs->getPreference('DISABLEDPLUGINS') || '';
# spent 35µs making 1 call to Foswiki::Prefs::getPreference
28912µs my %disabled = map { s/^\s+//; s/\s+$//; $_ => 1 } split( /,/, $dissed );
290
291 # Set the session for this call stack
29211µs local $Foswiki::Plugins::SESSION = $this->{session};
293 ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG;
294
29516µs foreach my $plugin ( @{ $this->{plugins} } ) {
2964240µs if ( $disabled{ $plugin->{name} } ) {
297 $plugin->{disabled} = 1;
298 $plugin->{reason} =
299 $this->{session}
300 ->i18n->maketext('See the DISABLEDPLUGINS preference setting.');
301 push(
302 @{ $plugin->{errors} },
303 $plugin->{name} . ' has been disabled'
304 ) if DEBUG;
305 }
306 else {
3074253µs4265.6ms $plugin->registerHandlers($this);
# spent 65.6ms making 42 calls to Foswiki::Plugin::registerHandlers, avg 1.56ms/call
308 }
309
310 # Report initialisation errors
3114244µs if ( $plugin->{errors} && @{ $plugin->{errors} } ) {
312 $this->{session}
313 ->logger->log( 'warning', join( "\n", @{ $plugin->{errors} } ) );
314 }
315 }
316}
317
318=begin TML
319
320---++ ObjectMethod getPluginVersion() -> $number
321
322Returns the $Foswiki::Plugins::VERSION number if no parameter is specified,
323else returns the version number of a named Plugin. If the Plugin cannot
324be found or is not active, 0 is returned.
325
326=cut
327
328sub getPluginVersion {
329 my ( $this, $thePlugin ) = @_;
330
331 return $VERSION unless $thePlugin;
332
333 foreach my $plugin ( @{ $this->{plugins} } ) {
334 if ( $plugin->{name} eq $thePlugin ) {
335 return $plugin->getVersion();
336 }
337 }
338 return 0;
339}
340
341=begin TML
342
343---++ ObjectMethod addListener( $command, $handler )
344
345 * =$command= - name of the event
346 * =$handler= - the handler object.
347
348Add a listener to the end of the list of registered listeners for this event.
349The listener must implement =invoke($command,...)=, which will be triggered
350when the event is to be processed.
351
352=cut
353
354
# spent 198µs within Foswiki::Plugins::addListener which was called 86 times, avg 2µs/call: # 86 times (198µs+0s) by Foswiki::Plugin::registerHandlers at line 298 of /var/www/foswikidev/core/lib/Foswiki/Plugin.pm, avg 2µs/call
sub addListener {
3558643µs my ( $this, $c, $h ) = @_;
356
35786261µs push( @{ $this->{registeredHandlers}{$c} }, $h );
358}
359
360=begin TML
361
362---++ ObjectMethod dispatch( $handlerName, ...)
363Dispatch the given handler, passing on ... in the parameter vector
364
365=cut
366
367
# spent 43.1ms (5.43+37.7) within Foswiki::Plugins::dispatch which was called 350 times, avg 123µs/call: # 100 times (2.92ms+13.6ms) by Foswiki::expandMacros at line 3625 of /var/www/foswikidev/core/lib/Foswiki.pm, avg 165µs/call # 100 times (1.39ms+3.07ms) by Foswiki::expandMacros at line 3595 of /var/www/foswikidev/core/lib/Foswiki.pm, avg 45µs/call # 100 times (536µs+879µs) by Foswiki::expandMacros at line 3658 of /var/www/foswikidev/core/lib/Foswiki.pm, avg 14µs/call # 18 times (50µs+0s) by Foswiki::Render::internalLink at line 174 of /var/www/foswikidev/core/lib/Foswiki/Render.pm, avg 3µs/call # 8 times (237µs+680µs) by Foswiki::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Macros/INCLUDE.pm:339] at line 306 of /var/www/foswikidev/core/lib/Foswiki/Macros/INCLUDE.pm, avg 115µs/call # 5 times (144µs+18.3ms) by Foswiki::Render::getRenderedVersion at line 269 of /var/www/foswikidev/core/lib/Foswiki/Render.pm, avg 3.69ms/call # 5 times (77µs+448µs) by Foswiki::Render::getRenderedVersion at line 569 of /var/www/foswikidev/core/lib/Foswiki/Render.pm, avg 105µs/call # 5 times (36µs+446µs) by Foswiki::Render::getRenderedVersion at line 548 of /var/www/foswikidev/core/lib/Foswiki/Render.pm, avg 96µs/call # 5 times (16µs+0s) by Foswiki::Render::getRenderedVersion at line 261 of /var/www/foswikidev/core/lib/Foswiki/Render.pm, avg 3µs/call # once (8µs+176µs) by Foswiki::Plugins::finish at line 109 # once (7µs+42µs) by Foswiki::generateHTTPHeaders at line 1095 of /var/www/foswikidev/core/lib/Foswiki.pm # once (4µs+0s) by Foswiki::writeCompletePage at line 750 of /var/www/foswikidev/core/lib/Foswiki.pm # once (3µs+0s) by Foswiki::generateHTTPHeaders at line 1067 of /var/www/foswikidev/core/lib/Foswiki.pm
sub dispatch {
368
369 # must be shifted to clear parameter vector
37035084µs my $this = shift;
37135062µs my $handlerName = shift;
372350382µs foreach my $plugin ( @{ $this->{registeredHandlers}{$handlerName} } ) {
373
374 # Set the value of $SESSION for this call stack
3751632621µs local $SESSION = $this->{session};
376 ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG;
377
378 # apply handler on the remaining list of args
379240µs234µs
# spent 22µs (10+12) within Foswiki::Plugins::BEGIN@379 which was called: # once (10µs+12µs) by Foswiki::BEGIN@646 at line 379
no strict 'refs';
# spent 22µs making 1 call to Foswiki::Plugins::BEGIN@379 # spent 12µs making 1 call to strict::unimport
38016322.02ms163237.7ms my $status = $plugin->invoke( $handlerName, @_ );
# spent 37.9ms making 1632 calls to Foswiki::Plugin::invoke, avg 23µs/call, recursion: max depth 1, sum of overlapping time 136µs
3812822µs227µs
# spent 17µs (8+9) within Foswiki::Plugins::BEGIN@381 which was called: # once (8µs+9µs) by Foswiki::BEGIN@646 at line 381
use strict 'refs';
# spent 17µs making 1 call to Foswiki::Plugins::BEGIN@381 # spent 9µs making 1 call to strict::import
3821632912µs if ( $status && $onlyOnceHandlers{$handlerName} ) {
383 return $status;
384 }
385 }
386350601µs return;
387}
388
389=begin TML
390
391---++ ObjectMethod haveHandlerFor( $handlerName ) -> $boolean
392
393 * =$handlerName= - name of the handler e.g. preRenderingHandler
394Return: true if at least one plugin has registered a handler of
395this type.
396
397=cut
398
399
# spent 24µs within Foswiki::Plugins::haveHandlerFor which was called 10 times, avg 2µs/call: # 5 times (16µs+0s) by Foswiki::Render::getRenderedVersion at line 271 of /var/www/foswikidev/core/lib/Foswiki/Render.pm, avg 3µs/call # 5 times (8µs+0s) by Foswiki::Render::getRenderedVersion at line 289 of /var/www/foswikidev/core/lib/Foswiki/Render.pm, avg 2µs/call
sub haveHandlerFor {
400106µs my ( $this, $handlerName ) = @_;
401
4021028µs return 0 unless defined( $this->{registeredHandlers}{$handlerName} );
403 return scalar( @{ $this->{registeredHandlers}{$handlerName} } );
404}
405
406# %RESTHANDLERS% reports the registred rest handlers and a bit of information
407# about them
408#
409sub _handleRESTHANDLERS {
410 my $this = shift->{plugins};
411
412 return
413'%MAKETEXT{"The details about REST Handlers are only available to users with Admin authority."}%'
414 unless ( $SESSION->{users}->isAdmin( $SESSION->{user} ) );
415
416 require Foswiki::UI::Rest;
417 my $restHandlers = Foswiki::UI::Rest::getRegisteredHandlers();
418 my $out = <<DONE
419| *Extension* | *REST Verb* | *HTTP<br />Method* | *Validation* | *Requires<br />Authentication* | *Description* |
420DONE
421 ; #Collect output for display
422
423 foreach my $handler ( sort keys %$restHandlers ) {
424 $out .=
425 "| [[$Foswiki::cfg{SystemWebName}.$handler][$handler]] | ||||||\n";
426 foreach my $verb ( keys %{ $restHandlers->{$handler} } ) {
427 my $method =
428 ( defined $restHandlers->{$handler}{$verb}{http_allow} )
429 ? $restHandlers->{$handler}{$verb}{http_allow}
430 : 'undef';
431 my $authenticate =
432 ( defined $restHandlers->{$handler}{$verb}{authenticate} )
433 ? $restHandlers->{$handler}{$verb}{authenticate}
434 : 'undef';
435 my $validate =
436 ( defined $restHandlers->{$handler}{$verb}{validate} )
437 ? $restHandlers->{$handler}{$verb}{validate}
438 : 'undef';
439 $out .=
440 "| | $verb | $method | $validate | $authenticate | "
441 . ( $restHandlers->{$handler}{$verb}{description} || '' )
442 . " |\n";
443
444 }
445 }
446
447 return $out;
448}
449
450# %FAILEDPLUGINS reports reasons why plugins failed to load
451# note this is invoked with the session as the first parameter
452sub _handleFAILEDPLUGINS {
453 my $this = shift->{plugins};
454
455 my $text = CGI::start_table(
456 {
457 border => 1,
458 class => 'foswikiTable',
459 summary => $this->{session}->i18n->maketext("Failed plugins")
460 }
461 ) . CGI::Tr( {}, CGI::th( {}, 'Plugin' ) . CGI::th( {}, 'Errors' ) );
462
463 foreach my $plugin ( @{ $this->{plugins} } ) {
464 my $td;
465 if ( $plugin->{errors} && @{ $plugin->{errors} } ) {
466 $td = CGI::td(
467 { class => 'foswikiAlert' },
468 "\n<verbatim>\n"
469 . join( "\n", @{ $plugin->{errors} } )
470 . "\n</verbatim>\n"
471 );
472 }
473 else {
474 $td = CGI::td( {}, 'none' );
475 }
476 my $web = $plugin->topicWeb();
477 my $modname = '';
478 if ( $SESSION->{users}->isAdmin( $SESSION->{user} ) ) {
479 if ( $Foswiki::cfg{Plugins}{ $plugin->{name} }{Module} ) {
480 $modname =
481 $Foswiki::cfg{Plugins}{ $plugin->{name} }{Module} . ' ';
482 }
483 else {
484 $modname = "Foswiki::Plugins::$plugin->{name} _(guessed)_ ";
485 }
486 }
487
488 $text .= CGI::Tr(
489 { valign => 'top' },
490 CGI::td( {},
491 ' '
492 . ( $web ? "$web." : '!' )
493 . $plugin->{name} . ' '
494 . CGI::br()
495 . $modname )
496 . $td
497 );
498 }
499
500 $text .= CGI::end_table()
501 . CGI::start_table(
502 {
503 border => 1,
504 class => 'foswikiTable',
505 summary => $this->{session}->i18n->maketext("Plugin handlers")
506 }
507 ) . CGI::Tr( {}, CGI::th( {}, 'Handler' ) . CGI::th( {}, 'Plugins' ) );
508
509 foreach my $handler (@Foswiki::Plugin::registrableHandlers) {
510 my $h = '';
511 if ( defined( $this->{registeredHandlers}{$handler} ) ) {
512 $h = join(
513 CGI::br(),
514 map { $_->{name} } @{ $this->{registeredHandlers}{$handler} }
515 );
516 }
517 if ($h) {
518 if ( defined( $Foswiki::Plugin::deprecated{$handler} ) ) {
519 $h .= CGI::br()
520 . CGI::span(
521 { class => 'foswikiAlert' },
522" __This handler is deprecated__ - please check for updated versions of the plugins that use it!"
523 );
524 }
525 $text .= CGI::Tr( { valign => 'top' },
526 CGI::td( {}, $handler ) . CGI::td( {}, $h ) );
527 }
528 }
529
530 return
531 $text
532 . CGI::end_table() . "\n*"
533 . scalar( @{ $this->{plugins} } )
534 . " plugins*\n\n";
535}
536
537# note this is invoked with the session as the first parameter
538sub _handlePLUGINDESCRIPTIONS {
539 my $this = shift->{plugins};
540 my $text = '';
541 foreach my $plugin ( @{ $this->{plugins} } ) {
542 $text .= CGI::li( {}, $plugin->getDescription() . ' ' );
543 }
544
545 return CGI::ul( {}, $text );
546}
547
548# note this is invoked with the session as the first parameter
549sub _handleACTIVATEDPLUGINS {
550 my $this = shift->{plugins};
551 my $text = '';
552 foreach my $plugin ( @{ $this->{plugins} } ) {
553 unless ( $plugin->{disabled} ) {
554 my $web = $plugin->topicWeb();
555 $text .= ( $web ? "$web." : '!' ) . "$plugin->{name}, ";
556 }
557 }
558 $text =~ s/\,\s*$//;
559 return $text;
560}
561
56215µs1;
563__END__