diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Alert.pm | 56 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FiksGataMi.pm | 83 |
2 files changed, 84 insertions, 55 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Alert.pm b/perllib/FixMyStreet/App/Controller/Alert.pm index 96498e1ab..aa51f1ba3 100644 --- a/perllib/FixMyStreet/App/Controller/Alert.pm +++ b/perllib/FixMyStreet/App/Controller/Alert.pm @@ -337,60 +337,6 @@ sub prettify_pc : Private { return 1; } -sub council_options : Private { - my ( $self, $c ) = @_; - - if ( $c->config->{COUNTRY} eq 'NO' ) { - -# my ($options, $options_start, $options_end); -# if (mySociety::Config::get('COUNTRY') eq 'NO') { -# -# my (@options, $fylke, $kommune); -# foreach (values %$areas) { -# if ($_->{type} eq 'NKO') { -# $kommune = $_; -# } else { -# $fylke = $_; -# } -# } -# my $kommune_name = $kommune->{name}; -# my $fylke_name = $fylke->{name}; -# -# if ($fylke->{id} == 3) { # Oslo -# -# push @options, [ 'council', $fylke->{id}, Page::short_name($fylke), -# sprintf(_("Problems within %s"), $fylke_name) ]; -# -# $options_start = "<div><ul id='rss_feed'>"; -# $options = alert_list_options($q, @options); -# $options_end = "</ul>"; -# -# } else { -# -# push @options, -# [ 'area', $kommune->{id}, Page::short_name($kommune), $kommune_name ], -# [ 'area', $fylke->{id}, Page::short_name($fylke), $fylke_name ]; -# $options_start = '<div id="rss_list">'; -# $options = $q->p($q->strong(_('Problems within the boundary of:'))) . -# $q->ul(alert_list_options($q, @options)); -# @options = (); -# push @options, -# [ 'council', $kommune->{id}, Page::short_name($kommune), $kommune_name ], -# [ 'council', $fylke->{id}, Page::short_name($fylke), $fylke_name ]; -# $options .= $q->p($q->strong(_('Or problems reported to:'))) . -# $q->ul(alert_list_options($q, @options)); -# $options_end = $q->p($q->small(_('FixMyStreet sends different categories of problem -#to the appropriate council, so problems within the boundary of a particular council -#might not match the problems sent to that council. For example, a graffiti report -#will be sent to the district council, so will appear in both of the district -#council’s alerts, but will only appear in the "Within the boundary" alert -#for the county council.'))) . '</div><div id="rss_buttons">'; -# -# } -# - } -} - sub process_user : Private { my ( $self, $c ) = @_; @@ -454,7 +400,7 @@ sub setup_council_rss_feeds : Private { } ( $c->stash->{options}, $c->stash->{reported_to_options} ) = - $c->cobrand->council_rss_alert_options( $c->stash->{all_councils} ); + $c->cobrand->council_rss_alert_options( $c->stash->{all_councils}, $c ); return 1; } diff --git a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm index aaa5f281b..9516cf0f6 100644 --- a/perllib/FixMyStreet/Cobrand/FiksGataMi.pm +++ b/perllib/FixMyStreet/Cobrand/FiksGataMi.pm @@ -40,6 +40,7 @@ sub area_min_generation { sub uri { my ( $self, $uri ) = @_; + $uri = URI->new( $uri ); $uri->query_param( zoom => 2 ) if $uri->query_param('lat') && !$uri->query_param('zoom'); @@ -78,6 +79,88 @@ sub short_name { } +sub council_rss_alert_options { + my $self = shift; + my $all_councils = shift; + my $c = shift; + + my ( @options, @reported_to_options, $fylke, $kommune ); + + foreach ( values %$all_councils ) { + if ( $_->{type} eq 'NKO' ) { + $kommune = $_; + } + else { + $fylke = $_; + } + } + + if ( $fylke->{id} == 3 ) { # Oslo + my $short_name = $self->short_name($fylke, $all_councils); + ( my $id_name = $short_name ) =~ tr/+/_/; + + push @options, + { + type => 'council', + id => sprintf( 'council:%s:%s', $fylke->{id}, $id_name ), + rss_text => + sprintf( _('RSS feed of problems within %s'), $fylke->{name} ), + text => sprintf( _('Problems within %s'), $fylke->{name} ), + uri => $c->uri_for( '/rss/reports', $short_name ), + }; + } + else { + my $short_kommune_name = $self->short_name($kommune, $all_councils); + ( my $id_kommune_name = $short_kommune_name ) =~ tr/+/_/; + + my $short_fylke_name = $self->short_name($fylke, $all_councils); + ( my $id_fylke_name = $short_fylke_name ) =~ tr/+/_/; + + push @options, + { + type => 'area', + id => sprintf( 'area:%s:%s', $kommune->{id}, $id_kommune_name ), + rss_text => + sprintf( _('RSS feed of %s'), $kommune->{name} ), + text => $kommune->{name}, + uri => $c->uri_for( '/rss/area', $short_kommune_name ), + }, + { + type => 'area', + id => sprintf( 'area:%s:%s', $fylke->{id}, $id_fylke_name ), + rss_text => + sprintf( _('RSS feed of %s'), $fylke->{name} ), + text => $fylke->{name}, + uri => $c->uri_for( '/rss/area', $short_fylke_name ), + }; + + push @reported_to_options, + { + type => 'council', + id => sprintf( 'council:%s:%s', $kommune->{id}, $id_kommune_name ), + rss_text => + sprintf( _('RSS feed of %s'), $kommune->{name} ), + text => $kommune->{name}, + uri => $c->uri_for( '/rss/reports', $short_kommune_name ), + }, + { + type => 'council', + id => sprintf( 'council:%s:%s', $fylke->{id}, $id_fylke_name ), + rss_text => + sprintf( _('RSS feed of %s'), $fylke->{name} ), + text => $fylke->{name}, + uri => $c->uri_for( '/rss/reports/', $short_fylke_name ), + }; + } + + return ( + \@options, @reported_to_options + ? \@reported_to_options + : undef + ); + +} + sub reports_council_check { my ( $self, $c, $council ) = @_; |