From 713aa0f5e7a96fdb77e9a441720891f4e3036039 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Fri, 22 Apr 2011 14:38:30 -0500 Subject: [PATCH] add Calendar to test_content --- lib/WebGUI/Command/test_content.pm | 46 +++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/lib/WebGUI/Command/test_content.pm b/lib/WebGUI/Command/test_content.pm index 0b9f25f53..9b949d098 100644 --- a/lib/WebGUI/Command/test_content.pm +++ b/lib/WebGUI/Command/test_content.pm @@ -9,6 +9,7 @@ use File::Spec::Functions qw(catfile); use WebGUI::Paths; use WebGUI::Session; use WebGUI::Macro; +use WebGUI::DateTime; our $LAYOUT_CLASS = 'WebGUI::Asset::Wobject::Layout'; our $FOLDER_CLASS = 'WebGUI::Asset::Wobject::Folder'; @@ -120,7 +121,7 @@ sub getAsset { =head2 buildAsset( class, page, props ) -Build one asset on the page +Build one asset on the page, recursing into any _children. =cut @@ -148,6 +149,14 @@ sub buildAsset { } # Add children + my $first_child = $children->[0]; + for my $child ( @$children ) { + my $merged_set = { + %$first_child, + %$child, + }; + $self->buildAsset( $merged_set->{className}, $asset, $merged_set ); + } return $asset; } @@ -160,10 +169,12 @@ This is hardcoded for now, but should eventually become a config file of some ki =cut +my $DT_NOW = DateTime->now; # The first set is the default properties, every other set will combine the # default properties with the set properties # A special property _children allows for child assets +# again, the first item will set defaults for the next items # A special property _files allows for files %ASSETS = ( 'WebGUI::Asset::Wobject::Article' => [ @@ -205,6 +216,39 @@ This is hardcoded for now, but should eventually become a config file of some ki ], }, ], + 'WebGUI::Asset::Wobject::Calendar' => [ + { + title => 'Calendar', + isHidden => 1, + displayTitle => 1, + _children => [ + { + className => 'WebGUI::Asset::Event', + title => 'Today', + startDate => $DT_NOW->ymd, + endDate => $DT_NOW->ymd, + }, + { + title => 'Tomorrow', + startDate => $DT_NOW->clone->add( days => 1 )->ymd, + endDate => $DT_NOW->clone->add( days => 1 )->ymd, + }, + { + title => 'Tomorrow Noon', + startDate => $DT_NOW->clone->add( days => 1 )->ymd, + endDate => $DT_NOW->clone->add( days => 1 )->ymd, + startTime => '12:00:00', + endTime => '12:00:00', + timeZone => 'CST', + }, + { + title => 'This weekend', + startDate => $DT_NOW->clone->add( days => 6 - $DT_NOW->dow )->ymd, + endDate => $DT_NOW->clone->add( days => 7 - $DT_NOW->dow )->ymd, + }, + ], + }, + ], ); sub getPropertySets {