Skip to content

Commit

Permalink
Add title phrase and warning if some how SetLang page is loaded and n…
Browse files Browse the repository at this point in the history
…ot redirected. Allow referrer to also be a local path. Use frontpage not home_page config option as default referrer if not otherwise set.
  • Loading branch information
drn05r authored and root committed Jun 4, 2021
1 parent dff6356 commit 94aa768
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/lang/en/phrases/system.xml
Expand Up @@ -3334,7 +3334,10 @@ PY = 2006 and OG = (Cambridge)<br />

<epp:phrase id="Plugin/Screen/Admin/Config/Edit:could_not_write">Could not write file '<epc:pin name="filename" />'. Error message: <epc:pin name="error_msg" /></epp:phrase>

<!-- Language -->

<epp:phrase id="Plugin/Screen/SetLang:title">Set Language</epp:phrase>
<epp:phrase id="Plugin/Screen/SetLang:no_redirect">If you are viewing this page, something has gone wrong. This page only exists as a means for setting the language in which you want to view this repository and then redirecting you back to your original page.</epp:phrase>

<epp:phrase id="languages_typename_" ref="lib/metafield:unspecified" />

Expand Down
15 changes: 13 additions & 2 deletions perl_lib/EPrints/Plugin/Screen/SetLang.pm
Expand Up @@ -47,12 +47,12 @@ sub from
{
my $referrer_uri = URI->new($referrer);
my $repository_uri = URI->new($session->config('base_url'));
if ($referrer_uri->host ne $repository_uri->host)
if ($referrer_uri->can( "host" ) && $referrer_uri->host ne $repository_uri->host)
{
$referrer = undef;
}
}
$referrer = $session->config( "home_page" ) unless( EPrints::Utils::is_set( $referrer ) );
$referrer = $session->config( "frontpage" ) unless( EPrints::Utils::is_set( $referrer ) );

$self->{processor}->{redirect} = $referrer;
}
Expand Down Expand Up @@ -129,6 +129,17 @@ sub render_action_link
return $div;
}

sub render
{
my( $self ) = @_;

my $chunk = $self->{session}->make_doc_fragment;
$chunk->appendChild( $self->html_phrase( "no_redirect" ) );

return $chunk;
}


1;

=head1 COPYRIGHT
Expand Down

0 comments on commit 94aa768

Please sign in to comment.