From 991aac998aaff3cf5a503f14ae77a63bd1264bd2 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Tue, 20 Mar 2007 17:27:30 +0000 Subject: [PATCH] fix: t::WebGUI::PseudoRequest now works properly add: Added some additional vars to Calendar Week view fix: WebGUI::DateTime now handles MySQL strings more robustly --- lib/WebGUI/Asset/Wobject/Calendar.pm | 5 ++- lib/WebGUI/DateTime.pm | 27 +++++++++------ lib/WebGUI/Help/Asset_Calendar.pm | 6 ++++ lib/WebGUI/i18n/English/Asset_Calendar.pm | 22 +++++++++++++ t/lib/WebGUI/PseudoRequest.pm | 40 +++++++++++++++++++++-- 5 files changed, 85 insertions(+), 15 deletions(-) diff --git a/lib/WebGUI/Asset/Wobject/Calendar.pm b/lib/WebGUI/Asset/Wobject/Calendar.pm index 619132d50..39e8142da 100644 --- a/lib/WebGUI/Asset/Wobject/Calendar.pm +++ b/lib/WebGUI/Asset/Wobject/Calendar.pm @@ -1019,7 +1019,6 @@ sub viewDay { ### Get all the events in this time period # Get the range of the epoch of this day my $dt = WebGUI::DateTime->new($session, $params->{start}); - $dt->set_locale($i18n->get("locale")); $dt->truncate( to => "day"); my @events = $self->getEventsIn($dt->toMysql,$dt->clone->add(days => 1)->toMysql); @@ -1113,7 +1112,6 @@ sub viewMonth { #### Get all the events in this time period # Get the range of the epoch of this month my $dt = WebGUI::DateTime->new($self->session, $params->{start}); - $dt->set_locale($i18n->get("locale")); $dt->truncate( to => "month"); my @events @@ -1292,7 +1290,6 @@ sub viewWeek { for my $event (@events) { # Get the week this event is in, and add it to that week in # the template variables - my $dt_event_start = $event->getDateTimeStart; my $dt_event_end = $event->getDateTimeEnd; $dt_event_start->set_locale($i18n->get("locale")); @@ -1311,6 +1308,7 @@ sub viewWeek { $var->{"pagePrevUrl"} = $self->getUrl("type=week;start=" . $dt->clone->subtract(weeks=>1)->toMysql); + $var->{"startMonth" } = $dt->month; $var->{"startMonthName" } = $dt->month_name; $var->{"startMonthAbbr" } = $dt->month_abbr; $var->{"startDayOfMonth" } = $dt->day_of_month; @@ -1318,6 +1316,7 @@ sub viewWeek { $var->{"startDayAbbr" } = $dt->day_abbr; $var->{"startYear" } = $dt->year; + $var->{"endMonth" } = $dtEnd->month; $var->{"endMonthName" } = $dtEnd->month_name; $var->{"endMonthAbbr" } = $dtEnd->month_abbr; $var->{"endDayOfMonth" } = $dtEnd->day_of_month; diff --git a/lib/WebGUI/DateTime.pm b/lib/WebGUI/DateTime.pm index 5c55b8478..d77eef591 100755 --- a/lib/WebGUI/DateTime.pm +++ b/lib/WebGUI/DateTime.pm @@ -611,16 +611,23 @@ DateTime sub _splitMysql { my $string = shift; - my ($y,$m,$d,$h,$n,$s) = split /\D+/,$string; - my %hash = ( - year => $y, - month => $m, - day => $d, - hour => $h, - minute => $n, - second => $s, - ); - + my %hash; + + @hash{ qw( year month day hour minute second ) } + = $string =~ m{ + (\d+) # Year + \D* + (\d+) # Month + \D* + (\d+) # Day + \D* + (\d+) # Hours + \D* + (\d+) # Minutes + \D* + (\d+) # Seconds + }x; + return %hash; } diff --git a/lib/WebGUI/Help/Asset_Calendar.pm b/lib/WebGUI/Help/Asset_Calendar.pm index e92979ae9..e416da6f0 100644 --- a/lib/WebGUI/Help/Asset_Calendar.pm +++ b/lib/WebGUI/Help/Asset_Calendar.pm @@ -221,6 +221,9 @@ our $HELP = { 'name' => 'pagePrevUrl', 'description' => 'pagePrevUrl weekVar' }, + { + 'name' => 'startMonth', + }, { 'name' => 'startMonthName' }, @@ -239,6 +242,9 @@ our $HELP = { { 'name' => 'startYear' }, + { + 'name' => 'endMonth', + }, { 'name' => 'endMonthName' }, diff --git a/lib/WebGUI/i18n/English/Asset_Calendar.pm b/lib/WebGUI/i18n/English/Asset_Calendar.pm index 9203ab3d0..193a24be7 100755 --- a/lib/WebGUI/i18n/English/Asset_Calendar.pm +++ b/lib/WebGUI/i18n/English/Asset_Calendar.pm @@ -276,6 +276,18 @@ our $I18N = { context => q{Description of what the Calendar Update Feeds workflow activity does}, }, + 'workflow generateRecurringEvents' => { + message => q{Generate Recurring Events}, + lastUpdated => 0, + context => q{The name of the CalendarGenerateRecurringEvents workflow activity}, + }, + + 'workflow generateRecurringEvents description' => { + message => q{This activity generates recurring events for calendars. } + . q{This activity also maintains recurring events in the future.}, + lastUpdated => 0, + context => q{Description of what the CalendarGenerateRecurringEvents workflow activity does}, + }, #################### HELP PAGES #################### @@ -510,6 +522,11 @@ our $I18N = { lastUpdated => 1171171998, }, + 'startMonth' => { + message => q{The number (1-12) of the month this week starts.}, + lastUpdated => 1171043883, + }, + 'startMonthName' => { message => q|The name of the month this week starts.|, lastUpdated => 1171043883, @@ -540,6 +557,11 @@ our $I18N = { lastUpdated => 1171043883, }, + 'endMonth' => { + message => q{The number (1-12) of the month this week ends.}, + lastUpdated => 117104883, + }, + 'endMonthName' => { message => q|The name of the month this week ends.|, lastUpdated => 1171043883, diff --git a/t/lib/WebGUI/PseudoRequest.pm b/t/lib/WebGUI/PseudoRequest.pm index 4babeeaae..d805235ea 100644 --- a/t/lib/WebGUI/PseudoRequest.pm +++ b/t/lib/WebGUI/PseudoRequest.pm @@ -37,7 +37,25 @@ sub body { my $self = shift; my $value = shift; return keys %{ $self->{body} } unless defined $value; - return $self->{body}->{$value}; + if ($self->{body}->{$value}) { + if (wantarray && ref $self->{body}->{$value} eq "ARRAY") { + return @{$self->{body}->{$value}}; + } + elsif (ref $self->{body}->{$value} eq "ARRAY") { + return $self->{body}->{$value}->[0]; + } + else { + return $self->{body}->{$value}; + } + } + else { + if (wantarray) { + return (); + } + else { + return undef; + } + } } sub setup_body { @@ -73,7 +91,25 @@ sub param { my $self = shift; my $value = shift; return keys %{ $self->{param} } unless defined $value; - return $self->{param}->{$value}; + if ($self->{param}->{$value}) { + if (wantarray && ref $self->{param}->{$value} eq "ARRAY") { + return @{$self->{param}->{$value}}; + } + elsif (ref $self->{param}->{$value} eq "ARRAY") { + return $self->{param}->{$value}->[0]; + } + else { + return $self->{param}->{$value}; + } + } + else { + if (wantarray) { + return (); + } + else { + return undef; + } + } } sub setup_param {