aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/View/Web.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/View/Web.pm')
-rw-r--r--perllib/FixMyStreet/App/View/Web.pm91
1 files changed, 91 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm
new file mode 100644
index 000000000..c8240948d
--- /dev/null
+++ b/perllib/FixMyStreet/App/View/Web.pm
@@ -0,0 +1,91 @@
+package FixMyStreet::App::View::Web;
+use base 'Catalyst::View::TT';
+
+use strict;
+use warnings;
+
+use mySociety::Locale;
+use FixMyStreet;
+use CrossSell;
+
+__PACKAGE__->config(
+ TEMPLATE_EXTENSION => '.html',
+ INCLUDE_PATH => [ #
+ FixMyStreet->path_to( 'templates', 'web', 'default' ),
+ ],
+ ENCODING => 'utf8',
+ render_die => 1,
+ expose_methods => [ 'loc', 'nget', 'tprintf', 'display_crossell_advert' ],
+);
+
+=head1 NAME
+
+FixMyStreet::App::View::Web - TT View for FixMyStreet::App
+
+=head1 DESCRIPTION
+
+TT View for FixMyStreet::App.
+
+=cut
+
+=head2 loc
+
+ [% loc('Some text to localize') %]
+
+Passes the text to the localisation engine for translations.
+
+=cut
+
+sub loc {
+ my ( $self, $c, @args ) = @_;
+ return _(@args);
+}
+
+=head2 nget
+
+ [% nget( 'singular', 'plural', $number ) %]
+
+Use first or second srting depending on the number.
+
+=cut
+
+sub nget {
+ my ( $self, $c, @args ) = @_;
+ return mySociety::Locale::nget(@args);
+}
+
+=head2 tprintf
+
+ [% tprintf( 'foo %s bar', 'insert' ) %]
+
+sprintf (different name to avoid clash)
+
+=cut
+
+sub tprintf {
+ my ( $self, $c, $format, @args ) = @_;
+ return sprintf $format, @args;
+}
+
+=head2 display_crossell_advert
+
+ [% display_crossell_advert( email, name ) %]
+
+Displays a crosssell advert if permitted by the cobrand.
+
+=cut
+
+sub display_crossell_advert {
+ my ( $self, $c, $email, $name ) = @_;
+
+ return unless $c->cobrand->allow_crosssell_adverts();
+
+ # fake up the old style $q
+ my $q = { site => $c->cobrand->moniker, };
+ $q->{site} = 'fixmystreet' if $q->{site} eq 'default';
+
+ return CrossSell::display_advert( $q, $email, $name );
+}
+
+1;
+