diff options
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/Cobrand.pm | 22 | ||||
-rw-r--r-- | perllib/Cobrands/Emptyhomes/Util.pm | 22 | ||||
-rw-r--r-- | perllib/Page.pm | 16 |
3 files changed, 42 insertions, 18 deletions
diff --git a/perllib/Cobrand.pm b/perllib/Cobrand.pm index f9dea2210..d589c9fbe 100644 --- a/perllib/Cobrand.pm +++ b/perllib/Cobrand.pm @@ -7,7 +7,7 @@ # Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. # Email: louise@mysociety.org. WWW: http://www.mysociety.org # -# $Id: Cobrand.pm,v 1.10 2009-09-09 10:18:01 louise Exp $ +# $Id: Cobrand.pm,v 1.11 2009-09-09 15:29:26 louise Exp $ package Cobrand; use strict; @@ -78,18 +78,34 @@ sub set_site_restriction{ return $handle->site_restriction($q); } +=item base_url COBRAND + +Return the base url for the cobranded version of the site + +=cut +sub base_url{ + my $cobrand = shift; + my $handle = cobrand_handle($cobrand); + return mySociety::Config::get('BASE_URL') unless $handle; + return $handle->base_url(); +} =item set_lang_and_domain COBRAND LANG Set the language and domain of the site based on the cobrand and host + =cut -sub set_lang_and_domain{ - my ($cobrand, $lang) = @_; +sub set_lang_and_domain($$;$) { + my ($cobrand, $lang, $unicode) = @_; if ($cobrand){ my $handle = cobrand_handle($cobrand); if ($handle){ $handle->set_lang_and_domain($lang); } + }else{ + mySociety::Locale::negotiate_language('en-gb,English,en_GB|nb,Norwegian,nb_NO'); # XXX Testing + mySociety::Locale::gettext_domain('FixMyStreet', $unicode); + mySociety::Locale::change(); } } diff --git a/perllib/Cobrands/Emptyhomes/Util.pm b/perllib/Cobrands/Emptyhomes/Util.pm index 560d85ceb..8dbeca4b4 100644 --- a/perllib/Cobrands/Emptyhomes/Util.pm +++ b/perllib/Cobrands/Emptyhomes/Util.pm @@ -7,7 +7,7 @@ # Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. # Email: louise@mysociety.org. WWW: http://www.mysociety.org # -# $Id: Util.pm,v 1.3 2009-09-02 08:55:59 louise Exp $ +# $Id: Util.pm,v 1.4 2009-09-09 15:29:27 louise Exp $ package Cobrands::Emptyhomes::Util; use Standard; @@ -31,6 +31,20 @@ sub site_restriction{ =item +Return the base url for this cobranded site + +=cut + +sub base_url { + my $base_url = mySociety::Config::get('BASE_URL'); + if ($base_url !~ /emptyhomes/) { + $base_url =~ s/http:\/\//http:\/\/emptyhomes\./g; + } + return $base_url; +} + +=item + Return the list of custom pages that can be produced by this module =cut @@ -57,16 +71,16 @@ sub page{ } } -=item set_lang_and_domain Q HOST +=item set_lang_and_domain LANG UNICODE Set the language and text domain for the site based on the query and host. =cut sub set_lang_and_domain{ - my ($self, $lang) = @_; + my ($self, $lang, $unicode) = @_; mySociety::Locale::negotiate_language('en-gb,English,en_GB|cy,Cymraeg,cy_GB', $lang); - mySociety::Locale::gettext_domain('FixMyStreet-EmptyHomes'); + mySociety::Locale::gettext_domain('FixMyStreet-EmptyHomes', $unicode); mySociety::Locale::change(); } diff --git a/perllib/Page.pm b/perllib/Page.pm index 712f206dc..df491957b 100644 --- a/perllib/Page.pm +++ b/perllib/Page.pm @@ -6,7 +6,7 @@ # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: Page.pm,v 1.173 2009-09-09 08:27:46 louise Exp $ +# $Id: Page.pm,v 1.174 2009-09-09 15:29:26 louise Exp $ # package Page; @@ -104,16 +104,10 @@ sub microsite { $q->{site} = $cobrand if $host =~ /$cobrand/; } - if ($q->{site} ne 'fixmystreet') { - my $lang; - $lang = 'cy' if $host =~ /cy/; - $lang = 'en-gb' if $host =~ /^en\./; - Cobrand::set_lang_and_domain($q->{site}, $lang); - } else { - mySociety::Locale::negotiate_language('en-gb,English,en_GB|nb,Norwegian,nb_NO'); # XXX Testing - mySociety::Locale::gettext_domain('FixMyStreet'); - mySociety::Locale::change(); - } + my $lang; + $lang = 'cy' if $host =~ /cy/; + $lang = 'en-gb' if $host =~ /^en\./; + Cobrand::set_lang_and_domain(get_cobrand($q), $lang); Problems::set_site_restriction($q); Memcached::set_namespace(mySociety::Config::get('BCI_DB_NAME') . ":"); |