Skip to content

Commit

Permalink
Item1652: added missing BASEWEB/BASETOPIC substitutions
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/HolidaylistPlugin@4140 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
DanielRohde authored and DanielRohde committed Jun 15, 2009
1 parent 339321d commit 887ad65
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions lib/Foswiki/Plugins/HolidaylistPlugin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ use vars qw(
%rendererCache
);

# This should always be $Rev: 18100 $ so that TWiki can determine the checked-in
# This should always be $Rev: 18101 $ so that TWiki can determine the checked-in
# status of the plugin. It is used by the build automation tools, so
# you should leave it alone.
$VERSION = '$Rev: 18100 $';
$VERSION = '$Rev: 18101 $';

# This is a free-form string you can use to "name" your own plugin version.
# It is *not* used by the build automation tools, but is reported as part
Expand Down Expand Up @@ -1542,9 +1542,12 @@ sub getTopicText() {
}
}

$text =~ s/%BASETOPIC%/${theTopic}/sg;
$text =~ s/%BASEWEB%/${theWeb}/sg;
$text =~ s/%INCLUDE{(.*?)}%/&expandIncludedEvents($1, \@processedTopics, $web, $topic)/geo;
$text =~s/\%HOLIDAYLIST({(.*?)})?%//sg;
$text = Foswiki::Func::expandCommonVariables($text,$web,$topic);


return $text;

Expand All @@ -1566,35 +1569,39 @@ sub readTopicText
# =========================
sub expandIncludedEvents
{
my( $theAttributes, $theProcessedTopicsRef, $theWeb, $theTopic ) = @_;
my( $theAttributes, $theProcessedTopicsRef, $web, $topic ) = @_;

my $webTopic = Foswiki::Func::expandCommonVariables( Foswiki::Func::extractNameValuePair( $theAttributes ), $theTopic, $theWeb );
my $section = Foswiki::Func::expandCommonVariables( Foswiki::Func::extractNameValuePair( $theAttributes, 'section'), $theTopic, $theWeb );
my $pattern = Foswiki::Func::expandCommonVariables( Foswiki::Func::extractNameValuePair( $theAttributes, 'pattern'), $theTopic, $theWeb );
my $webTopic = Foswiki::Func::expandCommonVariables( Foswiki::Func::extractNameValuePair( $theAttributes ), $topic, $web );
my $section = Foswiki::Func::expandCommonVariables( Foswiki::Func::extractNameValuePair( $theAttributes, 'section'), $topic, $web );
my $pattern = Foswiki::Func::expandCommonVariables( Foswiki::Func::extractNameValuePair( $theAttributes, 'pattern'), $topic, $web );


if( $webTopic =~ /^([^\.]+)[\.\/](.*)$/ ) {
$theWeb = $1;
$theTopic = $2;
$web = $1;
$topic = $2;
} else {
$theTopic = $webTopic;
$topic = $webTopic;
}

# prevent recursive loop:
grep (/^\Q$theWeb.$theTopic\E$/, @{$theProcessedTopicsRef}) and return "";
grep (/^\Q$web.$topic\E$/, @{$theProcessedTopicsRef}) and return "";

push( @{$theProcessedTopicsRef}, "$theWeb.$theTopic" );
push( @{$theProcessedTopicsRef}, "$web.$topic" );

my $text = &readTopicText( $theWeb, $theTopic );
my $text = &readTopicText( $web, $topic );

$text = getTopicSectionText($text, $section) if (defined $section && $section ne "");
$text = getTopicPatternText($text, $pattern) if (defined $pattern && $pattern ne "");


$text = getTopicIncludeText($text);

# fix base topic:
$text =~ s/%BASETOPIC%/${theTopic}/sg;
$text =~ s/%BASEWEB%/${theWeb}/sg;

# recursively expand includes:
$text =~ s/%INCLUDE{(.*?)}%/&expandIncludedEvents( $1, $theProcessedTopicsRef, $theWeb, $theTopic )/geo;
$text =~ s/%INCLUDE{(.*?)}%/&expandIncludedEvents( $1, $theProcessedTopicsRef, $web, $topic )/geo;

# expand common variables:
$text =~ s/%HOLIDAYLIST({[^}]*})?%//sg; ## prevent an endless recursion
Expand Down

0 comments on commit 887ad65

Please sign in to comment.