diff options
author | louise <louise> | 2009-09-02 08:31:26 +0000 |
---|---|---|
committer | louise <louise> | 2009-09-02 08:31:26 +0000 |
commit | e6e851d1678dde40703ae63864dd5f4cfff5cbda (patch) | |
tree | afc75f34fee84a52258dda5f8b9715fdc5d5e8ad | |
parent | 122ab601e674c06915e481cc66e0dad92495a41a (diff) |
Change params for set_lang_and_domain
-rw-r--r-- | perllib/Cobrand.pm | 21 | ||||
-rw-r--r-- | perllib/Cobrands/Emptyhomes/Util.pm | 8 | ||||
-rwxr-xr-x | t/Cobrand.t | 11 |
3 files changed, 20 insertions, 20 deletions
diff --git a/perllib/Cobrand.pm b/perllib/Cobrand.pm index 63224aa54..b30b5fe48 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.6 2009-08-31 14:19:42 louise Exp $ +# $Id: Cobrand.pm,v 1.7 2009-09-02 08:32:00 louise Exp $ package Cobrand; use strict; @@ -31,8 +31,7 @@ site, if one exists, or zero if not. =cut sub cobrand_handle{ - my $q = shift; - my $cobrand = $q->{site}; + my $cobrand = shift; my $cobrand_class = ucfirst($cobrand); my $class = "Cobrands::" . $cobrand_class . "::Util"; eval "use $class"; @@ -51,7 +50,8 @@ Return a string containing the HTML to be rendered for a custom Cobranded page =cut sub cobrand_page{ my $q = shift; - my $handle = cobrand_handle($q); + my $cobrand = $q->{site}; + my $handle = cobrand_handle($cobrand); return 0 if $handle == 0; return $handle->page($q); } @@ -67,21 +67,22 @@ sub set_site_restriction{ my $q = shift; my $site_restriction = ''; my $site_id = 0; - my $handle = cobrand_handle($q); + my $cobrand = $q->{site}; + my $handle = cobrand_handle($cobrand); return ($site_restriction, $site_id) if $handle == 0; return $handle->site_restriction($q); } -=item set_lang_and_domain Q HOST +=item set_lang_and_domain COBRAND HOST -Set the language and domain of the site based on the query and host +Set the language and domain of the site based on the cobrand and host =cut sub set_lang_and_domain{ - my ($q, $host) = @_; - my $handle = cobrand_handle($q); + my ($cobrand, $host) = @_; + my $handle = cobrand_handle($cobrand); if ($handle != 0){ - $handle->set_lang_and_domain($q, $host); + $handle->set_lang_and_domain($host); } } diff --git a/perllib/Cobrands/Emptyhomes/Util.pm b/perllib/Cobrands/Emptyhomes/Util.pm index d5ba0dcb4..32fb86333 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.1 2009-08-31 14:19:42 louise Exp $ +# $Id: Util.pm,v 1.2 2009-09-02 08:31:26 louise Exp $ package Cobrands::Emptyhomes::Util; use Standard; @@ -57,14 +57,14 @@ sub page{ } } -=item set_lang_and_domain Q HOST +=item set_lang_and_domain HOST -Set the language and text domain for the site based on the query and host. +Set the language and text domain for the site based on the host. =cut sub set_lang_and_domain{ - my ($self, $q, $host) = @_; + my ($self, $host) = @_; my $lang; $lang = 'cy' if $host =~ /cy/; $lang = 'en-gb' if $host =~ /^en\./; diff --git a/t/Cobrand.t b/t/Cobrand.t index 5d00cfa03..fab80e3d2 100755 --- a/t/Cobrand.t +++ b/t/Cobrand.t @@ -6,7 +6,7 @@ # Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. # Email: louise@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: Cobrand.t,v 1.3 2009-08-31 09:56:11 louise Exp $ +# $Id: Cobrand.t,v 1.4 2009-09-02 08:32:23 louise Exp $ # use strict; @@ -35,12 +35,11 @@ sub test_site_restriction{ } sub test_cobrand_handle{ - my $q = new MockQuery('mysite'); - my $handle = Cobrand::cobrand_handle($q); + my $cobrand = 'mysite'; + my $handle = Cobrand::cobrand_handle($cobrand); like($handle->site_name(), qr/mysite/, 'should get a module handle if Util module exists for cobrand'); - - $q = new MockQuery('nosite'); - $handle = Cobrand::cobrand_handle($q); + $cobrand = 'nosite'; + $handle = Cobrand::cobrand_handle($cobrand); ok($handle == 0, 'should return zero if no module exists'); } |