Skip to content

Commit

Permalink
Item699: don't get/set prefs in early init - the prefs object isn't f…
Browse files Browse the repository at this point in the history
…ully initialized yet

git-svn-id: http://svn.foswiki.org/trunk/NatSkinPlugin@1877 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Jan 8, 2009
1 parent a579232 commit fccf12b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion data/TWiki/NatSkinPlugin.txt
Expand Up @@ -337,7 +337,7 @@ The following variables can be used in the format string:
| Plugin Author: | Michael Daum |
| Copyright ©: | 2003-2009, Michael Daum http://michaeldaumconsulting.com |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
| Plugin Version: | v3.00-pre30 |
| Plugin Version: | v3.00-pre31 |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 07 Jan 2009: | added workaround to trick in <nop>NatSkin css into <nop>TinyMCE; \
several workarounds to be a hybrid skin for twiki&foswiki; \
Expand Down
28 changes: 10 additions & 18 deletions lib/TWiki/Plugins/NatSkinPlugin.pm
Expand Up @@ -50,7 +50,7 @@ $STARTWW = qr/^|(?<=[\s\(])/m;
$ENDWW = qr/$|(?=[\s\,\.\;\:\!\?\)])/m;

$VERSION = '$Rev$';
$RELEASE = '3.00-pre30';
$RELEASE = '3.00-pre31';
$NO_PREFS_IN_TOPIC = 1;
$SHORTDESCRIPTION = 'Theming engine for NatSkin';

Expand All @@ -72,21 +72,6 @@ sub writeDebug {
#TWiki::Func::writeDebug("- NatSkinPlugin - $_[0]");
}

###############################################################################
sub earlyInitPlugin {
# hack patternskin variables

my $skin = TWiki::Func::getSkin();
if ($skin =~ /\bnat\b/) {
TWiki::Func::setPreferencesValue('TWIKISTYLEURL', '%PUBURLPATH%/%TWIKIWEB%/NatSkin/BaseStyle.css');
TWiki::Func::setPreferencesValue('TWIKICOLORSURL', '%NATSTYLEURL%');
TWiki::Func::setPreferencesValue('FOSWIKI_STYLE_URL', '%PUBURLPATH%/%TWIKIWEB%/NatSkin/BaseStyle.css');
TWiki::Func::setPreferencesValue('FOSWIKI_COLORS_URL', '%NATSTYLEURL%');
}

return 0;
}

###############################################################################
sub initPlugin {
($baseTopic, $baseWeb, $currentUser) = @_;
Expand All @@ -113,6 +98,14 @@ sub initPlugin {
TWiki::Func::registerTagHandler('CURREV', \&renderCurRevision);
TWiki::Func::registerTagHandler('NATMAXREV', \&renderMaxRevision);

my $skin = TWiki::Func::getSkin();
if ($skin =~ /\bnat\b/) {
TWiki::Func::setPreferencesValue('TWIKISTYLEURL', '%PUBURLPATH%/%TWIKIWEB%/NatSkin/BaseStyle.css');
TWiki::Func::setPreferencesValue('TWIKICOLORSURL', '%NATSTYLEURL%');
TWiki::Func::setPreferencesValue('FOSWIKI_STYLE_URL', '%PUBURLPATH%/%TWIKIWEB%/NatSkin/BaseStyle.css');
TWiki::Func::setPreferencesValue('FOSWIKI_COLORS_URL', '%NATSTYLEURL%');
}

# preference values
$detectExternalLinks = TWiki::Func::getPreferencesFlag('EXTERNALLINKS');
$useEmailObfuscator = TWiki::Func::getPreferencesFlag('OBFUSCATEEMAIL');
Expand Down Expand Up @@ -148,9 +141,8 @@ sub initPlugin {
} else {
# disable during register context
my $theContentType = $request->param('contenttype');
my $skin = TWiki::Func::getSkin();
if ($skinState{'action'} =~ /^(register|mailnotif|resetpasswd)/ ||
$skin =~ /^rss/ ||
$skin =~ /^(rss|atom)/ ||
$theContentType) {
$useEmailObfuscator = 0;
}
Expand Down

0 comments on commit fccf12b

Please sign in to comment.