From f1d99a0af14ddd2d18981ca7afe170ac39b9915b Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 12 May 2006 04:12:01 +0000 Subject: [PATCH] Add AdSpace help. Fix bad subroutine exit in label.t Clone label.t to create setHelp.t, which checks that AdminConsole help topics resolve Fix typo in AC help topic for InOutBoard --- lib/WebGUI/Asset/Wobject/InOutBoard.pm | 2 +- lib/WebGUI/Operation/AdSpace.pm | 2 + lib/WebGUI/i18n/English/AdSpace.pm | 10 +++ t/Help/setHelp.t | 104 +++++++++++++++++++++++++ t/i18n/label.t | 2 +- 5 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 t/Help/setHelp.t diff --git a/lib/WebGUI/Asset/Wobject/InOutBoard.pm b/lib/WebGUI/Asset/Wobject/InOutBoard.pm index 01d4d51be..1fa6d6d24 100644 --- a/lib/WebGUI/Asset/Wobject/InOutBoard.pm +++ b/lib/WebGUI/Asset/Wobject/InOutBoard.pm @@ -297,7 +297,7 @@ order by department, lastName, firstName"; sub www_edit { my $self = shift; return $self->session->privilege->insufficient() unless $self->canEdit; - $self->getAdminConsole->setHelp("in out board add/edit","Asset_InOurBoard"); + $self->getAdminConsole->setHelp("in out board add/edit","Asset_InOutBoard"); my $i18n = WebGUI::International->new($self->session, "Asset_InOutBoard"); return $self->getAdminConsole->render($self->getEditForm->print,$i18n->get("18")); } diff --git a/lib/WebGUI/Operation/AdSpace.pm b/lib/WebGUI/Operation/AdSpace.pm index 72b85b8e3..20fdfe094 100644 --- a/lib/WebGUI/Operation/AdSpace.pm +++ b/lib/WebGUI/Operation/AdSpace.pm @@ -211,6 +211,7 @@ sub www_editAd { ); $f->fieldSetEnd; $f->submit; + $ac->setHelp('edit ad', 'AdSpace'); $ac->render($f->print, $i18n->get("edit advertisement")); } @@ -332,6 +333,7 @@ sub www_editAdSpace { } $ads .= '
'; } + $ac->setHelp('edit ad space', 'AdSpace'); $ac->render($code.$f->print.$ads, $i18n->get("edit ad space")); } diff --git a/lib/WebGUI/i18n/English/AdSpace.pm b/lib/WebGUI/i18n/English/AdSpace.pm index 8a0583bc2..4e55a4cb1 100644 --- a/lib/WebGUI/i18n/English/AdSpace.pm +++ b/lib/WebGUI/i18n/English/AdSpace.pm @@ -288,6 +288,16 @@ our $I18N = { lastUpdated => 0, }, + 'edit advertisement body' => { + message => q|

In this screen, you'll configure an advertisement to go into the adspace. You can set physical properties such as colors, images, displayed text and url, define how often the advertisement is shown and activate or deactivate the ad. Ads are local to a particular ad space.

|, + lastUpdated => 0, + }, + + 'edit ad space body' => { + message => q|

In this screen, you will configure an area that holds an ad (an ad space) to embed in a page via the Ad Space macro (^AdSpace();). When editing an existing ad space, a preview of the ad space is shown, along with a list of ads to be shown in the space. The icons in the list of ads allow ads to be edited or deleted.

|, + lastUpdated => 0, + }, + }; 1; diff --git a/t/Help/setHelp.t b/t/Help/setHelp.t new file mode 100644 index 000000000..978f2488b --- /dev/null +++ b/t/Help/setHelp.t @@ -0,0 +1,104 @@ +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2006 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use FindBin; +use strict; +use lib "$FindBin::Bin/../lib"; ##t/lib + +use WebGUI::Test; +use WebGUI::Operation::Help; +use WebGUI::International; +use WebGUI::Session; +use Text::Balanced qw(extract_codeblock); +use Data::Dumper; +use File::Find; + +#The goal of this test is to locate all help topics that are set +#in admin consoles. + +use Test::More; # increment this value for each test you create +my $numTests = 0; + +my $session = WebGUI::Test->session; +my $lib = WebGUI::Test->lib; + +# put your tests here + +my $digits = qr/(\d+)/; +my $bareword = qr/(\w+)/; +my $quotelike = qr/((['"])([^'"\s]+\s*)+(['"]))/; +my $sub_args = qr/(($quotelike|$digits)(,\s*)?)+/; +my $sess_arg = qr/(?:\$session|\$self->session)/; + +my @helpTopics = (); +find(\&getHelpTopics, $lib); + +$numTests = scalar(@helpTopics) +; + +plan tests => $numTests; + +my @helpFileSet = WebGUI::Operation::Help::_getHelpFilesList($session); + +my %helpTable = (); + +foreach my $helpSet (@helpFileSet) { + my $helpName = $helpSet->[1]; + my $help = WebGUI::Operation::Help::_load($session, $helpName); + $helpTable{ $helpName } = $help; +} + +foreach my $topic ( @helpTopics ) { + my ($tag, $namespace, $file) = @{ $topic }{ qw/tag namespace file/ }; + $tag =~ tr/"'//d; + $namespace =~ tr/'"//d; + ok(exists $helpTable{$namespace}->{$tag}, + sprintf "help topic: %s->%s inside from %s", $namespace, $tag, $file); +} + +sub getHelpTopics { + return unless /\.pm$/; + if ($File::Find::name =~ m#(?:Help|i18n)/?$#) { + $File::Find::prune=1; + return; + } + open my $pmf, $_ + or die "unable to open file $File::Find::name: $!\n"; + my $libFile = ''; + { + local $/; + $libFile = <$pmf>; + } + close $pmf; + ##Advance pos to first subroutine + while ( my $subBody = extract_codeblock($libFile, '{}', qr/(?ms).*?^sub (\w+)\s*/) ) { + if ( $subBody =~ /(\w+)\s*=\s*WebGUI::AdminConsole->new\($sess_arg(?:,\s*($quotelike))?\)/msgc) { + my $objBody = $subBody; + my ($obj, $namespace) = ($1,$2); + if ( $objBody =~ /$obj\->setHelp\(($sub_args)\)/msgc ) { + my ($tag, $namespace) = split /,\s*/, $1; + push @helpTopics, { + file=>$File::Find::name, + tag=>$tag, + namespace=>$namespace || 'WebGUI', + }; + } + } + elsif ($subBody =~ /AdminConsole->setHelp\(($sub_args)\)/msgc ) { + my ($tag, $namespace) = split /,\s*/, $1; + push @helpTopics, { + file=>$File::Find::name, + tag=>$tag, + namespace=>$namespace || 'WebGUI', + }; + } + } +} + diff --git a/t/i18n/label.t b/t/i18n/label.t index a76d96599..6ef753390 100644 --- a/t/i18n/label.t +++ b/t/i18n/label.t @@ -131,7 +131,7 @@ sub label_finder_pm { } sub obj_finder_pm { - next unless /\.pm$/; + return unless /\.pm$/; if ($File::Find::name =~ m#(?:Help|i18n)/?$#) { warn "Pruned $File::Find::name\n"; $File::Find::prune=1;