lib/TWiki/Configure/UIs/TAGS.pm
changeset 0 414e01d06fd5
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/lib/TWiki/Configure/UIs/TAGS.pm	Sat Jan 26 15:50:53 2008 +0100
     1.3 @@ -0,0 +1,54 @@
     1.4 +#
     1.5 +# TWiki Enterprise Collaboration Platform, http://TWiki.org/
     1.6 +#
     1.7 +# Copyright (C) 2000-2006 TWiki Contributors.
     1.8 +#
     1.9 +# This program is free software; you can redistribute it and/or
    1.10 +# modify it under the terms of the GNU General Public License
    1.11 +# as published by the Free Software Foundation; either version 2
    1.12 +# of the License, or (at your option) any later version. For
    1.13 +# more details read LICENSE in the root of this distribution.
    1.14 +#
    1.15 +# This program is distributed in the hope that it will be useful,
    1.16 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.17 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    1.18 +#
    1.19 +# As per the GPL, removal of this notice is prohibited.
    1.20 +package TWiki::Configure::UIs::TAGS;
    1.21 +
    1.22 +use strict;
    1.23 +
    1.24 +use base 'TWiki::Configure::UI';
    1.25 +
    1.26 +use TWiki::Configure::Type;
    1.27 +use TWiki::Configure::Value;
    1.28 +
    1.29 +sub ui {
    1.30 +    my %modules;
    1.31 +    my $scanner = TWiki::Configure::Type::load('SELECTCLASS');
    1.32 +    my $classes = $scanner->findClasses('TWiki::Tags::*');
    1.33 +    foreach my $module ( @$classes ) {
    1.34 +        $module =~ s/^.*::([^:]*)/$1/;
    1.35 +        $TWiki::cfg{Tags}{$module}{Enabled} ||= 0;
    1.36 +        # only add the first instance of any tag, as only
    1.37 +        # the first can get loaded from @INC.
    1.38 +        unless( $modules{$module} ) {
    1.39 +            $modules{$module} = 1;
    1.40 +        }
    1.41 +    }
    1.42 +    my $block = '';
    1.43 +    foreach my $m ( sort keys %modules ) {
    1.44 +        my $value = new TWiki::Configure::Value(
    1.45 +            'BOOLEAN', '',
    1.46 +            # SMELL - i'm assuming that the Tag topic is in the SystemWeb :(
    1.47 +            # Which of course it isn't.
    1.48 +            "<a rel=\"nofollow\" href=\"$TWiki::cfg{ScriptUrlPath}/view$TWiki::cfg{ScriptSuffix}/$TWiki::cfg{SystemWebName}/$m\">$m</a>",
    1.49 +            '{Tags}{'.$m.'}{Enabled}'
    1.50 +           );
    1.51 +        $block .= $value->buildInputFields();
    1.52 +    }
    1.53 +
    1.54 +    return $block;
    1.55 +}
    1.56 +
    1.57 +1;