Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/UpdatesPlugin.pm |
Statements | Executed 12 statements in 573µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 26µs | 34µs | BEGIN@18 | Foswiki::Plugins::UpdatesPlugin::
1 | 1 | 1 | 23µs | 80µs | initPlugin | Foswiki::Plugins::UpdatesPlugin::
1 | 1 | 1 | 22µs | 42µs | BEGIN@19 | Foswiki::Plugins::UpdatesPlugin::
1 | 1 | 1 | 10µs | 10µs | BEGIN@21 | Foswiki::Plugins::UpdatesPlugin::
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 | # UpdatesPlugin is Copyright (C) 2011 Foswiki Contributors | ||||
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. | ||||
9 | # | ||||
10 | # This program is distributed in the hope that it will be useful, | ||||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
13 | # GNU General Public License for more details, published at | ||||
14 | # http://www.gnu.org/copyleft/gpl.html | ||||
15 | |||||
16 | package Foswiki::Plugins::UpdatesPlugin; | ||||
17 | |||||
18 | 2 | 52µs | 2 | 42µs | # spent 34µs (26+8) within Foswiki::Plugins::UpdatesPlugin::BEGIN@18 which was called:
# once (26µs+8µs) by Foswiki::Plugin::BEGIN@2.20 at line 18 # spent 34µs making 1 call to Foswiki::Plugins::UpdatesPlugin::BEGIN@18
# spent 8µs making 1 call to strict::import |
19 | 2 | 51µs | 2 | 62µs | # spent 42µs (22+20) within Foswiki::Plugins::UpdatesPlugin::BEGIN@19 which was called:
# once (22µs+20µs) by Foswiki::Plugin::BEGIN@2.20 at line 19 # spent 42µs making 1 call to Foswiki::Plugins::UpdatesPlugin::BEGIN@19
# spent 20µs making 1 call to warnings::import |
20 | |||||
21 | 2 | 441µs | 1 | 10µs | # spent 10µs within Foswiki::Plugins::UpdatesPlugin::BEGIN@21 which was called:
# once (10µs+0s) by Foswiki::Plugin::BEGIN@2.20 at line 21 # spent 10µs making 1 call to Foswiki::Plugins::UpdatesPlugin::BEGIN@21 |
22 | |||||
23 | 1 | 2µs | our $VERSION = '$Rev$'; | ||
24 | 1 | 1µs | our $RELEASE = '0.10'; | ||
25 | 1 | 1µs | our $SHORTDESCRIPTION = 'Checks Foswiki.org for updates'; | ||
26 | 1 | 1µs | our $NO_PREFS_IN_TOPIC = 1; | ||
27 | |||||
28 | # spent 80µs (23+57) within Foswiki::Plugins::UpdatesPlugin::initPlugin which was called:
# once (23µs+57µs) 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 | ||||
29 | |||||
30 | # bail out if not an admin and not in view mode | ||||
31 | 1 | 16µs | 1 | 57µs | return 1 unless Foswiki::Func::isAnAdmin() && Foswiki::Func::getContext()->{view}; # spent 57µs making 1 call to Foswiki::Func::isAnAdmin |
32 | |||||
33 | my $request = Foswiki::Func::getRequestObject(); | ||||
34 | my $cookie = $request->cookie("FOSWIKI_UPDATESPLUGIN"); | ||||
35 | |||||
36 | return 1 if defined($cookie) && $cookie <= 0; # 0: DoNothing | ||||
37 | |||||
38 | Foswiki::Func::readTemplate("updatesplugin"); | ||||
39 | |||||
40 | my $installedPlugins = ''; | ||||
41 | |||||
42 | # we already know that the admin has to do something. so don't search again. | ||||
43 | # this happens when the admin continues to click around but did not action | ||||
44 | # on the info banner. | ||||
45 | $installedPlugins = Foswiki::Func::expandTemplate("installedplugins") | ||||
46 | unless defined($cookie); | ||||
47 | |||||
48 | my $css = Foswiki::Func::expandTemplate("css"); | ||||
49 | my $messageTmpl = Foswiki::Func::expandTemplate("messagetmpl"); | ||||
50 | |||||
51 | require Foswiki::Plugins::JQueryPlugin; | ||||
52 | |||||
53 | Foswiki::Plugins::JQueryPlugin::createPlugin("cookie"); | ||||
54 | Foswiki::Plugins::JQueryPlugin::createPlugin("tmpl"); | ||||
55 | |||||
56 | # SMELL read Foswiki::cfg{ExtensionsRepositories} and generate the report url on its base | ||||
57 | my $reportUrl = $Foswiki::cfg{UpdatesPlugin}{ReportUrl} | ||||
58 | || "http://foswiki.org/Extensions/UpdatesPluginReport"; | ||||
59 | |||||
60 | my $configureUrl = $Foswiki::cfg{UpdatesPlugin}{ConfigureUrl} | ||||
61 | || Foswiki::Func::getScriptUrl(undef, undef, "configure"); | ||||
62 | |||||
63 | Foswiki::Func::addToZone("head", "UPDATESPLUGIN::META", <<META); | ||||
64 | <meta name="foswiki.UPDATESPLUGIN::REPORTURL" content="$reportUrl" /> | ||||
65 | <meta name="foswiki.UPDATESPLUGIN::CONFIGUREURL" content="$configureUrl" /> | ||||
66 | $css | ||||
67 | $messageTmpl | ||||
68 | META | ||||
69 | |||||
70 | Foswiki::Func::addToZone( "script", "UPDATESPLUGIN::JS", <<JS, "JQUERYPLUGIN::FOSWIKI, JQUERYPLUGIN::COOKIE, JQUERYPLUGIN::TMPL" ); | ||||
71 | $installedPlugins | ||||
72 | <script src="%PUBURLPATH%/%SYSTEMWEB%/UpdatesPlugin/jquery.updates.js"></script> | ||||
73 | JS | ||||
74 | |||||
75 | return 1; | ||||
76 | } | ||||
77 | |||||
78 | 1 | 6µs | 1; |