← 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/ExtendedWebListPlugin.pm
StatementsExecuted 675 statements in 1.90ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.19ms8.35sFoswiki::Plugins::ExtendedWebListPlugin::::_EXTENDEDWEBLISTFoswiki::Plugins::ExtendedWebListPlugin::_EXTENDEDWEBLIST
11129µs70µsFoswiki::Plugins::ExtendedWebListPlugin::::initPluginFoswiki::Plugins::ExtendedWebListPlugin::initPlugin
11114µs27µsFoswiki::Plugins::ExtendedWebListPlugin::::BEGIN@32Foswiki::Plugins::ExtendedWebListPlugin::BEGIN@32
11110µs56µsFoswiki::Plugins::ExtendedWebListPlugin::::BEGIN@36Foswiki::Plugins::ExtendedWebListPlugin::BEGIN@36
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
2#
3# Copyright (C) 2008 Kenneth Lavrsen, kenneth@lavrsen.dk
4#
5# This program is free software; you can redistribute it and/or
6# modify it under the terms of the GNU General Public License
7# as published by the Free Software Foundation; either version 2
8# of the License, or (at your option) any later version. For
9# more details read LICENSE in the root of this distribution.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14#
15# For licensing info read LICENSE file in the Foswiki root.
16
17=pod
18
19---+ package ExtendedWebListPlugin
20
21__NOTE:__ When writing handlers, keep in mind that these may be invoked
22on included topics. For example, if a plugin generates links to the current
23topic, these need to be generated before the afterCommonTagsHandler is run,
24as at that point in the rendering loop we have lost the information that we
25the text had been included from another topic.
26
27=cut
28
29package Foswiki::Plugins::ExtendedWebListPlugin;
30
31# Always use strict to enforce variable scoping
32242µs240µs
# spent 27µs (14+13) within Foswiki::Plugins::ExtendedWebListPlugin::BEGIN@32 which was called: # once (14µs+13µs) by Foswiki::Plugin::BEGIN@2.14 at line 32
use strict;
# spent 27µs making 1 call to Foswiki::Plugins::ExtendedWebListPlugin::BEGIN@32 # spent 13µs making 1 call to strict::import
33
34# $VERSION is referred to by Foswiki, and is the only global variable that
35# *must* exist in this package.
3617µs146µs
# spent 56µs (10+46) within Foswiki::Plugins::ExtendedWebListPlugin::BEGIN@36 which was called: # once (10µs+46µs) by Foswiki::Plugin::BEGIN@2.14 at line 38
use vars qw( $VERSION $RELEASE $SHORTDESCRIPTION $debug
# spent 46µs making 1 call to vars::import
37 $pluginName $NO_PREFS_IN_TOPIC
381630µs156µs );
# spent 56µs making 1 call to Foswiki::Plugins::ExtendedWebListPlugin::BEGIN@36
39
40# This should always be $Rev: 1243 (10 Dec 2008) $ so that TWiki can determine the checked-in
41# status of the plugin. It is used by the build automation tools, so
42# you should leave it alone.
431600ns$VERSION = '$Rev: 1243 (10 Dec 2008) $';
44
45# This is a free-form string you can use to "name" your own plugin version.
46# It is *not* used by the build automation tools, but is reported as part
47# of the version number in PLUGINDESCRIPTIONS.
481200ns$RELEASE = '1.0';
49
50# Short description of this plugin
51# One line description, is shown in the %SYSTEMWEB%.TextFormattingRules topic:
521300ns$SHORTDESCRIPTION = 'Extended Web List Plugin provides the ability to only show subwebs within current top web.';
53
54# You must set $NO_PREFS_IN_TOPIC to 0 if you want your plugin to use preferences
55# stored in the plugin topic. This default is required for compatibility with
56# older plugins, but imposes a significant performance penalty, and
57# is not recommended. Instead, use $Foswiki::cfg entries set in LocalSite.cfg, or
58# if you want the users to be able to change settings, then use standard TWiki
59# preferences that can be defined in your %USERSWEB%.SitePreferences and overridden
60# at the web and topic level.
611200ns$NO_PREFS_IN_TOPIC = 0;
62
63# Name of this Plugin, only used in this module
641200ns$pluginName = 'ExtendedWebListPlugin';
65
66=pod
67
68---++ initPlugin($topic, $web, $user, $installWeb) -> $boolean
69 * =$topic= - the name of the topic in the current CGI query
70 * =$web= - the name of the web in the current CGI query
71 * =$user= - the login name of the user
72 * =$installWeb= - the name of the web the plugin is installed in
73
74REQUIRED
75
76Called to initialise the plugin. If everything is OK, should return
77a non-zero value. On non-fatal failure, should write a message
78using Foswiki::Func::writeWarning and return 0. In this case
79%FAILEDPLUGINS% will indicate which plugins failed.
80
81In the case of a catastrophic failure that will prevent the whole
82installation from working safely, this handler may use 'die', which
83will be trapped and reported in the browser.
84
85You may also call =Foswiki::Func::registerTagHandler= here to register
86a function to handle variables that have standard TWiki syntax - for example,
87=%MYTAG{"my param" myarg="My Arg"}%. You can also override internal
88TWiki variable handling functions this way, though this practice is unsupported
89and highly dangerous!
90
91__Note:__ Please align variables names with the Plugin name, e.g. if
92your Plugin is called FooBarPlugin, name variables FOOBAR and/or
93FOOBARSOMETHING. This avoids namespace issues.
94
95
96=cut
97
98
# spent 70µs (29+41) within Foswiki::Plugins::ExtendedWebListPlugin::initPlugin which was called: # once (29µs+41µs) 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 {
9912µs my( $topic, $web, $user, $installWeb ) = @_;
100
101 # check for Plugins.pm versions
102118µs110µs if( $Foswiki::Plugins::VERSION < 1.026 ) {
# spent 10µs making 1 call to version::vxs::VCMP
103 Foswiki::Func::writeWarning( "Version mismatch between $pluginName and Plugins.pm" );
104 return 0;
105 }
106
107 # Set plugin preferences in LocalSite.cfg
10814µs $debug = $Foswiki::cfg{Plugins}{ExtendedWebListPlugin}{Debug} || 0;
109
11013µs131µs Foswiki::Func::registerTagHandler( 'EXTENDEDWEBLIST', \&_EXTENDEDWEBLIST );
# spent 31µs making 1 call to Foswiki::Func::registerTagHandler
111
112 # Plugin correctly initialized
11316µs return 1;
114}
115
116
# spent 8.35s (1.19ms+8.35) within Foswiki::Plugins::ExtendedWebListPlugin::_EXTENDEDWEBLIST which was called: # once (1.19ms+8.35s) by Foswiki::Func::__ANON__[/var/www/foswiki11/lib/Foswiki/Func.pm:611] at line 609 of /var/www/foswiki11/lib/Foswiki/Func.pm
sub _EXTENDEDWEBLIST {
11712µs my($session, $params, $theTopic, $theWeb) = @_;
118 # $session - a reference to the TWiki session object (if you don't know
119 # what this is, just ignore it)
120 # $params= - a reference to a Foswiki::Attrs object containing parameters.
121 # This can be used as a simple hash that maps parameter names
122 # to values, with _DEFAULT being the name for the default
123 # parameter.
124 # $theTopic - name of the topic in the query
125 # $theWeb - name of the web in the query
126 # Return: the result of processing the variable
127
128 # For example, %EXAMPLETAG{'hamburger' sideorder="onions"}%
129 # $params->{_DEFAULT} will be 'hamburger'
130 # $params->{sideorder} will be 'onions'
131
13213µs my $format = $params->{_DEFAULT} || $params->{'format'} || '$name';
1331600ns $format ||= '$name';
13412µs my $separator = $params->{separator} || "\n";
13512µs $separator =~ s/\$n/\n/;
1361800ns my $web = $params->{web} || '';
1371800ns my $webs = $params->{webs} || 'public';
13811µs my $rootwebs = $params->{rootwebs} || 'on';
1391900ns my $selection = $params->{selection} || '';
1401600ns my $showWeb = $params->{subwebs} || '';
1411300ns $selection =~ s/\,/ /g;
14212µs $selection = " $selection ";
14311µs my $marker = $params->{marker} || 'selected="selected"';
1441400ns $web =~ s#\.#/#go;
145
14612µs my @list = ();
14715µs my @webslist = split( /,\s*/, $webs );
148
14912µs foreach my $aweb (@webslist) {
15013µs if ( $aweb eq 'public' ) {
1511900ns if ( $rootwebs eq 'on' ) {
1521800ns my @sublist = ();
1531500ns my @templist = ();
15414µs my @currentRootWeb = split(/\//, $showWeb);
155155µs18.33s push( @templist, Foswiki::Func::getListOfWebs( 'user,public,allowed', '' ) );
# spent 8.33s making 1 call to Foswiki::Func::getListOfWebs
15618µs119.8ms push( @sublist, Foswiki::Func::getListOfWebs( 'user,public,allowed', $currentRootWeb[0] ) );
# spent 19.8ms making 1 call to Foswiki::Func::getListOfWebs
157
158112µs foreach my $listitem (@templist) {
1598962µs if ( $listitem !~ /\// ) {
1603921µs push( @list, $listitem );
16139182µs if ( $showWeb =~ /\b$listitem\b/ ) {
16212µs push (@list, @sublist);
16311µs Foswiki::Func::writeDebug("@list") if $debug;
164 }
165 }
166 }
167
168 }
169 else {
170 push( @list, Foswiki::Func::getListOfWebs( 'user,public,allowed', $showWeb ) );
171 }
172 }
173 elsif ( $aweb eq 'webtemplate' ) {
174 push( @list, Foswiki::Func::getListOfWebs( 'template,allowed', $showWeb ) );
175 }
176 else {
177 push( @list, $aweb ) if ( Foswiki::Func::webExists( $aweb ) );
178 }
179 }
180
1811500ns my @items;
182114µs1127µs my $indent = CGI::span( { class => 'foswikiWebIndent' }, '' );
# spent 127µs making 1 call to CGI::span
18312µs foreach my $item (@list) {
1844212µs my $line = $format;
1854238µs $line =~ s/\$web\b/$web/g;
18642127µs $line =~ s/\$name\b/$item/g;
1874297µs $line =~ s/\$qname/"$item"/g;
1884212µs my $indenteditem = $item;
1894210µs $indenteditem =~ s#/$##g;
1904228µs $indenteditem =~ s#\w+/#$indent#g;
1914256µs $line =~ s/\$indentedname/$indenteditem/g;
19242209µs my $mark = ( $selection =~ / \Q$item\E / ) ? $marker : '';
19342101µs $line =~ s/\$marker/$mark/g;
1944255µs push( @items, $line );
195 }
196141µs return join( $separator, @items );
197}
198
19914µs1;