diff --git a/lemonldap-ng-portal/MANIFEST b/lemonldap-ng-portal/MANIFEST index a18b5d463..6ed01b6f1 100644 --- a/lemonldap-ng-portal/MANIFEST +++ b/lemonldap-ng-portal/MANIFEST @@ -332,7 +332,6 @@ site/templates/bootstrap/customhead.tpl site/templates/bootstrap/customheader.tpl site/templates/bootstrap/customLoginFooter.tpl site/templates/bootstrap/customLoginHeader.tpl -site/templates/bootstrap/error.json.example site/templates/bootstrap/error.tpl site/templates/bootstrap/ext2fcheck.tpl site/templates/bootstrap/footer.tpl @@ -342,7 +341,6 @@ site/templates/bootstrap/idpchoice.tpl site/templates/bootstrap/impersonation.tpl site/templates/bootstrap/info.tpl site/templates/bootstrap/ldapPpGrace.tpl -site/templates/bootstrap/login.json site/templates/bootstrap/login.tpl site/templates/bootstrap/mail.tpl site/templates/bootstrap/menu.tpl @@ -400,7 +398,6 @@ site/templates/common/oidc_checksession.tpl site/templates/common/redirect.tpl site/templates/common/registerBrowser.tpl site/templates/common/script.tpl -site/templates/common/trover.tpl t/01-AuthDemo.t t/01-pdata.t t/02-Password-Demo.t diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm index 763426810..d953910f4 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm @@ -734,38 +734,39 @@ sub _dump { sub sendHtml { my ( $self, $req, $template, %args ) = @_; - $args{params}->{TROVER} = $self->trOver; - $args{templateDir} = - $self->conf->{templateDir} . '/' . $self->getSkin($req); - my $tmpl = $args{templateDir} . "/$template.tpl"; - my $troverJson = $args{templateDir} . "/$template.json"; + my $templateDir = $self->conf->{templateDir} . '/' . $self->getSkin($req); + + # Check template + $args{templateDir} = $templateDir; + my $tmpl = $args{templateDir} . "/$template.tpl"; unless ( -f $tmpl ) { - $self->logger->debug("Template : $tmpl NOT found!!!"); + $self->logger->debug("Template $tmpl not found"); $args{templateDir} = $self->conf->{templateDir} . '/bootstrap'; - $tmpl = $args{templateDir} . "/$template.tpl"; - $troverJson = $args{templateDir} . "/$template.json"; + $tmpl = $args{templateDir} . "/$template.tpl"; $self->logger->debug("-> Trying to load $tmpl"); } - if ( -r $troverJson ) { - open my $tr_file, '<', $troverJson - or die "Can't open" . $troverJson . " : $!"; - while (<$tr_file>) { - chomp; - $args{params}->{TROVERbyJSON} .= $_; - } - close $tr_file or die "Can't close $tr_file : $!"; - eval { decode_json( $args{params}->{TROVERbyJSON} ) }; - if ($@) { - $self->logger->debug("$troverJson is NOT a regular JSON file!!!"); - $args{params}->{TROVERbyJSON} = ''; + # Override messages + my $trOverMessages = JSON::from_json( $self->trOver ); + + opendir( DIR, $templateDir ); + my @langfiles = grep( /\.json$/, readdir(DIR) ); + close(DIR); + + foreach my $file (@langfiles) { + my ($lang) = ( $file =~ /^(\w+)\.json/ ); + $self->logger->debug("Use $file to override messages"); + if ( open my $json, "<", $templateDir . "/" . $file ) { + local $/ = undef; + $trOverMessages->{$lang} = JSON::from_json(<$json>); } else { - $self->logger->debug(" -> Overriding messages with $troverJson"); - $self->logger->debug( - " -> File content : $args{params}->{TROVERbyJSON}"); + $self->logger->error("Unable to read $file"); } } + + $args{params}->{TROVER} = JSON::to_json($trOverMessages); + my $res = $self->SUPER::sendHtml( $req, $template, %args ); push @{ $res->[1] }, 'X-XSS-Protection' => '1; mode=block', diff --git a/lemonldap-ng-portal/site/templates/bootstrap/error.json.example b/lemonldap-ng-portal/site/templates/bootstrap/error.json.example deleted file mode 100644 index d4ed76e76..000000000 --- a/lemonldap-ng-portal/site/templates/bootstrap/error.json.example +++ /dev/null @@ -1,3 +0,0 @@ -{ -"trOver":{"all":{},"fr":{"PE5":"Pas de chance, râté ! Merci de réessayer ..."},"en":{}} -} \ No newline at end of file diff --git a/lemonldap-ng-portal/site/templates/bootstrap/header.tpl b/lemonldap-ng-portal/site/templates/bootstrap/header.tpl index 9aa643ae5..29c848af7 100644 --- a/lemonldap-ng-portal/site/templates/bootstrap/header.tpl +++ b/lemonldap-ng-portal/site/templates/bootstrap/header.tpl @@ -39,7 +39,6 @@ " /> -