Commit 059d5320 authored by Clément OUDOT's avatar Clément OUDOT

Clean code that manages templates parameters (#1634, #1631)

parent d7c252d5
...@@ -418,18 +418,6 @@ sub display { ...@@ -418,18 +418,6 @@ sub display {
} }
# Additional $req param
%templateParams = ( %templateParams, %{ $req->{customParameters} // {} }, );
for my $session_key ( keys %{ $req->{sessionInfo} } ) {
$templateParams{ "session_" . $session_key } =
$req->{sessionInfo}->{$session_key};
}
for my $env_key ( keys %{ $req->env } ) {
$templateParams{ "env_" . $env_key } = $req->env->{$env_key};
}
$self->logger->debug("Skin returned: $skinfile"); $self->logger->debug("Skin returned: $skinfile");
return ( $skinfile, \%templateParams ); return ( $skinfile, \%templateParams );
} }
......
...@@ -843,16 +843,30 @@ sub rebuildCookies { ...@@ -843,16 +843,30 @@ sub rebuildCookies {
} }
sub tplParams { sub tplParams {
my $portalPath = $_[0]->conf->{portal}; my ( $self, $req ) = @_;
my %templateParams;
my $portalPath = $self->conf->{portal};
$portalPath =~ s#^https?://[^/]+/?#/#; $portalPath =~ s#^https?://[^/]+/?#/#;
$portalPath =~ s#[^/]+\.fcgi$##; $portalPath =~ s#[^/]+\.fcgi$##;
for my $session_key ( keys %{ $req->{sessionInfo} } ) {
$templateParams{ "session_" . $session_key } =
$req->{sessionInfo}->{$session_key};
}
for my $env_key ( keys %{ $req->env } ) {
$templateParams{ "env_" . $env_key } = $req->env->{$env_key};
}
return ( return (
SKIN => $_[0]->getSkin( $_[1] ), SKIN => $self->getSkin( $req ),
PORTAL_URL => $_[0]->conf->{portal}, PORTAL_URL => $self->conf->{portal},
SKIN_PATH => $portalPath . "skins", SKIN_PATH => $portalPath . "skins",
ANTIFRAME => $_[0]->conf->{portalAntiFrame}, ANTIFRAME => $self->conf->{portalAntiFrame},
SKIN_BG => $_[0]->conf->{portalSkinBackground}, SKIN_BG => $self->conf->{portalSkinBackground},
( $_[0]->customParameters ? ( %{ $_[0]->customParameters } ) : () ), ( $self->customParameters ? ( %{ $self->customParameters } ) : () ),
%templateParams
); );
} }
......
...@@ -594,17 +594,6 @@ sub display { ...@@ -594,17 +594,6 @@ sub display {
$tplPrm{DISPLAY_PASSWORD_FORM} = $req->sessionInfo->{pwdAllowed}; $tplPrm{DISPLAY_PASSWORD_FORM} = $req->sessionInfo->{pwdAllowed};
} }
# Custom template parameters
if ( my $customParams = $self->p->customParameters ) {
foreach ( keys %$customParams ) {
$tplPrm{$_} = $customParams->{$_};
}
}
for my $env_key ( keys %{ $req->env } ) {
$tplPrm{ "env_" . $env_key } = $req->env->{$env_key};
}
return 'mail', \%tplPrm; return 'mail', \%tplPrm;
} }
......
...@@ -522,10 +522,6 @@ sub display { ...@@ -522,10 +522,6 @@ sub display {
); );
} }
for my $env_key ( keys %{ $req->env } ) {
$templateParams{ "env_" . $env_key } = $req->env->{$env_key};
}
return ( 'register', \%templateParams ); return ( 'register', \%templateParams );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment