diff --git a/docs/upgrades/upgrade_4.4.1-4.5.0.sql b/docs/upgrades/upgrade_4.4.1-4.5.0.sql
index 2ca5dd4eb..7aa8c029a 100644
--- a/docs/upgrades/upgrade_4.4.1-4.5.0.sql
+++ b/docs/upgrades/upgrade_4.4.1-4.5.0.sql
@@ -24,7 +24,7 @@ delete from international where namespace='EventsCalendar' and internationalId=1
delete from international where namespace='EventsCalendar' and internationalId=11;
insert into international values (75,'EventsCalendar',1,'Which do you wish to do?');
insert into international values (76,'EventsCalendar',1,'Delete only this event.');
-insert into international values (77,'EventsCalendar',1,'Delete this event and all of its recurring events.');
+insert into international values (77,'EventsCalendar',1,'Delete this event and all of its recurrences.');
insert into international values (78,'EventsCalendar',1,'Don\'t delete anything, I made a mistake.');
diff --git a/lib/HTML/CalendarMonthSimple.pm b/lib/HTML/CalendarMonthSimple.pm
index 2694f88ab..f87145306 100644
--- a/lib/HTML/CalendarMonthSimple.pm
+++ b/lib/HTML/CalendarMonthSimple.pm
@@ -3,7 +3,7 @@
# Herein, the symbol $self is used to refer to the object that's being passed around.
package HTML::CalendarMonthSimple;
-$HTML::CalendarMonthSimple::VERSION = "1.17";
+$HTML::CalendarMonthSimple::VERSION = "1.18";
use strict;
use Date::Calc;
@@ -29,7 +29,11 @@ sub new {
$self->{'vcellalignment'} = 'top';
$self->{'weekdayheadersbig'} = 1;
$self->{'nowrap'} = 0;
+
$self->{'mondayisfirstday'} = 0;
+ $self->{'weekdays'} = [qw/Monday Tuesday Wednesday Thursday Friday/];
+ $self->{'sunday'} = "Sunday";
+ $self->{'saturday'} = "Saturday";
# Set the default calendar header
$self->{'header'} = sprintf("
%s %d",
@@ -61,7 +65,7 @@ sub new {
sub as_HTML {
my $self = shift;
my $html = '';
- my(@days,$adjustedWeek,$sunday,$weeks,$WEEK,$DAY);
+ my(@days,$weeks,$adjustedWeek,$sunday,$mondayisfirstday,$WEEK,$DAY);
# To make the grid even, pad the start of the series with 0s
@days = (1 .. Date::Calc::Days_in_Month($self->year(),$self->month() ) );
@@ -79,6 +83,7 @@ sub as_HTML {
my $tablewidth = $self->width();
$tablewidth =~ m/^(\d+)(\%?)$/; my $cellwidth = (int($1/7))||'14'; if ($2) { $cellwidth .= '%'; }
my $header = $self->header();
+ my $mondayisfirstday = $self->mondayisfirstday();
my $cellalignment = $self->cellalignment();
my $vcellalignment = $self->vcellalignment();
my $contentfontsize = $self->contentfontsize();
@@ -105,18 +110,19 @@ sub as_HTML {
my $sharpborders = $self->sharpborders() || 0;
my $cellheight = $self->cellheight();
my $cellclass = $self->cellclass();
+ my $tableclass = $self->tableclass();
my $weekdaycellclass = $self->weekdaycellclass() || $self->cellclass();
my $weekendcellclass = $self->weekendcellclass() || $self->cellclass();
my $todaycellclass = $self->todaycellclass() || $self->cellclass();
my $headerclass = $self->headerclass() || $self->cellclass();
my $nowrap = $self->nowrap() || 0;
- my $mondayisfirstday = $self->mondayisfirstday();
# Get today's date, in case there's a todaycolor()
my($todayyear,$todaymonth,$todaydate) = Date::Calc::Today();
# the table declaration - sharpborders wraps the table inside a table cell
if ($sharpborders) {
$html .= "\n";
$html .= "\n";
@@ -126,13 +132,14 @@ sub as_HTML {
$html .= "";
}
else {
- $html .= "showweekdayheaders) {
my $celltype = $self->weekdayheadersbig() ? "th" : "td";
+ my @weekdays = $self->weekdays();
$html .= "\n";
$sunday = "<$celltype";
- $sunday.= " bgcolor=\"$weekendheadercolor\"" if $weekendheadercolor;
+ $sunday .= " bgcolor=\"$weekendheadercolor\"" if $weekendheadercolor;
$sunday .= " class=\"$weekendcellclass\"" if $weekendcellclass;
$sunday .= ">";
$sunday .= "" if $weekendheadercontentcolor;
- $sunday .= "Sunday";
+ $sunday .= $self->sunday();
$sunday .= "" if $weekendheadercontentcolor;
$sunday .= "$celltype>\n";
$html .= $sunday unless ($mondayisfirstday);
- foreach ("Monday","Tuesday","Wednesday","Thursday","Friday"){
+ foreach (@weekdays) { # draw the weekday headers
$html .= "<$celltype";
$html .= " bgcolor=\"$weekdayheadercolor\"" if $weekdayheadercolor;
$html .= " class=\"$weekdaycellclass\"" if $weekdaycellclass;
@@ -174,7 +182,7 @@ sub as_HTML {
$html .= " class=\"$weekendcellclass\"" if $weekendcellclass;
$html .= ">";
$html .= "" if $weekendheadercontentcolor;
- $html .= "Saturday";
+ $html .= $self->saturday();
$html .= "" if $weekendheadercontentcolor;
$html .= "$celltype>\n";
$html .= $sunday if ($mondayisfirstday);
@@ -185,11 +193,11 @@ sub as_HTML {
$html .= "
\n";
foreach $DAY (eval{if ($mondayisfirstday) {1..6,0} else {0..6}}) {
my($thiscontent,$thisday,$thisbgcolor,$thisbordercolor,$thiscontentcolor,$thiscellclass);
- if ($DAY == 0 && $mondayisfirstday) {
- $adjustedWeek = $WEEK+1;
- } else {
- $adjustedWeek = $WEEK;
- }
+ if ($DAY == 0 && $mondayisfirstday) {
+ $adjustedWeek = $WEEK+1;
+ } else {
+ $adjustedWeek = $WEEK;
+ }
$thisday = $days[((7*$adjustedWeek)+$DAY)];
# Get the cell content
@@ -212,7 +220,7 @@ sub as_HTML {
# Content for "Wednesdays", etc.
$thiscontent .= $self->getcontent(('sundays','mondays','tuesdays','wednesdays','thursdays','fridays','saturdays')[$DAY]);
# Normalize if there's no content
- $thiscontent .= ' ';
+ $thiscontent ||= ' ';
}
# Get the cell's coloration and CSS class
@@ -265,7 +273,26 @@ sub as_HTML {
}
+sub sunday {
+ my $self = shift;
+ my $newvalue = shift;
+ $self->{'sunday'} = $newvalue if defined($newvalue);
+ return $self->{'sunday'};
+}
+sub saturday {
+ my $self = shift;
+ my $newvalue = shift;
+ $self->{'saturday'} = $newvalue if defined($newvalue);
+ return $self->{'saturday'};
+}
+
+sub weekdays {
+ my $self = shift;
+ my @days = @_;
+ $self->{'weekdays'} = \@days if (scalar(@days)==5);
+ return @{$self->{'weekdays'}};
+}
sub getdatehref {
my $self = shift;
@@ -316,6 +343,13 @@ sub headercolor {
return $self->{'headercolor'};
}
+sub mondayisfirstday {
+ my $self = shift;
+ my $newvalue = shift;
+ if (defined ($newvalue)) { $self->{'mondayisfirstday'} = $newvalue; }
+ return $self->{'mondayisfirstday'}
+}
+
sub bgcolor {
my $self = shift;
my $newvalue = shift;
@@ -537,6 +571,8 @@ sub month {
sub monthname {
my $self = shift;
+ my $newvalue = shift;
+ if (defined($newvalue)) { $self->{'monthname'} = $newvalue; }
return $self->{'monthname'};
}
@@ -548,13 +584,6 @@ sub header {
return $self->{'header'};
}
-sub mondayisfirstday {
- my $self = shift;
- my $newvalue = shift;
- if (defined ($newvalue)) { $self->{'mondayisfirstday'} = $newvalue; }
- return $self->{'mondayisfirstday'}
-}
-
sub nowrap {
my $self = shift;
my $newvalue = shift;
@@ -583,6 +612,13 @@ sub cellclass {
return $self->{'cellclass'};
}
+sub tableclass {
+ my $self = shift;
+ my $newvalue = shift;
+ if (defined($newvalue)) { $self->{'tableclass'} = $newvalue; }
+ return $self->{'tableclass'};
+}
+
sub weekdaycellclass {
my $self = shift;
my $newvalue = shift;
@@ -672,7 +708,7 @@ Naturally, new() returns a newly constructed calendar object. Recognized argumen
=head1 month()
-=head1 monthname()
+=head1 monthname([STRING])
These methods simply return the year/month of the calendar. monthname() returns the text name of the month, e.g. "December".
@@ -815,6 +851,7 @@ If the header is set to an empty string, then no header will be printed at all.
$cal->header("$m $y\n\n");
+
=head1 bgcolor([STRING])
=head1 weekdaycolor([STRING])
@@ -899,6 +936,7 @@ The date must be numeric; it cannot be a string such as "2wednesday"
If set to 1, then calendar cells will have the NOWRAP attribute set, preventing their content from wrapping. If set to 0 (the default) then NOWRAP is not used and very long content may cause cells to become stretched out.
+
=head1 sharpborders([1 or 0])
If set to 1, this gives very crisp edges between the table cells. If set to 0 (the default) standard HTML cells are used. If neither value is specified, the current value is returned.
@@ -906,6 +944,7 @@ If set to 1, this gives very crisp edges between the table cells. If set to 0 (t
FYI: To accomplish the crisp border, the entire calendar table is wrapped inside a table cell.
+
=head1 cellheight([NUMBER])
This specifies the height in pixels of each cell in the calendar. By default, no height is defined and the web browser usually chooses a reasonable default.
@@ -916,6 +955,8 @@ To un-specify a height, try specifying a height of 0 or undef.
+=head1 tableclass([STRING])
+
=head1 cellclass([STRING])
=head1 weekdaycellclass([STRING])
@@ -929,7 +970,9 @@ To un-specify a height, try specifying a height of 0 or undef.
=head1 headerclass([STRING])
-These specify which CSS class will be attributed to the calendar's cells. By default, no classes are specified or used.
+These specify which CSS class will be attributed to the calendar's table and the calendar's cells. By default, no classes are specified or used.
+
+tableclass() sets the CSS class for the calendar table.
cellclass() is used for all calendar cells. weekdaycellclass(), weekendcellclass(), and todaycellclass() override the cellclass() for the corresponding types of cells. headerclass() is used for the calendar's header.
@@ -939,6 +982,29 @@ If no value is given, the current value is returned.
To un-specify a class, try specifying an empty string, e.g. cellclass('')
+=head1 mondayisfirstday([0|1])
+
+ Defaults to '0'. If '0' the first day of the week will be Sunday (American Format), but if '1' the first day of the week will be Monday (European Format).
+
+=head1 sunday([STRING])
+
+=head1 saturday([STRING])
+
+=head1 weekdays([MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY])
+
+These functions allow the days of the week to be "renamed", which is useful for displaying the weekday headers in another language.
+
+ # show the days of the week in Spanish
+ $cal->saturday('Sábado');
+ $cal->sunday('Domingo');
+ $cal->weekdays('Lunes','Martes','Miércoles','Jueves','Viernes');
+
+ # show the days of the week in German
+ $cal->saturday('Samstag');
+ $cal->sunday('Sonntag');
+ $cal->weekdays('Montag','Dienstag','Mittwoch','Donnerstag','Freitag');
+
+If no value is specified (or, for weekdays() if exactly 5 arguments aren't given) then the current value is returned.
@@ -978,6 +1044,8 @@ Changes in 1.16: Fixed a very stupid bug that made addcontent() and setcontent()
Changes in 1.17: Corrected B<-w> warnings about uninitialized values in as_HTML().
+Changes in 1.18: Added methods: tableclass(), sunday(), saturday(), weekdays(). Now day names can be internationalized!
+
=head1 AUTHORS, CREDITS, COPYRIGHTS
@@ -1006,7 +1074,9 @@ Bill Turner supplied the headerclass() method and the r
Bill Rhodes provided the contentfontsize() method for version 1.14
-JT Smith added the mondayisfirstday() method for truly international calendars.
+Alberto Simões provided the tableclass() function and the saturday(), sunday(), and weekdays() functions for version 1.18. Thanks, Alberto, I've been wanting this since the beginning!
+
+JT Smith added the mondayisfirstday() method to allow for European formatted calendars, and extended monthname to complete the internationalization functionality.
diff --git a/lib/WebGUI/DateTime.pm b/lib/WebGUI/DateTime.pm
index 69fd8ab2c..7d8920d0d 100644
--- a/lib/WebGUI/DateTime.pm
+++ b/lib/WebGUI/DateTime.pm
@@ -19,39 +19,6 @@ use WebGUI::Session;
our @ISA = qw(Exporter);
our @EXPORT = qw(&localtime &time &addToTime &addToDate &epochToHuman &epochToSet &humanToEpoch &setToEpoch &monthStartEnd);
-#-------------------------------------------------------------------
-sub _getMonth {
- my %month = (
- 1=> WebGUI::International::get(15),
- 2=> WebGUI::International::get(16),
- 3=> WebGUI::International::get(17),
- 4=> WebGUI::International::get(18),
- 5=> WebGUI::International::get(19),
- 6=> WebGUI::International::get(20),
- 7=> WebGUI::International::get(21),
- 8=> WebGUI::International::get(22),
- 9=> WebGUI::International::get(23),
- 10=> WebGUI::International::get(24),
- 11=> WebGUI::International::get(25),
- 12=> WebGUI::International::get(26)
- );
- return %month;
-}
-
-#-------------------------------------------------------------------
-sub _getWeekday {
- my %weekday = (
- 1=> WebGUI::International::get(27),
- 2=> WebGUI::International::get(28),
- 3=> WebGUI::International::get(29),
- 4=> WebGUI::International::get(30),
- 5=> WebGUI::International::get(31),
- 6=> WebGUI::International::get(32),
- 7=> WebGUI::International::get(33)
- );
- return %weekday;
-}
-
#-------------------------------------------------------------------
sub addToDate {
my ($year,$month,$day, $hour,$min,$sec, $newDate);
@@ -96,7 +63,7 @@ sub epochToHuman {
$output =~ s/\%m/$value/g;
$output =~ s/\%M/$date[1]/g;
if ($output =~ /\%c/) {
- %month = _getMonth();
+ %month = getMonthName();
$output =~ s/\%c/$month{$date[1]}/g;
}
#---day stuff
@@ -104,7 +71,7 @@ sub epochToHuman {
$output =~ s/\%d/$value/g;
$output =~ s/\%D/$date[2]/g;
if ($output =~ /\%w/) {
- %weekday = _getWeekday();
+ %weekday = getDayName();
$output =~ s/\%w/$weekday{$date[6]}/g;
}
#---hour stuff
@@ -142,6 +109,54 @@ sub epochToSet {
return epochToHuman($_[0],"%m/%d/%y");
}
+#-------------------------------------------------------------------
+sub getMonthName {
+ if ($_[0] == 1) {
+ return WebGUI::International::get(15);
+ } elsif ($_[0] == 2) {
+ return WebGUI::International::get(16);
+ } elsif ($_[0] == 3) {
+ return WebGUI::International::get(17);
+ } elsif ($_[0] == 4) {
+ return WebGUI::International::get(18);
+ } elsif ($_[0] == 5) {
+ return WebGUI::International::get(19);
+ } elsif ($_[0] == 6) {
+ return WebGUI::International::get(20);
+ } elsif ($_[0] == 7) {
+ return WebGUI::International::get(21);
+ } elsif ($_[0] == 8) {
+ return WebGUI::International::get(22);
+ } elsif ($_[0] == 9) {
+ return WebGUI::International::get(23);
+ } elsif ($_[0] == 10) {
+ return WebGUI::International::get(24);
+ } elsif ($_[0] == 11) {
+ return WebGUI::International::get(25);
+ } elsif ($_[0] == 12) {
+ return WebGUI::International::get(26);
+ }
+}
+
+#-------------------------------------------------------------------
+sub getDayName {
+ if ($_[0] == 1) {
+ return WebGUI::International::get(27);
+ } elsif ($_[0] == 2) {
+ return WebGUI::International::get(28);
+ } elsif ($_[0] == 2) {
+ return WebGUI::International::get(29);
+ } elsif ($_[0] == 2) {
+ return WebGUI::International::get(30);
+ } elsif ($_[0] == 2) {
+ return WebGUI::International::get(31);
+ } elsif ($_[0] == 2) {
+ return WebGUI::International::get(32);
+ } elsif ($_[0] == 2) {
+ return WebGUI::International::get(33);
+ }
+}
+
#-------------------------------------------------------------------
# eg: humanToEpoch(YYYY-MM-DD HH:MM:SS)
sub humanToEpoch {
diff --git a/lib/WebGUI/Wobject/EventsCalendar.pm b/lib/WebGUI/Wobject/EventsCalendar.pm
index bbe9ed090..7db22eb5f 100644
--- a/lib/WebGUI/Wobject/EventsCalendar.pm
+++ b/lib/WebGUI/Wobject/EventsCalendar.pm
@@ -41,6 +41,15 @@ sub _calendarLayout {
$calendar->todaycellclass("tableHeader");
$calendar->headerclass("tableHeader");
$calendar->mondayisfirstday($session{user}{firstDayOfWeek});
+ $calendar->sunday(WebGUI::International::get(27));
+ $calendar->weekdays(WebGUI::International::get(28),
+ WebGUI::International::get(29),
+ WebGUI::International::get(30),
+ WebGUI::International::get(31),
+ WebGUI::International::get(32));
+ $calendar->saturday(WebGUI::International::get(33));
+ $calendar->monthname(WebGUI::DateTime::getMonthName($calendar->month));
+ $calendar->header(''.$calendar->monthname.' '.$calendar->year.'
');
($start,$end) = monthStartEnd($_[1]);
$sth = WebGUI::SQL->read("select * from EventsCalendar_event where wobjectId=".$_[0]->get("wobjectId")." order by startDate,endDate");
while (%event = $sth->hash) {