Ignore:
Timestamp:
04/15/09 17:38:37 (3 years ago)
Author:
CrawfordCurrie
Message:

Item1383: make plugin get its preferences from global preferences, instead of from the plugin topic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/RenderListPlugin/lib/Foswiki/Plugins/RenderListPlugin.pm

    r1408 r3450  
    2323# ========================= 
    2424use vars qw( 
    25         $web $topic $user $installWeb $VERSION $RELEASE $pluginName 
    26         $debug $pubUrl $attachUrl 
     25        $web $topic $user $installWeb 
     26        $pubUrl $attachUrl 
    2727    ); 
    2828 
    29 $VERSION = '$Rev: 16234 $'; 
    30 $RELEASE = '2.1'; 
    31 $pluginName = 'RenderListPlugin';  # Name of this Plugin 
     29our $VERSION = '$Rev: 16234 $'; 
     30our $RELEASE = '2.1'; 
     31our $pluginName = 'RenderListPlugin';  # Name of this Plugin 
     32our $NO_PREFS_IN_TOPIC = 1; 
     33our $SHORTDESCRIPTION = 'Render bullet lists in a variety of formats'; 
     34 
     35our %defaultThemes = ( 
     36    THREAD => 'tree, 1', 
     37    HOME   => 'icon, 1, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/home.gif', 
     38    ORG    => 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/home.gif', 
     39    GROUP  => 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/group.gif', 
     40    EMAIL  => 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/email.gif', 
     41    TREND  => 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/trend.gif', 
     42    FILE   => 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/file.gif', 
     43); 
    3244 
    3345# ========================= 
     
    4254    } 
    4355 
    44     # Get plugin debug flag 
    45     $debug = Foswiki::Func::getPreferencesFlag( "\U$pluginName\E_DEBUG" ); 
    46  
    4756    # one time initialization 
    4857    $pubUrl = Foswiki::Func::getUrlHost() . Foswiki::Func::getPubUrlPath(); 
     
    5059 
    5160    # Plugin correctly initialized 
    52     Foswiki::Func::writeDebug( "- Foswiki::Plugins::${pluginName}::initPlugin( $web.$topic ) is OK" ) if $debug; 
    5361    return 1; 
    5462} 
     
    5866{ 
    5967### my ( $text, $web ) = @_;   # do not uncomment, use $_[0], $_[1] instead 
    60  
    61     Foswiki::Func::writeDebug( "- ${pluginName}::startRenderingHandler( $_[1] )" ) if $debug; 
    6268 
    6369    # This handler is called by getRenderedVersion just before the line loop 
     
    8692    my $theme = &Foswiki::Func::extractNameValuePair( $theAttr, "theme" ) || 
    8793                &Foswiki::Func::extractNameValuePair( $theAttr ); 
    88     $theme = "RENDERLISTPLUGIN_" . uc( $theme ) . "_THEME"; 
    89     $theme = &Foswiki::Func::getPreferencesValue( $theme ) || "unrecognized theme type"; 
     94    $theme = uc($theme || ''); 
     95    if (defined $defaultThemes{$theme}) { 
     96        $theme = $defaultThemes{$theme}; 
     97    } else { 
     98        $theme = "RENDERLISTPLUGIN_${theme}_THEME"; 
     99        $theme = &Foswiki::Func::getPreferencesValue( $theme ) 
     100          || "unrecognized theme type"; 
     101    } 
    90102    my ( $type, $params ) = split( /, */, $theme, 2 ); 
    91103    $type = lc( $type ); 
Note: See TracChangeset for help on using the changeset viewer.