From 84198ceea0a36286b8d2c83f78b92abe637a4b06 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sat, 10 Feb 2007 00:16:16 +0000 Subject: [PATCH] More tests for AdSpace/Ad.pm, one of which found a bug with handling Macros in Rich Media ads. This was fixed. Just the start of template docs for the Calendar. Finishing the Calendar docs requires doing the Event docs. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/AdSpace/Ad.pm | 2 +- lib/WebGUI/Asset/Wobject/Calendar.pm | 4 +- lib/WebGUI/Help/Asset_Calendar.pm | 308 +++++++++++++++------- lib/WebGUI/i18n/English/Asset_Calendar.pm | 185 +++++++++++++ t/AdSpace/Ad.t | 19 +- 6 files changed, 422 insertions(+), 97 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 952b09f37..219558f24 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -63,6 +63,7 @@ - fix: Ignoring shortcut overrides. - fix: Calendar feeds not working. - fix: multiple matrix sharing features + - fix: Fixed a bug with processing macros in rich media ads. (perlDreamer Consulting, LLC) - fix: WebGUI Auth create account can now be properly overriden 7.3.8 diff --git a/lib/WebGUI/AdSpace/Ad.pm b/lib/WebGUI/AdSpace/Ad.pm index d10d40a40..0cba9636a 100644 --- a/lib/WebGUI/AdSpace/Ad.pm +++ b/lib/WebGUI/AdSpace/Ad.pm @@ -263,7 +263,7 @@ sub set { $self->{_properties}{renderedAd} = '
get("height").'px; margin:0px; overflow:hidden; border:0px;">getId).'" style="position:absolute; padding: 3px; top:0px; left:0px; width:100%; height:100%; z-index:10; display:block; text-decoration:none; vertical-align:top;">'.$self->get(
'; } elsif ($self->get("type") eq "rich") { my $ad = $self->get("richMedia"); - WebGUI::Macro::process($self->session, $ad); + WebGUI::Macro::process($self->session, \$ad); $self->{_properties}{renderedAd} = $ad; } $self->session->db->setRow("advertisement","adId",$self->{_properties}); diff --git a/lib/WebGUI/Asset/Wobject/Calendar.pm b/lib/WebGUI/Asset/Wobject/Calendar.pm index b0a376510..a282dcf69 100644 --- a/lib/WebGUI/Asset/Wobject/Calendar.pm +++ b/lib/WebGUI/Asset/Wobject/Calendar.pm @@ -1685,10 +1685,12 @@ sub www_search { defaultValue => $default_end, }); + my $i18n = WebGUI::International->new($session, 'Asset_Calendar'); + $var->{"form.submit"} = WebGUI::Form::submit($session, { name => "submit", - value => "Search", + value => $i18n->get('searchButtonLabel'), }); # This is very bad! It should be $self->processStyle or whatnot. diff --git a/lib/WebGUI/Help/Asset_Calendar.pm b/lib/WebGUI/Help/Asset_Calendar.pm index c8c7e9e4b..514fa1af6 100644 --- a/lib/WebGUI/Help/Asset_Calendar.pm +++ b/lib/WebGUI/Help/Asset_Calendar.pm @@ -3,92 +3,153 @@ package WebGUI::Help::Asset_Calendar; use strict; use warnings; -our $HELP = {}; - -#### Edit Calendar Page -my $editPage = $HELP->{'calendar add/edit'} = {}; - -$editPage->{ title } = 'help add/edit title'; -$editPage->{ body } = 'help add/edit body'; - -push @{$editPage->{ isa }}, { - tag => 'asset fields', - namespace => 'Asset', - }, - ; - -push @{$editPage->{ fields }}, - { - title => "defaultView label", - description => "defaultView description", - namespace => "Asset_Calendar", - }, - { - title => "defaultDate label", - description => "defaultDate description", - namespace => "Asset_Calendar", - }, - { - title => "groupIdEventEdit label", - description => "groupIdEventEdit description", - namespace => "Asset_Calendar", - }, - { - title => "templateIdMonth label", - description => "templateIdMonth description", - namespace => "Asset_Calendar", - }, - { - title => "templateIdWeek label", - description => "templateIdWeek description", - namespace => "Asset_Calendar", - }, - { - title => "templateIdDay label", - description => "templateIdDay description", - namespace => "Asset_Calendar", - }, - { - title => "templateIdEvent label", - description => "templateIdEvent description", - namespace => "Asset_Calendar", - }, - { - title => "templateIdEventEdit label", - description => "templateIdEventEdit description", - namespace => "Asset_Calendar", - }, - { - title => "templateIdSearch label", - description => "templateIdSearch description", - namespace => "Asset_Calendar", - }, - { - title => "templateIdPrintMonth label", - description => "templateIdPrintMonth description", - namespace => "Asset_Calendar", - }, - { - title => "templateIdPrintWeek label", - description => "templateIdPrintWeek description", - namespace => "Asset_Calendar", - }, - { - title => "templateIdPrintDay label", - description => "templateIdPrintDay description", - namespace => "Asset_Calendar", - }, - { - title => "templateIdPrintEvent label", - description => "templateIdPrintEvent description", - namespace => "Asset_Calendar", - }, - ; - +our $HELP = { + 'calendar add/edit' => { + title => 'help add/edit title', + body => 'help add/edit body', + isa => [ + { + namespace => "Asset_Wobject", + tag => "wobject add/edit" + }, + ], + fields => [ + { + title => "defaultView label", + description => "defaultView description", + namespace => "Asset_Calendar", + }, + { + title => "defaultDate label", + description => "defaultDate description", + namespace => "Asset_Calendar", + }, + { + title => "groupIdEventEdit label", + description => "groupIdEventEdit description", + namespace => "Asset_Calendar", + }, + { + title => "templateIdMonth label", + description => "templateIdMonth description", + namespace => "Asset_Calendar", + }, + { + title => "templateIdWeek label", + description => "templateIdWeek description", + namespace => "Asset_Calendar", + }, + { + title => "templateIdDay label", + description => "templateIdDay description", + namespace => "Asset_Calendar", + }, + { + title => "templateIdEvent label", + description => "templateIdEvent description", + namespace => "Asset_Calendar", + }, + { + title => "templateIdEventEdit label", + description => "templateIdEventEdit description", + namespace => "Asset_Calendar", + }, + { + title => "templateIdSearch label", + description => "templateIdSearch description", + namespace => "Asset_Calendar", + }, + { + title => "templateIdPrintMonth label", + description => "templateIdPrintMonth description", + namespace => "Asset_Calendar", + }, + { + title => "templateIdPrintWeek label", + description => "templateIdPrintWeek description", + namespace => "Asset_Calendar", + }, + { + title => "templateIdPrintDay label", + description => "templateIdPrintDay description", + namespace => "Asset_Calendar", + }, + { + title => "templateIdPrintEvent label", + description => "templateIdPrintEvent description", + namespace => "Asset_Calendar", + }, + ], + variables => [ + ], + related => [ + ], + }, #### View Calendar Page + 'view calendar template' => { + title => 'view calendar title', + body => 'view calendar body', + isa => [ + { + namespace => "Asset_Template", + tag => "template variables" + }, + { + namespace => "Asset", + tag => "asset template" + }, + ], + fields => [ + ], + variables => [ + { + 'name' => 'admin' + }, + { + 'name' => 'adminControls' + }, + { + 'name' => 'editor' + }, + { + 'name' => 'urlAdd' + }, + { + 'name' => 'urlDay' + }, + { + 'name' => 'urlWeek' + }, + { + 'name' => 'urlMonth' + }, + { + 'name' => 'urlSearch' + }, + { + 'name' => 'urlPrint' + }, + { + 'name' => 'paramStart' + }, + { + 'name' => 'paramType' + }, + { + 'name' => 'extrasUrl' + }, + ], + related => [ + { + tag => 'calendar add/edit', + namespace => 'Asset_Calendar' + }, + ] + }, + #### Search Calendar Page #### ICal Calendar Page @@ -100,25 +161,88 @@ push @{$editPage->{ fields }}, #### View Day Template -#### Search Template - -__END__ -our $HELP = { - 'calendar add/edit' => { - title => 'add/edit title', - body => 'add/edit body', + 'view day template' => { + title => 'view calendar day title', + body => 'view calendar day body', isa => [ { - tag => 'asset fields', - namespace => 'Asset' + namespace => "Asset_Calendar", + tag => "view calendar template" }, ], fields => [ - ], + ], + variables => [ + { + 'name' => 'hours' + }, + { + 'name' => 'hour12' + }, + { + 'name' => 'hour24' + }, + { + 'name' => 'hourM' + }, + { + 'name' => 'pageNextStart' + }, + { + 'name' => 'pageNextUrl' + }, + { + 'name' => 'pagePrevStart' + }, + { + 'name' => 'pagePrevUrl' + }, + { + 'name' => 'dayName' + }, + { + 'name' => 'dayAbbr' + }, + { + 'name' => 'dayOfMonth' + }, + { + 'name' => 'dayOfWeek' + }, + { + 'name' => 'monthName' + }, + { + 'name' => 'monthAbbr' + }, + { + 'name' => 'year' + }, + { + 'name' => 'ymd' + }, + { + 'name' => 'mdy' + }, + { + 'name' => 'dmy' + }, + { + 'name' => 'epoch' + }, + ], related => [ + { + tag => 'calendar add/edit', + namespace => 'Asset_Calendar' + }, ] }, }; +#### Search Template + 1; + + diff --git a/lib/WebGUI/i18n/English/Asset_Calendar.pm b/lib/WebGUI/i18n/English/Asset_Calendar.pm index efc5b6467..acbf3b9e3 100755 --- a/lib/WebGUI/i18n/English/Asset_Calendar.pm +++ b/lib/WebGUI/i18n/English/Asset_Calendar.pm @@ -290,6 +290,191 @@ our $I18N = { }, +#################### HELP PAGES #################### + 'searchButtonLabel' => { + message => q|Search|, + lastUpdated => 1170803504, + }, + +#################### HELP PAGES View Calendar #################### + + 'view calendar title' => { + message => q|View Calendar Template Variables|, + lastUpdated => 1171043337, + }, + + 'view calendar body' => { + message => q|

The Calendar can be viewed as an entire month, a week, or just a day. Each view has its own individual template variables, but they also share several common variables. These are listed below:

|, + lastUpdated => 1171043883, + }, + + 'admin' => { + message => q|A conditional that will be true if the user has Admin mode turned on.|, + lastUpdated => 1171043883, + }, + + 'adminControls' => { + message => q|These are the icons and URLs that allow editing, cutting, copying, deleting and reordering the Asset.|, + lastUpdated => 1171043883, + }, + + 'editor' => { + message => q|A conditional that will be true if the user is in the group allowed to edit events in the calendar.|, + lastUpdated => 1171043883, + }, + + 'urlAdd' => { + message => q|A URL to add an event to the calendar.|, + lastUpdated => 1171043883, + }, + + 'urlDay' => { + message => q|A URL to the 1 day view of the calendar.|, + lastUpdated => 1171043883, + }, + + 'urlWeek' => { + message => q|A URL to the week view of the calendar.|, + lastUpdated => 1171043883, + }, + + 'urlMonth' => { + message => q|A URL to the month view of the calendar.|, + lastUpdated => 1171043883, + }, + + 'urlSearch' => { + message => q|A URL to the search form for the calendar.|, + lastUpdated => 1171043883, + }, + + 'urlPrint' => { + message => q|A URL to the printable view of the calendar.|, + lastUpdated => 1171043883, + }, + + 'paramStart' => { + message => q|The starting date of the calendar.|, + lastUpdated => 1171043883, + }, + + 'paramType' => { + message => q|The current view of the calendar, one of the strings "day", "week", "month".|, + context => q|Translator's note: Do not translate the strings in double quotes, they are literals.|, + lastUpdated => 1171062302, + }, + + 'extrasUrl' => { + message => q|A URL to the WebGUI extras directory.|, + lastUpdated => 1171062302, + }, + + 'view calendar day title' => { + message => q|View Calendar Day Template Variables|, + lastUpdated => 1171043337, + }, + + 'view calendar day body' => { + message => q|

This template shows all events in a single day in the calendar, sorted by hour.

|, + lastUpdated => 1171043883, + }, + + 'hours' => { + message => q|This loop contains all the events and labels for the hours that they occur in.|, + lastUpdated => 1171043883, + }, + + 'hour12' => { + message => q|The hour in 12 hour format. 2:00 in the afternoon will be 2:00.|, + lastUpdated => 1171043883, + }, + + 'hour24' => { + message => q|The hour in 24 hour format. 2:00 in the afternoon will be 14:00.|, + lastUpdated => 1171043883, + }, + + 'hourM' => { + message => q|Depending on whether the hour occurs in the morning or afternoon, either the strings "am" or "pm"|, + context => q|Translator's note: Do not translate the strings in double quotes, they are literals.|, + lastUpdated => 1171043883, + }, + + 'pageNextStart' => { + message => q|The date of the next day in the calendar in YYYY-MM-DD (Year, Month, Day) format.|, + lastUpdated => 1171043883, + }, + + 'pageNextUrl' => { + message => q|A URL to the next day in the calendar.|, + lastUpdated => 1171043883, + }, + + 'pagePrevStart' => { + message => q|The date of the previous day in the calendar in YYYY-MM-DD (Year, Month, Day) format.|, + lastUpdated => 1171043883, + }, + + 'pagePrevUrl' => { + message => q|A URL to the previous day in the calendar.|, + lastUpdated => 1171043883, + }, + + 'dayName' => { + message => q|The name of the current day.|, + lastUpdated => 1171043883, + }, + + 'dayAbbr' => { + message => q|The abbreviation for the name of the current day.|, + lastUpdated => 1171043883, + }, + + 'dayOfMonth' => { + message => q|Which day of the month this day is, an integer from 1..31.|, + lastUpdated => 1171043883, + }, + + 'dayOfWeek' => { + message => q|Which day of the week this day is, an integer from 1..7.|, + lastUpdated => 1171043883, + }, + + 'monthName' => { + message => q|The name of this month.|, + lastUpdated => 1171043883, + }, + + 'monthAbbr' => { + message => q|The abbreviation of the name for this month.|, + lastUpdated => 1171043883, + }, + + 'year' => { + message => q|The 4 digit year.|, + lastUpdated => 1171043883, + }, + + 'ymd' => { + message => q|This day's date in yyyy-mm-dd format, where yyyy is the year, mm is the month and dd is the day.|, + lastUpdated => 1171043883, + }, + + 'mdy' => { + message => q|This day's date in mm-dd-yyyy format, where yyyy is the year, mm is the month and dd is the day.|, + lastUpdated => 1171043883, + }, + + 'dmy' => { + message => q|This day's date in dd-mm-yyyy format, where yyyy is the year, mm is the month and dd is the day.|, + lastUpdated => 1171043883, + }, + + 'epoch' => { + message => q|This day's date in epoch format.|, + lastUpdated => 1171043883, + }, + #################### ASSET NAME #################### 'assetName' => { diff --git a/t/AdSpace/Ad.t b/t/AdSpace/Ad.t index 16b2bcd40..ec4921166 100644 --- a/t/AdSpace/Ad.t +++ b/t/AdSpace/Ad.t @@ -35,7 +35,7 @@ my $newAdSettings = { priority => "0", }; -my $numTests = 6; # increment this value for each test you create +my $numTests = 7; # increment this value for each test you create $numTests += scalar keys %{ $newAdSettings }; ++$numTests; ##For conditional testing on module load @@ -45,6 +45,7 @@ my $loaded = use_ok('WebGUI::AdSpace::Ad'); my $session = WebGUI::Test->session; my $ad; +my $richAd; my $adSpace; SKIP: { @@ -55,6 +56,7 @@ SKIP: { isa_ok($ad,"WebGUI::AdSpace::Ad"); isa_ok($ad->session, 'WebGUI::Session'); + isa($ad->get('type'), 'text', 'property set during object creation'); my $ad2 = WebGUI::AdSpace::Ad->new($session, $ad->getId); cmp_deeply($ad2, $ad, "new returns an identical object to the original what was created"); @@ -72,11 +74,22 @@ SKIP: { sprintf "default setting for %s", $setting); } + $richAd = WebGUI::AdSpace::Ad->create($session, $adSpace->getId); + $richAd->set({ + type => 'rich', + richMedia => 'This is rich, ^@;' + }); + my $renderedAd = $richAd->get('renderedAd'); + my $userName = $session->user->username; + like($renderedAd, qr/This is rich, $userName/, 'Rich media ads render macros'); + } END { - if (defined $ad and ref $ad eq 'WebGUI::AdSpace::Ad') { - $ad->delete; + foreach my $advertisement ($ad, $richAd) { + if (defined $advertisement and ref $advertisement eq 'WebGUI::AdSpace::Ad') { + $advertisement->delete; + } } if (defined $adSpace and ref $adSpace eq 'WebGUI::AdSpace') { $adSpace->delete;