Added POD to 4 macros.
Internationalized Error messages for Include and LastModified
This commit is contained in:
parent
01816cd806
commit
d085152304
6 changed files with 111 additions and 3 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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'});
|
||||
|
|
|
|||
|
|
@ -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<WebGUI::DateTime/"epochToHuman"> 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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,11 @@ package WebGUI::i18n::English::Macro_LastModified;
|
|||
|
||||
our $I18N = {
|
||||
|
||||
'never' => {
|
||||
message => q|Never|,
|
||||
lastUpdated => 1134969093
|
||||
},
|
||||
|
||||
'macroName' => {
|
||||
message => q|LastModified|,
|
||||
lastUpdated => 1128839043,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue