~kosova/+junk/tuxfamily-twiki

« back to all changes in this revision

Viewing changes to foswiki/lib/Foswiki/Configure/PLUGINS.pm

  • Committer: James Michael DuPont
  • Date: 2009-07-18 19:58:49 UTC
  • Revision ID: jamesmikedupont@gmail.com-20090718195849-vgbmaht2ys791uo2
added foswiki

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# See bottom of file for license and copyright information
 
2
 
 
3
# Plug-in module for finding and handling plugins
 
4
package Foswiki::Configure::PLUGINS;
 
5
use base 'Foswiki::Configure::Pluggable';
 
6
 
 
7
use strict;
 
8
 
 
9
use Foswiki::Configure::Pluggable;
 
10
use Foswiki::Configure::Type;
 
11
use Foswiki::Configure::Value;
 
12
 
 
13
my $scanner = Foswiki::Configure::Type::load('SELECTCLASS');
 
14
 
 
15
sub new {
 
16
    my ($class) = @_;
 
17
 
 
18
    my $this = $class->SUPER::new('Installed Plugins');
 
19
    my %modules;
 
20
    my $classes      = $scanner->findClasses('Foswiki::Plugins::*Plugin');
 
21
    my $twikiclasses = $scanner->findClasses('TWiki::Plugins::*Plugin');
 
22
    push( @$classes, @$twikiclasses );
 
23
    foreach my $module (@$classes) {
 
24
        my $simple = $module;
 
25
        $simple =~ s/^.*::([^:]*)/$1/;
 
26
 
 
27
        # only add the first instance of any plugin, as only
 
28
        # the first can get loaded from @INC.
 
29
        $modules{$simple} = $module;
 
30
    }
 
31
    foreach my $module ( sort { lc( $a ) cmp lc( $b ) } keys %modules ) {
 
32
        $this->addChild(
 
33
            new Foswiki::Configure::Value(
 
34
                parent   => $this,
 
35
                keys     => '{Plugins}{' . $module . '}{Enabled}',
 
36
                typename => 'BOOLEAN'
 
37
            )
 
38
        );
 
39
        $this->addChild(
 
40
            new Foswiki::Configure::Value(
 
41
                parent   => $this,
 
42
                keys     => '{Plugins}{' . $module . '}{Module}',
 
43
                typename => 'STRING'
 
44
            )
 
45
        );
 
46
        $Foswiki::cfg{Plugins}{$module}{Module} ||= $modules{$module};
 
47
    }
 
48
    return $this;
 
49
}
 
50
 
 
51
1;
 
52
__DATA__
 
53
#
 
54
# Foswiki - The Free and Open Source Wiki, http://foswiki.org/
 
55
#
 
56
# Copyright (C) 2008 Foswiki Contributors. All Rights Reserved.
 
57
# Foswiki Contributors are listed in the AUTHORS file in the root
 
58
# of this distribution. NOTE: Please extend that file, not this notice.
 
59
#
 
60
# Additional copyrights apply to some or all of the code in this
 
61
# file as follows:
 
62
#
 
63
# Copyright (C) 2000-2006 TWiki Contributors. All Rights Reserved.
 
64
# TWiki Contributors are listed in the AUTHORS file in the root
 
65
# of this distribution. NOTE: Please extend that file, not this notice.
 
66
#
 
67
# This program is free software; you can redistribute it and/or
 
68
# modify it under the terms of the GNU General Public License
 
69
# as published by the Free Software Foundation; either version 2
 
70
# of the License, or (at your option) any later version. For
 
71
# more details read LICENSE in the root of this distribution.
 
72
#
 
73
# This program is distributed in the hope that it will be useful,
 
74
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
75
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
76
#
 
77
# As per the GPL, removal of this notice is prohibited.
 
78
#