lib/TWiki/Configure/PLUGINS.pm
author Colas Nahaboo <colas@nahaboo.net>
Sat, 26 Jan 2008 15:50:53 +0100
changeset 0 414e01d06fd5
permissions -rw-r--r--
RELEASE 4.2.0 freetown
colas@0
     1
#
colas@0
     2
# TWiki Enterprise Collaboration Platform, http://TWiki.org/
colas@0
     3
#
colas@0
     4
# Copyright (C) 2000-2006 TWiki Contributors.
colas@0
     5
#
colas@0
     6
# This program is free software; you can redistribute it and/or
colas@0
     7
# modify it under the terms of the GNU General Public License
colas@0
     8
# as published by the Free Software Foundation; either version 2
colas@0
     9
# of the License, or (at your option) any later version. For
colas@0
    10
# more details read LICENSE in the root of this distribution.
colas@0
    11
#
colas@0
    12
# This program is distributed in the hope that it will be useful,
colas@0
    13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
colas@0
    14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
colas@0
    15
#
colas@0
    16
# As per the GPL, removal of this notice is prohibited.
colas@0
    17
#
colas@0
    18
# Plug-in module for finding and handling plugins
colas@0
    19
package TWiki::Configure::PLUGINS;
colas@0
    20
use base 'TWiki::Configure::Pluggable';
colas@0
    21
colas@0
    22
use strict;
colas@0
    23
colas@0
    24
use TWiki::Configure::Pluggable;
colas@0
    25
use TWiki::Configure::Type;
colas@0
    26
use TWiki::Configure::Value;
colas@0
    27
colas@0
    28
my $scanner = TWiki::Configure::Type::load('SELECTCLASS');
colas@0
    29
colas@0
    30
sub new {
colas@0
    31
    my ($class) = @_;
colas@0
    32
colas@0
    33
    my $this = $class->SUPER::new('Installed Plugins');
colas@0
    34
    my %modules;
colas@0
    35
    my $classes = $scanner->findClasses('TWiki::Plugins::*Plugin');
colas@0
    36
    foreach my $module ( @$classes ) {
colas@0
    37
        $module =~ s/^.*::([^:]*)/$1/;
colas@0
    38
        # only add the first instance of any plugin, as only
colas@0
    39
        # the first can get loaded from @INC.
colas@0
    40
        $modules{$module} = 1;
colas@0
    41
    }
colas@0
    42
    foreach my $module (sort { lc $a cmp lc $b } keys %modules) {
colas@0
    43
        $this->addChild(
colas@0
    44
            new TWiki::Configure::Value(
colas@0
    45
                parent=>$this,
colas@0
    46
                keys => '{Plugins}{'.$module.'}{Enabled}',
colas@0
    47
                typename => 'BOOLEAN'));
colas@0
    48
    }
colas@0
    49
    return $this;
colas@0
    50
}
colas@0
    51
colas@0
    52
1;