forward port i18n AssetExportHtml error messages
This commit is contained in:
parent
5ab09308af
commit
8e6c3297bb
4 changed files with 30 additions and 6 deletions
|
|
@ -219,27 +219,27 @@ sub exportAsHtml {
|
|||
# verify them
|
||||
if(!defined $userId) {
|
||||
$returnCode = 0;
|
||||
$message = 'need a userId parameter';
|
||||
$message = $i18n->get('need a userId parameter');
|
||||
return ($returnCode, $message);
|
||||
}
|
||||
|
||||
# we take either a numeric userId or a WebGUI::User object
|
||||
if( ref $userId ne 'WebGUI::User' && ! (looks_like_number($userId) || $session->id->valid($userId))) {
|
||||
$returnCode = 0;
|
||||
$message = "'$userId' is not a valid userId";
|
||||
$message = "'$userId' ".$i18n->get('is not a valid userId');
|
||||
return ($returnCode, $message);
|
||||
}
|
||||
|
||||
# depth is required.
|
||||
if(!defined $depth) {
|
||||
$returnCode = 0;
|
||||
$message = 'need a depth';
|
||||
$message = $i18n->get('need a depth');
|
||||
return ($returnCode, $message);
|
||||
}
|
||||
# and it must be a number.
|
||||
if( !looks_like_number($depth) ) {
|
||||
$returnCode = 0;
|
||||
$message = "'$depth' is not a valid depth";
|
||||
$message = sprintf $i18n->get('%d is not a valid depth'), $depth;
|
||||
return ($returnCode, $message);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ A string that specifies the language that the user should see. Defaults to the
|
|||
|
||||
=cut
|
||||
|
||||
my $safeRe = qr/[^\.\w\d\s\/\^\;\?]/;
|
||||
my $safeRe = qr/[^\.\w\d\s\/\^\;\?%]/;
|
||||
|
||||
sub get {
|
||||
my ($self, $id, $namespace, $language) = @_;
|
||||
|
|
|
|||
|
|
@ -1127,6 +1127,30 @@ Couldn't open %-s because %-s <br />
|
|||
context => q{Error message in Asset.pm},
|
||||
}
|
||||
|
||||
'need a userId parameter' => {
|
||||
message => q{need a userId parameter},
|
||||
lastUpdated => 0,
|
||||
context => q{Error message in exportAsHtml for an illegal parameter.},
|
||||
},
|
||||
|
||||
'is not a valid userId' => {
|
||||
message => q{is not a valid userId},
|
||||
lastUpdated => 0,
|
||||
context => q{Error message in exportAsHtml for an illegal parameter.},
|
||||
},
|
||||
|
||||
'need a depth' => {
|
||||
message => q{need a depth},
|
||||
lastUpdated => 0,
|
||||
context => q{Error message in exportAsHtml for an illegal parameter.},
|
||||
},
|
||||
|
||||
'%s is not a valid depth' => {
|
||||
message => q{%s is not a valid depth},
|
||||
lastUpdated => 0,
|
||||
context => q{Error message in exportAsHtml for an illegal parameter.},
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -725,7 +725,7 @@ is($message, "need a depth", "exportAsHtml returns correct message when not give
|
|||
|
||||
($success, $message) = $home->exportAsHtml( { userId => 3, depth => 'orly? yarly!' } );
|
||||
is($success, 0, "exportAsHtml returns 0 when given bogus, memetic depth");
|
||||
is($message, "'orly? yarly!' is not a valid depth", "exportAsHtml returns correct message when given bogus, memetic depth");
|
||||
is($message, "orly? yarly! is not a valid depth", "exportAsHtml returns correct message when given bogus, memetic depth");
|
||||
|
||||
# next, let's make sure some simple exports work. export 'home', but clean up
|
||||
# the exportPath first to make sure there are no residuals from the tests
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue