summaryrefslogtreecommitdiff
path: root/lib/VNDB/Handler/Misc.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-01-26 19:30:00 +0100
committerYorhel <git@yorhel.nl>2010-01-26 19:30:00 +0100
commit4dfb556ecc621b1983d7ad4154db202ec7530e44 (patch)
tree5de32cd553eeca355ad071b0be226f9cc0ca2727 /lib/VNDB/Handler/Misc.pm
parent5f5306216268e2bc97f7dccee24a9a8152553890 (diff)
Removed the ?l10n= parameter
Setting the l10n cookie is now done from a separate url: /setlang This makes the language determination code less complex, and makes sure nobody links to pages that change the UI language without intending to. (I've seen some links floating around with the l10n parameter included, which is... bad)
Diffstat (limited to 'lib/VNDB/Handler/Misc.pm')
-rw-r--r--lib/VNDB/Handler/Misc.pm15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm
index e2fdaa62..de4bdd67 100644
--- a/lib/VNDB/Handler/Misc.pm
+++ b/lib/VNDB/Handler/Misc.pm
@@ -13,6 +13,7 @@ YAWF::register(
qr{}, \&homepage,
qr{(?:([upvr])([1-9]\d*)/)?hist}, \&history,
qr{d([1-9]\d*)}, \&docpage,
+ qr{setlang}, \&setlang,
qr{nospam}, \&nospam,
qr{we-dont-like-ie6}, \&ie6message,
qr{opensearch\.xml}, \&opensearch,
@@ -328,6 +329,20 @@ sub docpage {
}
+sub setlang {
+ my $self = shift;
+
+ my $lang = $self->formValidate({name => 'lang', required => 1, enum => [ VNDB::L10N::languages ]});
+ return 404 if $lang->{_err};
+ $lang = $lang->{lang};
+
+ (my $ref = $self->reqHeader('Referer')||'/') =~ s/^\Q$self->{url}//;
+ $self->resRedirect($ref, 'post');
+ $self->resHeader('Set-Cookie', "l10n=$lang; expires=Sat, 01-Jan-2030 00:00:00 GMT; path=/; domain=$self->{cookie_domain}")
+ if $lang ne $self->{l10n}->language_tag();
+}
+
+
sub nospam {
my $self = shift;
$self->htmlHeader(title => mt '_nospam_title', noindex => 1);