From d085152304d86e03667a6c35b2f85d1c40884c3c Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 19 Dec 2005 05:34:13 +0000 Subject: [PATCH] Added POD to 4 macros. Internationalized Error messages for Include and LastModified --- lib/WebGUI/Macro/Include.pm | 25 +++++++++++++++++-- lib/WebGUI/Macro/International.pm | 25 +++++++++++++++++++ lib/WebGUI/Macro/JavaScript.pm | 19 ++++++++++++++ lib/WebGUI/Macro/LastModified.pm | 25 ++++++++++++++++++- lib/WebGUI/i18n/English/Macro_Include.pm | 15 +++++++++++ lib/WebGUI/i18n/English/Macro_LastModified.pm | 5 ++++ 6 files changed, 111 insertions(+), 3 deletions(-) diff --git a/lib/WebGUI/Macro/Include.pm b/lib/WebGUI/Macro/Include.pm index 808bf0d70..2cac3607b 100644 --- a/lib/WebGUI/Macro/Include.pm +++ b/lib/WebGUI/Macro/Include.pm @@ -12,13 +12,34 @@ package WebGUI::Macro::Include; use strict; use FileHandle; +use WebGUI::International; + +=head1 NAME + +Package WebGUI::Macro::Include + +=head1 DESCRIPTION + +Macro for returning the contents of a file from the filesystem. + +=head2 process ( filename ) + +process will return internationalized error messages if an illegal file +is read (password, group of config file) or if the file could not be found. + +=head3 filename + +The complete path to a file in the local filesystem. + +=cut + #------------------------------------------------------------------- sub process { my (@param, $temp, $file); @param = @_; if ($param[0] =~ /passwd/ || $param[0] =~ /shadow/ || $param[0] =~ /WebGUI.conf/) { - $temp = "SECURITY VIOLATION"; + $temp = WebGUI::International::get('security','Macro_Include'); } else { $file = FileHandle->new($param[0],"r"); if ($file) { @@ -27,7 +48,7 @@ sub process { } $file->close; } else { - $temp = "INCLUDED FILE DOES NOT EXIST"; + $temp = WebGUI::International::get('not found','Macro_Include'); } } return $temp; diff --git a/lib/WebGUI/Macro/International.pm b/lib/WebGUI/Macro/International.pm index a1f5089a4..55c3ca0ac 100644 --- a/lib/WebGUI/Macro/International.pm +++ b/lib/WebGUI/Macro/International.pm @@ -14,6 +14,31 @@ use strict; use WebGUI::International; use WebGUI::Session; +=head1 NAME + +Package WebGUI::Macro::International + +=head1 DESCRIPTION + +Macro for displaying an internationalized label from WebGUI's internationalization system. + +=head2 process ( label, namespace ) + +Note that a particular language cannot be specified. It uses either the +current User's setting or the default language for the site. English is +always used as a fallback. + +=head3 label + +The label to pull. + +=head3 namespace + +The namespace to pull the label from. + +=cut + + #------------------------------------------------------------------- sub process { return WebGUI::International::get(shift,shift); diff --git a/lib/WebGUI/Macro/JavaScript.pm b/lib/WebGUI/Macro/JavaScript.pm index 017869336..b4ba3bfaf 100644 --- a/lib/WebGUI/Macro/JavaScript.pm +++ b/lib/WebGUI/Macro/JavaScript.pm @@ -14,6 +14,25 @@ use strict; use WebGUI::Session; use WebGUI::Style; +=head1 NAME + +Package WebGUI::Macro::JavaScript + +=head1 DESCRIPTION + +This Macro is a wrapper for WebGUI::Style::setScript, which puts a script +tag into the head of the current page with the contents of the javascript +found at the url that is passed in. + +=head2 process ( url ) + +=head3 url + +URL to the javascript to include in the page's header tags. + +=cut + + #------------------------------------------------------------------- sub process { WebGUI::Style::setScript(shift,{type=>'text/javascript'}); diff --git a/lib/WebGUI/Macro/LastModified.pm b/lib/WebGUI/Macro/LastModified.pm index e09eedee7..d40fd8e4e 100644 --- a/lib/WebGUI/Macro/LastModified.pm +++ b/lib/WebGUI/Macro/LastModified.pm @@ -17,6 +17,29 @@ use WebGUI::Session; use WebGUI::International; use WebGUI::SQL; +=head1 NAME + +Package WebGUI::Macro::LastModified + +=head1 DESCRIPTION + +Macro for displaying the date that the most recent revision of the Asset was last modified. + +=head2 process ( [label, format] ) + +=head3 label + +Text to prepend to the date. This can be the empty string. + +=head3 format string + +A string specifying how to format the date using codes similar to those used by +sprintf. See L for a list of codes. Uses +"%z" if empty. + +=cut + + #------------------------------------------------------------------- sub process { return '' unless $session{asset}; @@ -24,7 +47,7 @@ sub process { ($label, $format) = @_; $format = '%z' if ($format eq ""); ($time) = WebGUI::SQL->quickArray("SELECT max(revisionDate) FROM assetData where assetId=".quote($session{asset}->getId),WebGUI::SQL->getSlave); - return WebGUI::International::get(43,'Asset_Survey') if $time eq 0; + return WebGUI::International::get('never','Macro_LastModified') if $time eq 0; return $label.epochToHuman($time,$format) if ($time); } diff --git a/lib/WebGUI/i18n/English/Macro_Include.pm b/lib/WebGUI/i18n/English/Macro_Include.pm index 3fb124ffd..9f7bb850d 100644 --- a/lib/WebGUI/i18n/English/Macro_Include.pm +++ b/lib/WebGUI/i18n/English/Macro_Include.pm @@ -7,6 +7,21 @@ our $I18N = { lastUpdated => 1128838682, }, + 'security' => { + message => q|SECURITY VIOLATION|, + lastUpdated => 1134968524, + }, + + 'not found' => { + message => q|INCLUDED FILE DOES NOT EXIST|, + lastUpdated => 1134968522, + }, + + 'include title' => { + message => q|Include Macro|, + lastUpdated => 1112466408, + }, + 'include title' => { message => q|Include Macro|, lastUpdated => 1112466408, diff --git a/lib/WebGUI/i18n/English/Macro_LastModified.pm b/lib/WebGUI/i18n/English/Macro_LastModified.pm index d6b84741f..ca84013d3 100644 --- a/lib/WebGUI/i18n/English/Macro_LastModified.pm +++ b/lib/WebGUI/i18n/English/Macro_LastModified.pm @@ -2,6 +2,11 @@ package WebGUI::i18n::English::Macro_LastModified; our $I18N = { + 'never' => { + message => q|Never|, + lastUpdated => 1134969093 + }, + 'macroName' => { message => q|LastModified|, lastUpdated => 1128839043,