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