Changeset 3450


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

Location:
trunk/RenderListPlugin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/RenderListPlugin/data/System/RenderListPlugin.txt

    r3047 r3450  
    22---+ Render List Plugin 
    33 
    4 Render bullet lists in a variety of formats 
     4<!-- 
     5   * Set SHORTDESCRIPTION = Render bullet lists in a variety of formats 
     6--> 
     7%SHORTDESCRIPTION% 
    58 
    69---++ Syntax Rules 
     
    320323</td></tr></table> 
    321324 
    322 ---++ <nop>%TOPIC% Settings 
    323  
    324 Plugin settings are stored as [[%SYSTEMWEB%.PreferenceSettings][preference settings]]. To reference a plugin setting write ==%<nop>&lt;plugin&gt;_&lt;setting&gt;%==, i.e. ==%<nop>RENDERPLUGIN_SHORTDESCRIPTION%== 
    325  
    326    * One line description, is shown in the %SYSTEMWEB%.TextFormattingRules topic: 
    327       * Set SHORTDESCRIPTION = Render bullet lists in a variety of formats 
    328  
    329    * Debug plugin: (See output in =data/debug.txt=) 
    330       * Set DEBUG = 0 
    331  
    332    * Themes are named =&lt;SOMETHING&gt;_THEME= and contain a comma delimited list of render type with parameters: 
    333       * Set THREAD_THEME = tree, 1 
    334       * Set HOME_THEME = icon, 1, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/home.gif 
    335       * Set ORG_THEME = icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/home.gif 
    336       * Set GROUP_THEME = icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/group.gif 
    337       * Set EMAIL_THEME = icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/email.gif 
    338       * Set TREND_THEME = icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/trend.gif 
    339       * Set FILE_THEME = icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/file.gif 
     325---++ Themes 
     326Themes are defined by setting a [[%SYSTEMWEB%.PreferenceSettings][preference]] called =RENDERLISTPLUGIN_&lt;SOMETHING&gt;_THEME= (for example, =RENDERLISTPLUGIN_THREAD_THEME= ) and contain a comma-delimited list of render type and parameters. The default themes are: 
     327| *Theme* | *Render type* | 
     328| THREAD | tree, 1 | 
     329| HOME | icon, 1, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/home.gif | 
     330| ORG | icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/home.gif | 
     331| GROUP | icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/group.gif | 
     332| EMAIL | icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/email.gif | 
     333| TREND | icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/trend.gif | 
     334| FILE | icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/file.gif | 
    340335 
    341336---++ Plugin Installation Instructions 
    342  
    343 *Note:* You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the Foswiki server. 
    344  
    345    * Download the ZIP file from the Plugin Home (see below) 
    346    * Unzip ==%TOPIC%.zip== in your Foswiki installation directory. Content: 
    347      | *File:* | *Description:* | 
    348      | ==data/System/%TOPIC%.txt== | Plugin topic | 
    349      | ==data/System/%TOPIC%.txt,v== | Plugin topic repository | 
    350      | ==lib/Foswiki/Plugins/%TOPIC%.pm== | Plugin Perl module | 
    351      | ==pub/System/%TOPIC%/*.gif== | Image files for themes | 
    352    * Run the [[%SCRIPTURL%/configure%SCRIPTSUFFIX%][configure]] script to enable the Plugin 
     337%$INSTALL_INSTRUCTIONS% 
    353338   * Test if the installation was successful: See if above examples work 
    354339 
    355340---++ Plugin Info 
    356341 
    357 |  Copyright: | Copyright (C) 2006-2007 Peter Thoeny, peter@thoeny.org and TWiki 
    358 Contributors; 2008 Foswiki Contributors | 
     342|  Copyright: | Copyright (C) 2006-2007 Peter Thoeny, peter@thoeny.org and TWiki Contributors; 2008 Foswiki Contributors | 
    359343|  License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | 
    360344|  Plugin Version: | 16 Dec 2008 (2.1) | 
    361345|  Change History: | <!-- versions below in reverse order -->&nbsp; | 
     346|  15 Apr 2009: | 2.2: Crawford Currie. Moved default themes out of plugin topic for efficiency. | 
    362347|  16 Dec 2008: | 2.1: Kenneth Lavrsen. Foswiki version | 
    363348|  15 Jan 2008: | 2.0: Kenneth Lavrsen. No more reporting warnings in the error log when a render list starts at deeper level than 1 |  
     
    374359|  05 Dec 2003: | Fixed rendering issue with IE; added EMAIL_THEME | 
    375360|  02 Dec 2003: | Initial version | 
    376 |  CPAN Dependencies: | none | 
    377 |  Other Dependencies: | none | 
    378 |  Perl Version: | 5.008 | 
    379361|  Plugin Home: | http://foswiki.org/Extensions/%TOPIC% | 
    380362|  Support: | http://foswiki.org/Support/%TOPIC% | 
  • 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.