lib/TWiki/Configure/Pluggable.pm
changeset 0 414e01d06fd5
equal deleted inserted replaced
-1:000000000000 0:414e01d06fd5
       
     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 # A placeholder in a configuration representing a pluggable UI block.
       
    19 # A pluggable block has special semantics, may have a special UI which
       
    20 # may override the behaviors of a standard item. Normally pluggables
       
    21 # are sections, containing values and other sections. If this isn't
       
    22 # appropriate, you will have to implement a new visit() function for
       
    23 # saving configuration data.
       
    24 package TWiki::Configure::Pluggable;
       
    25 
       
    26 use strict;
       
    27 
       
    28 use TWiki::Configure::Section;
       
    29 
       
    30 use base 'TWiki::Configure::Section';
       
    31 
       
    32 sub load {
       
    33     my ($name) = @_;
       
    34 
       
    35     my $modelName = 'TWiki::Configure::'.$name;
       
    36     eval "use $modelName";
       
    37     Carp::confess $@ if $@;
       
    38 
       
    39     no strict 'refs';
       
    40     my $model = $modelName->new();
       
    41     use strict 'refs';
       
    42 
       
    43     return $model;
       
    44 }
       
    45 
       
    46 1;