From 01816cd806bbe410e8e21352cda88df9668f514d Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 19 Dec 2005 04:48:38 +0000 Subject: [PATCH] Corrent template description in Macro/AdminBar. Added POD for two macros. Internationalized the If error message. --- lib/WebGUI/Macro/AdminBar.pm | 6 +++--- lib/WebGUI/Macro/H_homeLink.pm | 25 ++++++++++++++++++++++ lib/WebGUI/Macro/If.pm | 33 +++++++++++++++++++++++++++-- lib/WebGUI/i18n/English/Macro_If.pm | 6 ++++++ 4 files changed, 65 insertions(+), 5 deletions(-) diff --git a/lib/WebGUI/Macro/AdminBar.pm b/lib/WebGUI/Macro/AdminBar.pm index c5ba4937d..46a754ca6 100644 --- a/lib/WebGUI/Macro/AdminBar.pm +++ b/lib/WebGUI/Macro/AdminBar.pm @@ -31,14 +31,14 @@ Package WebGUI::Macro::AdminBar Macro for displaying administrative functions to a user with Admin turned on. -=head2 process ( [template ] ) +=head2 process ( [templateId ] ) process takes one optional parameters for customizing the layout of the Admin bar. -=head3 template +=head3 templateId -A template to use for formatting the link. The default template creates the sliding +The ID for a template to use for formatting the link. The default template creates the sliding Admin bar to the left of the screen. =cut diff --git a/lib/WebGUI/Macro/H_homeLink.pm b/lib/WebGUI/Macro/H_homeLink.pm index 4abae9c88..7f90d69a9 100644 --- a/lib/WebGUI/Macro/H_homeLink.pm +++ b/lib/WebGUI/Macro/H_homeLink.pm @@ -16,6 +16,31 @@ use WebGUI::Asset::Template; use WebGUI::International; use WebGUI::Session; +=head1 NAME + +Package WebGUI::Macro::H_homeLink + +=head1 DESCRIPTION + +Returns a templated link for the default page, determined by the WebGUI settings. + +=head2 process ( [label, templateUrl] ) + +=head3 label + +The text to present to the user as a link to the home page. If left blank, an +internationalized label will be used. If the label is the word "linkonly", +the macro will just return the bare link, with no templating. + +=head3 templateUrl + +A URL for a template to use to style the link. This can be used to add +images or other stuff. If left blank, a default template will +be used. + +=cut + + #------------------------------------------------------------------- sub process { my ($label, $templateUrl) = @_; diff --git a/lib/WebGUI/Macro/If.pm b/lib/WebGUI/Macro/If.pm index 8a2aa35ac..8cfc31e02 100644 --- a/lib/WebGUI/Macro/If.pm +++ b/lib/WebGUI/Macro/If.pm @@ -12,8 +12,37 @@ package WebGUI::Macro::If; use strict; +use WebGUI::International; use Safe; +=head1 NAME + +Package WebGUI::Macro::If + +=head1 DESCRIPTION + +A macro for implementing a simple conditional. + +=head2 process ( expression, trueResult, falseResult ) + +Returns trueResult if expression is true, falseResult if the expression +is false and an error message if there was a problem evaluating the +expression. + +=head3 expression + +A perl expression that will be evaulated in a Safe compartment. + +=head3 trueResult + +Text that will be returned if the expression is true. + +=head3 falseResult + +Text that will be returned if the expression is false. + +=cut + sub process { my ($expression, $true, $false) = @_; my $output = $false; @@ -22,8 +51,8 @@ sub process { my $compartment = new Safe; my $return = $compartment->reval($expression); - return "

If Macro failed: $@

Expression: $expression -
Display if true: $true
Display if false: $false" if ($@); + return sprintf(WebGUI::International::get('eval error', 'Macro_If'), + $@,$expression,$true,$false) if ($@); $output = $true if ($return); diff --git a/lib/WebGUI/i18n/English/Macro_If.pm b/lib/WebGUI/i18n/English/Macro_If.pm index 4509e0e5e..b5b2e8fe1 100644 --- a/lib/WebGUI/i18n/English/Macro_If.pm +++ b/lib/WebGUI/i18n/English/Macro_If.pm @@ -7,6 +7,12 @@ our $I18N = { lastUpdated => 1128838656, }, + 'eval error' => { + message => q|

If Macro failed: %s

Expression: %s +
Display if true: %s
Display if false: %s|, + lastUpdated => 1134967651, + }, + 'if title' => { message => q|If Macro|, lastUpdated => 1112466408,