making config addToArray only add if it's not already there.
This commit is contained in:
parent
71881282aa
commit
3fad0b078f
2 changed files with 8 additions and 1 deletions
|
|
@ -79,6 +79,7 @@ sub addToArray {
|
|||
my $property = shift;
|
||||
my $value = shift;
|
||||
my $array = $self->get($property);
|
||||
return undef if isIn($value,@{$array});
|
||||
push(@{$array}, $value);
|
||||
$self->set($property, $array);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package WebGUI::International;
|
|||
|
||||
use strict qw(vars subs);
|
||||
|
||||
our %l10nCache;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -79,6 +80,7 @@ sub get {
|
|||
$id =~ s/$safeRe//g;
|
||||
$language =~ s/$safeRe//g;
|
||||
$namespace =~ s/$safeRe//g;
|
||||
return $l10nCache{$language}{$namespace}{$id} if $l10nCache{$language}{$namespace}{$id};
|
||||
my $cmd = "WebGUI::i18n::".$language."::".$namespace;
|
||||
my $load = "use ".$cmd;
|
||||
eval($load);
|
||||
|
|
@ -87,6 +89,7 @@ sub get {
|
|||
my $output = eval($cmd);
|
||||
$self->session->errorHandler->warn("Couldn't get value from ".$cmd." because ".$@) if ($@);
|
||||
$output = $self->get($id,$namespace,"English") if ($output eq "" && $language ne "English");
|
||||
$l10nCache{$language}{$namespace}{$id} = $output || $id;
|
||||
return $output || $id;
|
||||
}
|
||||
|
||||
|
|
@ -207,11 +210,14 @@ Specify a default language. Defaults to user preference or "English".
|
|||
|
||||
sub new {
|
||||
my ($class, $session, $namespace, $language) = @_;
|
||||
bless( {
|
||||
return $l10nCache{namespaces}{$namespace} if $l10nCache{namespaces}{$namespace};
|
||||
my $self = bless( {
|
||||
_session => $session,
|
||||
_namespace => $namespace,
|
||||
_language => ($language || $session->user->profileField('language')),
|
||||
},$class);
|
||||
$l10nCache{namespaces}{$namespace} = $self;
|
||||
return $self;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue