aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/Cobrand.pm16
-rw-r--r--perllib/Cobrands/Emptyhomes/Util.pm77
-rw-r--r--perllib/Page.pm11
3 files changed, 95 insertions, 9 deletions
diff --git a/perllib/Cobrand.pm b/perllib/Cobrand.pm
index 26fc6c95e..63224aa54 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.5 2009-08-31 09:48:55 louise Exp $
+# $Id: Cobrand.pm,v 1.6 2009-08-31 14:19:42 louise Exp $
package Cobrand;
use strict;
@@ -36,6 +36,7 @@ sub cobrand_handle{
my $cobrand_class = ucfirst($cobrand);
my $class = "Cobrands::" . $cobrand_class . "::Util";
eval "use $class";
+
my $handle;
eval{ $handle = $class->new };
return 0 if $@;
@@ -71,5 +72,18 @@ sub set_site_restriction{
return $handle->site_restriction($q);
}
+
+=item set_lang_and_domain Q HOST
+
+Set the language and domain of the site based on the query and host
+=cut
+sub set_lang_and_domain{
+ my ($q, $host) = @_;
+ my $handle = cobrand_handle($q);
+ if ($handle != 0){
+ $handle->set_lang_and_domain($q, $host);
+ }
+}
+
1;
diff --git a/perllib/Cobrands/Emptyhomes/Util.pm b/perllib/Cobrands/Emptyhomes/Util.pm
new file mode 100644
index 000000000..d5ba0dcb4
--- /dev/null
+++ b/perllib/Cobrands/Emptyhomes/Util.pm
@@ -0,0 +1,77 @@
+#!/usr/bin/perl -w
+#
+# Util.pm:
+# Emptyhomes Cobranding for FixMyStreet.
+#
+#
+# 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 $
+
+package Cobrands::Emptyhomes::Util;
+use Standard;
+use strict;
+use Carp;
+use mySociety::Web qw(ent);
+
+sub new{
+ my $class = shift;
+ return bless {}, $class;
+}
+
+=item site_restriction Q
+
+Return a site restriction clause and a site key.
+
+=cut
+sub site_restriction{
+ return ('', 0);
+}
+
+=item
+
+Return the list of custom pages that can be produced by this module
+
+=cut
+
+sub pages{
+ return qw();
+}
+
+=item page Q
+
+Return HTML for the page specified by the cobrand_page parameter in
+the query.
+
+=cut
+
+sub page{
+ my $self = shift;
+ my $q = shift;
+ my $page_requested = $q->param('cobrand_page');
+ if (grep ($_ eq $page_requested, $self->pages())){
+ return $self->$page_requested($q);
+ }else{
+ throw Error::Simple("Unknown page");
+ }
+}
+
+=item set_lang_and_domain Q HOST
+
+Set the language and text domain for the site based on the query and host.
+
+=cut
+
+sub set_lang_and_domain{
+ my ($self, $q, $host) = @_;
+ my $lang;
+ $lang = 'cy' if $host =~ /cy/;
+ $lang = 'en-gb' if $host =~ /^en\./;
+ mySociety::Locale::negotiate_language('en-gb,English,en_GB|cy,Cymraeg,cy_GB', $lang);
+ mySociety::Locale::gettext_domain('FixMyStreet-EmptyHomes');
+ mySociety::Locale::change();
+}
+
+1;
+
diff --git a/perllib/Page.pm b/perllib/Page.pm
index 10ba6f084..6d6c6a94d 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.165 2009-08-31 12:22:54 louise Exp $
+# $Id: Page.pm,v 1.166 2009-08-31 14:19:42 louise Exp $
#
package Page;
@@ -104,13 +104,8 @@ sub microsite {
$q->{site} = $cobrand if $host =~ /$cobrand/;
}
- if ($q->{site} eq 'emptyhomes') {
- my $lang;
- $lang = 'cy' if $host =~ /cy/;
- $lang = 'en-gb' if $host =~ /^en\./;
- mySociety::Locale::negotiate_language('en-gb,English,en_GB|cy,Cymraeg,cy_GB', $lang);
- mySociety::Locale::gettext_domain('FixMyStreet-EmptyHomes');
- mySociety::Locale::change();
+ if ($q->{site} ne 'fixmystreet') {
+ Cobrand::set_lang_and_domain($q, $host);
} else {
mySociety::Locale::negotiate_language('en-gb,English,en_GB|nb,Norwegian,nb_NO'); # XXX Testing
mySociety::Locale::gettext_domain('FixMyStreet');