Skip to content

Commit

Permalink
Item1039: port CalendarPlugin
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/CalendarPlugin@2437 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Feb 10, 2009
1 parent 82ea4d7 commit 6e0b23d
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 39 deletions.
Expand Up @@ -366,7 +366,7 @@ __Note:__ You do not need to install anything on the browser to use this plugin.
| ==data/System/%TOPIC%.txt== | Plugin topic |
| ==data/System/%TOPIC%.txt,v== | Plugin topic repository |
| ==lib/Foswiki/Plugins/%TOPIC%.pm== | Plugin Perl module |
| ==pub/TWiki/%TOPIC%/exclam.gif== | Image file |
| ==pub/System/%TOPIC%/exclam.gif== | Image file |
* (Dakar) Visit =configure= in your TWiki installation, and enable the plugin in the {Plugins} section.
* Test if the installation was successful:
* You should see two calendars near the Event list above and a current month calendar below:
Expand Down
Expand Up @@ -24,7 +24,7 @@
# This is a plugin for showing a Month calendar with events.
#
# =========================
package TWiki::Plugins::CalendarPlugin;
package Foswiki::Plugins::CalendarPlugin;


# use strict;
Expand Down Expand Up @@ -83,7 +83,7 @@ sub initPlugin
# =========================
sub initDefaults
{
my $webColor = &TWiki::Func::getPreferencesValue('WEBBGCOLOR', $web) ||
my $webColor = &Foswiki::Func::getPreferencesValue('WEBBGCOLOR', $web) ||
'wheat' ;

# reasonable defaults to produce a small calendar
Expand Down Expand Up @@ -140,7 +140,7 @@ sub initDefaults
my $v;
foreach $option (keys %defaults) {
# read defaults from CalendarPlugin topic
$v = &TWiki::Func::getPreferencesValue("CALENDARPLUGIN_\U$option\E") || undef;
$v = &Foswiki::Func::getPreferencesValue("CALENDARPLUGIN_\U$option\E") || undef;
$defaults{$option} = $v if defined($v);
}
$defaultsInitialized = 1;
Expand All @@ -158,10 +158,10 @@ sub readTopicText
{
my( $theWeb, $theTopic ) = @_;
my $text = '';
if( $TWiki::Plugins::VERSION >= 1.010 ) {
$text = &TWiki::Func::readTopicText( $theWeb, $theTopic, '', 1 );
if( $Foswiki::Plugins::VERSION >= 1.010 ) {
$text = &Foswiki::Func::readTopicText( $theWeb, $theTopic, '', 1 );
} else {
$text = &TWiki::Func::readTopic( $theWeb, $theTopic );
$text = &Foswiki::Func::readTopic( $theWeb, $theTopic );
}
# return raw topic text, including meta data
return $text;
Expand All @@ -172,7 +172,7 @@ sub expandIncludedEvents
{
my( $theAttributes, $theWeb, $theTopic, @theProcessedTopics ) = @_;

my $webTopic = &TWiki::Func::extractNameValuePair( $theAttributes );
my $webTopic = &Foswiki::Func::extractNameValuePair( $theAttributes );
if( $webTopic =~ m|^([^.]+)[\.\/](.*)$| ) {
$theWeb = $1;
$theTopic = $2;
Expand Down Expand Up @@ -294,13 +294,13 @@ sub handleCalendar
my $orgtopic = $options{topic};
my $orgweb = $options{web};
foreach $option (keys %options) {
$v = &TWiki::Func::extractNameValuePair($attributes,$option) || undef;
$v = &Foswiki::Func::extractNameValuePair($attributes,$option) || undef;
$options{$option} = $v if defined($v);
}

# get GMT offset
my ($currentYear, $currentMonth, $currentDay, $currentHour, $currentMinute, $currentSecond) = Today_and_Now(1);
my $gmtoff = scalar &TWiki::Func::extractNameValuePair( $attributes, 'gmtoffset' );
my $gmtoff = scalar &Foswiki::Func::extractNameValuePair( $attributes, 'gmtoffset' );
if ( $gmtoff ) {
$gmtoff += 0;
($currentYear,
Expand All @@ -319,8 +319,8 @@ sub handleCalendar


# read fixed months/years
my $m = scalar &TWiki::Func::extractNameValuePair( $attributes, 'month' );
my $y = scalar &TWiki::Func::extractNameValuePair( $attributes, 'year' );
my $m = scalar &Foswiki::Func::extractNameValuePair( $attributes, 'month' );
my $y = scalar &Foswiki::Func::extractNameValuePair( $attributes, 'year' );

# Check syntax of year parameter. It can be blank (meaning the
# current year), an absolute number, or a relative number (e.g.,
Expand Down Expand Up @@ -359,7 +359,7 @@ sub handleCalendar
}

# read and set the desired language
my $lang = scalar &TWiki::Func::extractNameValuePair( $attributes, 'lang' );
my $lang = scalar &Foswiki::Func::extractNameValuePair( $attributes, 'lang' );
$lang = $lang ? $lang : $defaults{lang};
Date::Calc::Language(Date::Calc::Decode_Language($lang));

Expand All @@ -371,7 +371,7 @@ sub handleCalendar
# Process "aslist" parameter (if set, display the calendar as a
# list, not as a table)

my $asList = scalar &TWiki::Func::extractNameValuePair( $attributes,
my $asList = scalar &Foswiki::Func::extractNameValuePair( $attributes,
'aslist' );

if ($asList) {
Expand Down Expand Up @@ -412,14 +412,14 @@ sub handleCalendar
# Process "days" parameter (goes with aslist=1; specifies the
# number of days of calendar data to list). Default is 1.

my $numDays = scalar &TWiki::Func::extractNameValuePair( $attributes,
my $numDays = scalar &Foswiki::Func::extractNameValuePair( $attributes,
'days' );
$numDays = 1 if (! $numDays);

# Process "months" parameter (goes with aslist=0; specifies the
# number of months of calendar data to list) Default is 1.

my $numMonths = scalar &TWiki::Func::extractNameValuePair( $attributes, 'months' );
my $numMonths = scalar &Foswiki::Func::extractNameValuePair( $attributes, 'months' );
$numMonths = 1 if (! $numMonths);

# Figure out last month/year to display. This calculation depends
Expand Down Expand Up @@ -453,7 +453,7 @@ sub handleCalendar
my $text = getTopicText($theTopic, $theWeb, $refText, %options);

# recursively expand includes
# (don't rely on TWiki::Func::expandCommonVariables to avoid deep recursion)
# (don't rely on Foswiki::Func::expandCommonVariables to avoid deep recursion)
$text =~ s/%INCLUDE{(.*?)}%/&expandIncludedEvents( $1, $options{web}, $options{topic}, () )/geo;

# Before this was modified to do multiple months, there was a
Expand Down Expand Up @@ -497,7 +497,7 @@ sub handleCalendar
}

# header color
my $webColor = &TWiki::Func::getPreferencesValue('WEBBGCOLOR',
my $webColor = &Foswiki::Func::getPreferencesValue('WEBBGCOLOR',
$options{web}) ||
'wheat' ;
# Highlight today
Expand Down Expand Up @@ -588,7 +588,7 @@ sub handleCalendar
}
}
};
&TWiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
&Foswiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
}
# then collect all intervals without year
@days = fetchDays( "$date_rx\\s+-\\s+$date_rx", \@bullets );
Expand Down Expand Up @@ -620,7 +620,7 @@ sub handleCalendar
}
}
};
&TWiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
&Foswiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
}
# first collect all dates with year
@days = fetchDays( "$full_date_rx", \@bullets );
Expand All @@ -631,7 +631,7 @@ sub handleCalendar
&highlightDay( $cal, $dd, $descr, %options);
}
};
&TWiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
&Foswiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
}
# collect all anniversary dates
@days = fetchDays( "$anniversary_date_rx", \@bullets );
Expand All @@ -655,7 +655,7 @@ sub handleCalendar
&highlightDay( $cal, $dd, $descr . $elapsed_indicator, %options);
}
};
&TWiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
&Foswiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
}
# then collect all dates without year
@days = fetchDays( "$date_rx", \@bullets );
Expand All @@ -671,7 +671,7 @@ sub handleCalendar
&highlightDay( $cal, $dd, $descr, %options );
}
};
&TWiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
&Foswiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
}

# collect monthly repeaters
Expand All @@ -697,7 +697,7 @@ sub handleCalendar
&highlightDay( $cal, $hd, $descr, %options );
}
};
&TWiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
&Foswiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
}

# collect weekly repeaters with start and end dates
Expand All @@ -721,7 +721,7 @@ sub handleCalendar
($ny, $nm, $hd) = Add_Delta_Days($y, $m, $hd, 7);
} while ($ny == $y && $nm == $m);
};
&TWiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
&Foswiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
}

# collect weekly repeaters with start dates
Expand All @@ -744,7 +744,7 @@ sub handleCalendar
($ny, $nm, $hd) = Add_Delta_Days($y, $m, $hd, 7);
} while ($ny == $y && $nm == $m);
};
&TWiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
&Foswiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
}

# collect weekly repeaters
Expand All @@ -765,7 +765,7 @@ sub handleCalendar
($ny, $nm, $hd) = Add_Delta_Days($y, $m, $hd, 7);
} while ($ny == $y && $nm == $m);
};
&TWiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
&Foswiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
}

# collect num-day-mon repeaters
Expand Down Expand Up @@ -794,7 +794,7 @@ sub handleCalendar
}
}
};
&TWiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
&Foswiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
}

# collect periodic repeaters with start and end dates
Expand All @@ -820,7 +820,7 @@ sub handleCalendar
($yy1, $mm1, $dd1) = Add_Delta_Days($yy1, $mm1, $dd1, $p);
}
};
&TWiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
&Foswiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
}

# collect periodic repeaters
Expand All @@ -846,7 +846,7 @@ sub handleCalendar
}
}
};
&TWiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
&Foswiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
}

# collect date monthly repeaters
Expand All @@ -863,7 +863,7 @@ sub handleCalendar
&highlightDay( $cal, $dd, $descr, %options );
}
};
&TWiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
&Foswiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
}

# Format the calendar as either a list or a table
Expand Down Expand Up @@ -1004,7 +1004,7 @@ sub formatDate
Day_of_Year
Month_to_Text);

&TWiki::Func::writeDebug("formatDate: $formatString, $date") if $debug;
&Foswiki::Func::writeDebug("formatDate: $formatString, $date") if $debug;
my $outputTimeZone = 'gmtime'; # FIXME: Should be configurable
my $value = ''; # Return value for the function
my ($year, $mon, $day) = Add_Delta_Days(1, 1, 1, $date - 1);
Expand Down Expand Up @@ -1037,7 +1037,7 @@ sub formatDate

# HTTP header format, e.g. "Thu, 23 Jul 1998 07:21:56 EST"
# - based on RFC 2616/1123 and HTTP::Date; also used
# by TWiki::Net for Date header in emails.
# by Foswiki::Net for Date header in emails.
$formatString =~ s/\$(http|email)/\$wday, \$day \$month \$year \$hour:\$min:\$sec \$tz/gi;

# ISO Format, see spec at http://www.w3.org/TR/NOTE-datetime
Expand All @@ -1051,7 +1051,7 @@ sub formatDate
$formatString =~ s/\$iso/\$year-\$mo-\$dayT\$hour:\$min$tzd/gi;

# The matching algorithms here are the same as those in
# TWiki::Time::formatTime()
# Foswiki::Time::formatTime()

$value = $formatString;
$value =~ s/\$seco?n?d?s?/sprintf('%.2u',$sec)/gei;
Expand Down
3 changes: 3 additions & 0 deletions lib/Foswiki/Plugins/CalendarPlugin/MANIFEST
@@ -0,0 +1,3 @@
data/System/CalendarPlugin.txt 0660
lib/Foswiki/Plugins/CalendarPlugin.pm 0440
pub/System/CalendarPlugin/exclam.gif 0660
Expand Up @@ -24,12 +24,12 @@ BEGIN
}
}

use TWiki::Contrib::Build;
use Foswiki::Contrib::Build;

# Declare our build package
{ package CalendarPluginBuild;

@CalendarPluginBuild::ISA = ( "TWiki::Contrib::Build" );
@CalendarPluginBuild::ISA = ( "Foswiki::Contrib::Build" );

sub new {
my $class = shift;
Expand Down
3 changes: 0 additions & 3 deletions lib/TWiki/Plugins/CalendarPlugin/MANIFEST

This file was deleted.

File renamed without changes

0 comments on commit 6e0b23d

Please sign in to comment.