# # TWiki WikiClone ($wikiversion has version info) # # Copyright (C) 2001 Dresdner Kleinwort Wasserstein # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details, published at # http://www.gnu.org/copyleft/gpl.html # # ========================= # # This is the plugin is required by the Tiger skin # ========================= package TWiki::Plugins::TigerSkinPlugin; # ========================= use vars qw( $web $topic $user $installWeb $VERSION $debug $renderingWeb $isGuest $revsToShow $skin ); #$web $topic $user $installWeb $VERSION $debug $VERSION = '1.000'; # ========================= sub initPlugin { ( $topic, $web, $user, $installWeb ) = @_; # check for Plugins.pm versions if( $TWiki::Plugins::VERSION < 1 ) { &TWiki::Func::writeWarning( "Version mismatch between TigerSkinPlugin and Plugins.pm" ); return 0; } $renderingWeb = $web; # Get plugin debug flag $debug = &TWiki::Func::getPreferencesFlag( "TIGERSKINPLUGIN_DEBUG" ); $revsToShow = &TWiki::Func::getPreferencesValue( "TIGERSKINPLUGIN_NUMREVISIONS" ) || 5; $isGuest = &TWiki::Func::isGuest(); # Plugin correctly initialized &TWiki::Func::writeDebug( "- TWiki::Plugins::TigerSkinPlugin::initPlugin( $web.$topic ) is OK" ) if $debug; return 1; } sub notHandle { my $skin = &TWiki::Func::getSkin(); return ( $skin ne "tiger" && $skin ne "cat" ); } # ========================= sub commonTagsHandler { ### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead &TWiki::Func::writeDebug( "- TigerSkinPlugin::commonTagsHandler( $_[2].$_[1] )" ) if $debug; return if( notHandle() ); # This is the place to define customized tags and variables # Called by sub handleCommonTags, after %INCLUDE:"..."% $_[0] =~ s/%LOGO%/&getIcon( $web, $topic, "tiger" )/geo; $_[0] =~ s/%TIGERLOGON%/&dispUser()/geo; $_[0] =~ s/%LEFTMENU%/&getMenu()/geo; $_[0] =~ s/%SHOWALL%/&showMenu("all")/geo; $_[0] =~ s/%SHOWVIEW%/&showMenu("view")/geo; } # ========================= sub dispUser # conditional on presence of SessionPlugin { my $dispUser = ""; if( &TWiki::Func::topicExists( &TWiki::Func::getTwikiWebname(), "SessionPlugin" ) && $isGuest ) { $dispUser = "%SESSIONLOGON%"; } else { my $wikiName = &TWiki::Func::getWikiName(); my $mainWeb = &TWiki::Func::getMainWebname(); $dispUser = "$wikiName" } return $dispUser; } # ================================= sub showMenu { my( $scope ) = @_; my $res = "on"; if( $scope eq "view" ) { $res = "none"; } # Only do check if there are permission set on this Web or if user logged on already my $perm = TWiki::Func::permissionsSet( $web ); if( $perm || !$isGuest ) { my $auth = TWiki::Func::checkAccessPermission( "change", &TWiki::Func::getWikiUserName, "", $topic, $web ); if( ! $auth ) { if( $scope eq "all" ) { $res= "none"; } else { $res = "on"; } } } return $res; } # =============================== sub getMenu { my( $menu, $meta ); if( TWiki::Func::topicExists( $web, "WebMenu" ) ) { ( $meta, $menu ) = &TWiki::Func::readTopic( $web, "WebMenu" ); } else { my $twikiWebname = &TWiki::Func::getTwikiWebname(); ( $meta, $menu ) = &TWiki::Func::readTopic( $twikiWebname, "WebMenu" ); } my $res = "