aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rwxr-xr-xweb/ajax.cgi6
-rwxr-xr-xweb/alert.cgi118
-rw-r--r--web/cobrands/fiksgatami/css.css3
-rwxr-xr-xweb/contact.cgi11
-rwxr-xr-xweb/import.cgi8
-rwxr-xr-xweb/index.cgi156
-rw-r--r--web/js/map-OpenStreetMap.js76
-rwxr-xr-xweb/photo.cgi2
-rwxr-xr-xweb/questionnaire.cgi5
-rwxr-xr-xweb/reports.cgi119
-rwxr-xr-xweb/rss.cgi44
11 files changed, 384 insertions, 164 deletions
diff --git a/web/ajax.cgi b/web/ajax.cgi
index 69c389765..f13529852 100755
--- a/web/ajax.cgi
+++ b/web/ajax.cgi
@@ -59,8 +59,8 @@ sub main {
$list = '';
foreach (@$around_map) {
- my $dist = int($_->{distance}/100+.5)/10;
- $link = Cobrand::url($cobrand, NewURL($q, -retain => 1,
+ my $dist = int($_->{distance}*10+.5)/10;
+ $link = Cobrand::url($cobrand, NewURL($q, -retain => 1,
-url => '/report/' . $_->{id},
pc => undef,
x => undef,
@@ -81,7 +81,7 @@ sub main {
#$list = '';
#foreach (@$fixed) {
# $list .= '<li><a href="/report/' . $_->{id} . '">';
- # $list .= $_->{title} . ' <small>(' . int($_->{distance}/100+.5)/10 . 'km)</small>';
+ # $list .= $_->{title} . ' <small>(' . int($_->{distance}*10+.5)/10 . 'km)</small>';
# $list .= '</a></li>';
#}
#my $f_list = $list;
diff --git a/web/alert.cgi b/web/alert.cgi
index 896ca9ccc..e2a4efaac 100755
--- a/web/alert.cgi
+++ b/web/alert.cgi
@@ -11,6 +11,7 @@
use strict;
use Standard;
use Digest::SHA1 qw(sha1_hex);
+use Encode;
use Error qw(:try);
use CrossSell;
use FixMyStreet::Alert;
@@ -96,28 +97,76 @@ sub alert_list {
return alert_front_page($q, $error) if $error;
my $pretty_pc = $input_h{pc};
+ my $pretty_pc_text;# This one isnt't getting the nbsp.
if (mySociety::PostcodeUtil::is_valid_postcode($input{pc})) {
$pretty_pc = mySociety::PostcodeUtil::canonicalise_postcode($input{pc});
+ $pretty_pc_text = $pretty_pc;
+ $pretty_pc_text =~ s/ //g;
$pretty_pc =~ s/ /&nbsp;/;
}
my $errors = '';
$errors = '<ul class="error"><li>' . join('</li><li>', @errors) . '</li></ul>' if @errors;
- my @types = (@$mySociety::VotingArea::council_parent_types, @$mySociety::VotingArea::council_child_types);
- my %councils = map { $_ => 1 } @$mySociety::VotingArea::council_parent_types;
+ my $cobrand = Page::get_cobrand($q);
+ my @types = (Cobrand::area_types($cobrand), @$mySociety::VotingArea::council_child_types);
+ my %councils = map { $_ => 1 } Cobrand::area_types($cobrand);
my $areas = mySociety::MaPit::call('point', "4326/$lon,$lat", type => \@types);
- my $cobrand = Page::get_cobrand($q);
my ($success, $error_msg) = Cobrand::council_check($cobrand, { all_councils => $areas }, $q, 'alert');
- if (!$success){
+ if (!$success) {
return alert_front_page($q, $error_msg);
}
return alert_front_page($q, _('That location does not appear to be covered by a council, perhaps it is offshore - please try somewhere more specific.')) if keys %$areas == 0;
my ($options, $options_start, $options_end);
- if (keys %$areas == 2) {
+ 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&rsquo;s alerts, but will only appear in the "Within the boundary" alert
+for the county council.'))) . '</div><div id="rss_buttons">';
+
+ }
+
+ } elsif (keys %$areas == 2) {
# One-tier council
my (@options, $council, $ward);
@@ -128,10 +177,12 @@ sub alert_list {
$ward = $_;
}
}
- push @options, [ 'council', $council->{id}, Page::short_name($council->{name}),
- sprintf(_("Problems within %s"), $council->{name}) ];
- push @options, [ 'ward', $council->{id}.':'.$ward->{id}, Page::short_name($council->{name}) . '/'
- . Page::short_name($ward->{name}), sprintf(_("Problems within %s ward"), $ward->{name}) ];
+ my $council_name = $council->{name};
+ my $ward_name = $ward->{name};
+ push @options, [ 'council', $council->{id}, Page::short_name($council),
+ sprintf(_("Problems within %s"), $council_name) ];
+ push @options, [ 'ward', $council->{id}.':'.$ward->{id}, Page::short_name($council) . '/'
+ . Page::short_name($ward), sprintf(_("Problems within %s ward"), $ward_name) ];
$options_start = "<div><ul id='rss_feed'>";
$options = alert_list_options($q, @options);
@@ -144,8 +195,9 @@ sub alert_list {
foreach (values %$areas) {
$council = $_;
}
- push @options, [ 'council', $council->{id}, Page::short_name($council->{name}),
- sprintf(_("Problems within %s"), $council->{name}) ];
+ my $council_name = $council->{name};
+ push @options, [ 'council', $council->{id}, Page::short_name($council),
+ sprintf(_("Problems within %s"), $council_name) ];
$options_start = "<div><ul id='rss_feed'>";
$options = alert_list_options($q, @options);
@@ -166,26 +218,30 @@ sub alert_list {
$d_ward = $_;
}
}
+ my $district_name = $district->{name};
+ my $d_ward_name = $d_ward->{name};
+ my $county_name = $county->{name};
+ my $c_ward_name = $c_ward->{name};
push @options,
- [ 'area', $district->{id}, Page::short_name($district->{name}), $district->{name} ],
- [ 'area', $district->{id}.':'.$d_ward->{id}, Page::short_name($district->{name}) . '/'
- . Page::short_name($d_ward->{name}), "$d_ward->{name} ward, $district->{name}" ],
- [ 'area', $county->{id}, Page::short_name($county->{name}), $county->{name} ],
- [ 'area', $county->{id}.':'.$c_ward->{id}, Page::short_name($county->{name}) . '/'
- . Page::short_name($c_ward->{name}), "$c_ward->{name} ward, $county->{name}" ];
+ [ 'area', $district->{id}, Page::short_name($district), $district_name ],
+ [ 'area', $district->{id}.':'.$d_ward->{id}, Page::short_name($district) . '/'
+ . Page::short_name($d_ward), "$d_ward_name ward, $district_name" ],
+ [ 'area', $county->{id}, Page::short_name($county), $county_name ],
+ [ 'area', $county->{id}.':'.$c_ward->{id}, Page::short_name($county) . '/'
+ . Page::short_name($c_ward), "$c_ward_name ward, $county_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', $district->{id}, Page::short_name($district->{name}), $district->{name} ],
- [ 'ward', $district->{id}.':'.$d_ward->{id}, Page::short_name($district->{name}) . '/' . Page::short_name($d_ward->{name}),
- "$district->{name}, within $d_ward->{name} ward" ];
+ [ 'council', $district->{id}, Page::short_name($district), $district_name ],
+ [ 'ward', $district->{id}.':'.$d_ward->{id}, Page::short_name($district) . '/' . Page::short_name($d_ward),
+ "$district_name, within $d_ward_name ward" ];
if ($q->{site} ne 'emptyhomes') {
push @options,
- [ 'council', $county->{id}, Page::short_name($county->{name}), $county->{name} ],
- [ 'ward', $county->{id}.':'.$c_ward->{id}, Page::short_name($county->{name}) . '/'
- . Page::short_name($c_ward->{name}), "$county->{name}, within $c_ward->{name} ward" ];
+ [ 'council', $county->{id}, Page::short_name($county), $county_name ],
+ [ 'ward', $county->{id}.':'.$c_ward->{id}, Page::short_name($county) . '/'
+ . Page::short_name($c_ward), "$county_name, within $c_ward_name ward" ];
$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
@@ -238,17 +294,23 @@ feed, or enter your email address to subscribe to an email alert.'));
<input type="radio" name="feed" id="local:$lat:$lon" value="local:$lat:$lon"$checked>
<label for="local:$lat:$lon">$rss_label</label>
EOF
- my $rss_feed = Cobrand::url($cobrand, "/rss/l/$lat,$lon", $q);
+ my $rss_feed;
+ if ($pretty_pc_text) {
+ $rss_feed = Cobrand::url($cobrand, "/rss/pc/$pretty_pc_text/", $q);
+ } else {
+ $rss_feed = Cobrand::url($cobrand, "/rss/l/$lat,$lon/", $q);
+ }
+
my $default_link = Cobrand::url($cobrand, "/alert?type=local;feed=local:$lat:$lon", $q);
my $rss_details = _('(a default distance which covers roughly 200,000 people)');
$out .= $rss_details;
$out .= " <a href='$rss_feed'><img src='/i/feed.png' width='16' height='16' title='"
. _('RSS feed of nearby problems') . "' alt='" . _('RSS feed') . "' border='0'></a>";
$out .= '</p> <p id="rss_local_alt">' . _('(alternatively the RSS feed can be customised, within');
- my $rss_feed_2k = Cobrand::url($cobrand, "/rss/l/$lat,$lon/2", $q);
- my $rss_feed_5k = Cobrand::url($cobrand, "/rss/l/$lat,$lon/5", $q);
- my $rss_feed_10k = Cobrand::url($cobrand, "/rss/l/$lat,$lon/10", $q);
- my $rss_feed_20k = Cobrand::url($cobrand, "/rss/l/$lat,$lon/20", $q);
+ my $rss_feed_2k = Cobrand::url($cobrand, $rss_feed.'2', $q);
+ my $rss_feed_5k = Cobrand::url($cobrand, $rss_feed.'5', $q);
+ my $rss_feed_10k = Cobrand::url($cobrand, $rss_feed.'10', $q);
+ my $rss_feed_20k = Cobrand::url($cobrand, $rss_feed.'20', $q);
$out .= <<EOF;
<a href="$rss_feed_2k">2km</a> / <a href="$rss_feed_5k">5km</a>
/ <a href="$rss_feed_10k">10km</a> / <a href="$rss_feed_20k">20km</a>)
diff --git a/web/cobrands/fiksgatami/css.css b/web/cobrands/fiksgatami/css.css
new file mode 100644
index 000000000..8029e6698
--- /dev/null
+++ b/web/cobrands/fiksgatami/css.css
@@ -0,0 +1,3 @@
+#front_stats div {
+ width: 6em;
+}
diff --git a/web/contact.cgi b/web/contact.cgi
index fd0043d94..aefd3de7a 100755
--- a/web/contact.cgi
+++ b/web/contact.cgi
@@ -106,6 +106,8 @@ sub contact_details {
my $out = '';
my $sitename = _('FixMyStreet');
my $contact_info = '';
+ if ( mySociety::Config::get('COUNTRY') eq 'GB' ) {
+ # XXX Rewrite to make brandable?
$contact_info .= <<EOF;
<div class="contact-details">
<p>$sitename is a service provided by mySociety, which is the project of a
@@ -120,6 +122,7 @@ UK</p>
</div>
EOF
$out .= $contact_info unless $q->{site} eq 'emptyhomes';
+ }
return $out;
}
@@ -203,10 +206,12 @@ sub contact_page {
} else {
$intro .= $q->p(_('You are reporting the following problem report for being abusive, containing personal information, or similar:'));
$item_title = ent($p->{title});
+ my $date_time = Page::prettify_epoch($q, $p->{confirmed});
$item_meta = $q->em(
- 'Reported ',
- ($p->{anonymous}) ? 'anonymously' : "by " . ent($p->{name}),
- ' at ' . Page::prettify_epoch($q, $p->{confirmed}));
+ $p->{anonymous}
+ ? sprintf(_('Reported anonymously at %s'), $date_time)
+ : sprintf(_('Reported by %s at %s'), ent($p->{name}), $date_time)
+ );
$item_body = ent($p->{detail});
}
}
diff --git a/web/import.cgi b/web/import.cgi
index e7746f589..ac36b2ee5 100755
--- a/web/import.cgi
+++ b/web/import.cgi
@@ -16,7 +16,7 @@ use mySociety::AuthToken;
use mySociety::Config;
use mySociety::EmailUtil;
use mySociety::EvEl;
-use mySociety::GeoUtil;
+use mySociety::Locale;
sub main {
my $q = shift;
@@ -64,10 +64,8 @@ sub main {
if ( $latitude && mySociety::Config::get('COUNTRY') eq 'GB' ) {
try {
- mySociety::GeoUtil::wgs84_to_national_grid( $latitude, $longitude,
- 'G' );
- }
- catch Error::Simple with {
+ Utils::convert_latlon_to_en( $latitude, $longitude );
+ } catch Error::Simple with {
my $e = shift;
push @errors, "We had a problem with the supplied co-ordinates - outside the UK?";
};
diff --git a/web/index.cgi b/web/index.cgi
index af89fc8cf..7e177e0a2 100755
--- a/web/index.cgi
+++ b/web/index.cgi
@@ -9,6 +9,7 @@
use strict;
use Standard;
use Utils;
+use Encode;
use Error qw(:try);
use File::Slurp;
use LWP::Simple;
@@ -24,7 +25,6 @@ use mySociety::AuthToken;
use mySociety::Config;
use mySociety::DBHandle qw(select_all);
use mySociety::EmailUtil;
-use mySociety::GeoUtil;
use mySociety::Locale;
use mySociety::MaPit;
use mySociety::PostcodeUtil;
@@ -81,10 +81,10 @@ sub main {
my %params;
if ($q->param('submit_problem')) {
$params{title} = _('Submitting your report');
- ($out) = submit_problem($q);
+ ($out, %params) = submit_problem($q);
} elsif ($q->param('submit_update')) {
$params{title} = _('Submitting your update');
- ($out) = submit_update($q);
+ ($out, %params) = submit_update($q);
} elsif ($q->param('submit_map')) {
($out, %params) = display_form($q, [], {});
$params{title} = _('Reporting a problem');
@@ -118,6 +118,8 @@ sub front_page {
my $cobrand_form_elements = Cobrand::form_elements($cobrand, 'postcodeForm', $q);
my $form_action = Cobrand::url($cobrand, '/', $q);
my $question = Cobrand::enter_postcode_text($cobrand, $q);
+ $question = _("Enter a nearby GB postcode, or street name and area:")
+ unless $question;
my %params = ('context' => 'front-page');
$params{status_code} = $status_code if $status_code;
my %vars = (
@@ -276,11 +278,12 @@ sub submit_problem {
my @errors;
my %field_errors;
+ my $cobrand = Page::get_cobrand($q);
# If in UK and we have a lat,lon coocdinate check it is in UK
if ( $input{latitude} && mySociety::Config::get('COUNTRY') eq 'GB' ) {
try {
- mySociety::GeoUtil::wgs84_to_national_grid($input{latitude}, $input{longitude}, 'G');
+ Utils::convert_latlon_to_en( $input{latitude}, $input{longitude} );
} catch Error::Simple with {
my $e = shift;
push @errors, "We had a problem with the supplied co-ordinates - outside the UK?";
@@ -307,7 +310,7 @@ sub submit_problem {
} elsif (!mySociety::EmailUtil::is_valid_email($input{email})) {
$field_errors{email} = _('Please enter a valid email');
}
- if ($input{category} && $input{category} eq '-- Pick a category --') {
+ if ($input{category} && $input{category} eq _('-- Pick a category --')) {
$field_errors{category} = _('Please choose a category');
$input{category} = '';
} elsif ($input{category} && $input{category} eq _('-- Pick a property type --')) {
@@ -323,7 +326,8 @@ sub submit_problem {
$areas = mySociety::MaPit::call( 'point', $mapit_query );
if ($input{council} =~ /^[\d,]+(\|[\d,]+)?$/) {
my $no_details = $1 || '';
- my %va = map { $_ => 1 } @$mySociety::VotingArea::council_parent_types;
+ my @area_types = Cobrand::area_types($cobrand);
+ my %va = map { $_ => 1 } @area_types;
my %councils;
foreach (keys %$areas) {
$councils{$_} = 1 if $va{$areas->{$_}->{type}};
@@ -387,7 +391,6 @@ sub submit_problem {
my $used_map = $input{skipped} ? 'f' : 't';
$input{category} = _('Other') unless $input{category};
my ($id, $out);
- my $cobrand = Page::get_cobrand($q);
my $cobrand_data = Cobrand::extra_problem_data($cobrand, $q);
if (my $token = $input{partial}) {
my $id = mySociety::AuthToken::retrieve('partial', $token);
@@ -515,23 +518,29 @@ sub display_form {
}
# Look up councils and do checks for the point we've got
- my $parent_types = $mySociety::VotingArea::council_parent_types;
- $parent_types = [qw(DIS LBO MTD UTA LGD COI)] # No CTY
- if $q->{site} eq 'emptyhomes';
+ my @area_types = Cobrand::area_types($cobrand);
# XXX: I think we want in_gb_locale around the next line, needs testing
- my $all_councils = mySociety::MaPit::call('point', "4326/$longitude,$latitude", type => $parent_types);
+ my $all_councils = mySociety::MaPit::call('point', "4326/$longitude,$latitude", type => \@area_types);
# Let cobrand do a check
my ($success, $error_msg) = Cobrand::council_check($cobrand, { all_councils => $all_councils }, $q, 'submit_problem');
- if (!$success){
+ if (!$success) {
return front_page($q, $error_msg);
}
- # Ipswich & St Edmundsbury are responsible for everything in their areas, not Suffolk
- delete $all_councils->{2241} if $all_councils->{2446} || $all_councils->{2443};
+ if (mySociety::Config::get('COUNTRY') eq 'GB') {
+ # Ipswich & St Edmundsbury are responsible for everything in their areas, not Suffolk
+ delete $all_councils->{2241} if $all_councils->{2446} || $all_councils->{2443};
+
+ # Norwich is responsible for everything in its areas, not Norfolk
+ delete $all_councils->{2233} if $all_councils->{2391};
+
+ } elsif (mySociety::Config::get('COUNTRY') eq 'NO') {
- # Norwich is responsible for everything in its areas, not Norfolk
- delete $all_councils->{2233} if $all_councils->{2391};
+ # Oslo is both a kommune and a fylke, we only want to show it once
+ delete $all_councils->{301} if $all_councils->{3};
+
+ }
return display_location($q, _('That spot does not appear to be covered by a council.
If you have tried to report an issue past the shoreline, for example,
@@ -553,7 +562,7 @@ please specify the closest point on land.')) unless %$all_councils;
@categories = Page::scambs_categories();
}
if (@categories) {
- @categories = ('-- Pick a category --', @categories, _('Other'));
+ @categories = (_('-- Pick a category --'), @categories, _('Other'));
$category = _('Category:');
}
} else {
@@ -648,33 +657,37 @@ name if you give us permission.'), $council_list);
push @missing, $_ unless $councils{$_};
}
my $n = @missing;
- my $list = join(' or ', map { $all_councils->{$_}->{name} } @missing);
- $vars{text_help} = '<p>All the information you provide here will be sent to <strong>'
- . join('</strong> or <strong>', map { $all_councils->{$_}->{name} } @councils)
- . '</strong>. The subject and details of the problem will be public, plus your
-name if you give us permission.';
- $vars{text_help} .= ' We do <strong>not</strong> yet have details for the other council';
- $vars{text_help} .= ($n>1) ? 's that cover' : ' that covers';
- $vars{text_help} .= " this location. You can help us by finding a contact email address for local
-problems for $list and emailing it to us at <a href='mailto:$e'>$e</a>.";
+ my $list = join(_(' or '), map { $all_councils->{$_}->{name} } @missing);
+ $vars{text_help} = '<p>' . _('All the information you provide here will be sent to') . ' <strong>'
+ . join('</strong>' . _(' or ') . '<strong>', map { $all_councils->{$_}->{name} } @councils)
+ . '</strong>. ';
+ $vars{text_help} .= _('The subject and details of the problem will be public, plus your name if you give us permission.');
+ $vars{text_help} .= ' ' . mySociety::Locale::nget(
+ 'We do <strong>not</strong> yet have details for the other council that covers this location.',
+ 'We do <strong>not</strong> yet have details for the other councils that cover this location.',
+ $n
+ );
+ $vars{text_help} .= ' ' . sprintf(_("You can help us by finding a contact email address for local problems for %s and emailing it to us at <a href='mailto:%s'>%s</a>."), $list, $e, $e);
$vars{text_help} .= '<input type="hidden" name="council" value="' . join(',', @councils)
. '|' . join(',', @missing) . '">';
} else {
my $e = Cobrand::contact_email($cobrand);
- my $list = join(' or ', map { $_->{name} } values %$all_councils);
+ my $list = join(_(' or '), map { $_->{name} } values %$all_councils);
my $n = scalar keys %$all_councils;
if ($q->{site} ne 'emptyhomes') {
- $vars{text_help} = '<p>We do not yet have details for the council';
- $vars{text_help} .= ($n>1) ? 's that cover' : ' that covers';
- $vars{text_help} .= " this location. If you submit a problem here the subject and details
-of the problem will be public, but the problem will <strong>not</strong> be reported to the council.
-You can help us by finding a contact email address for local
-problems for $list and emailing it to us at <a href='mailto:$e'>$e</a>.";
+ $vars{text_help} = '<p>';
+ $vars{text_help} .= mySociety::Locale::nget(
+ 'We do not yet have details for the council that covers this location.',
+ 'We do not yet have details for the councils that cover this location.',
+ $n
+ );
+ $vars{text_help} .= _("If you submit a problem here the subject and details of the problem will be public, but the problem will <strong>not</strong> be reported to the council.");
+ $vars{text_help} .= sprintf(_("You can help us by finding a contact email address for local problems for %s and emailing it to us at <a href='mailto:%s'>%s</a>."), $list, $e, $e);
} else {
- $vars{text_help} = _("<p>We do not yet have details for the council that covers
-this location. If you submit a report here it will be left on the site, but
-not reported to the council &ndash; please still leave your report, so that
-we can show to the council the activity in their area.");
+ $vars{text_help} = '<p>'
+ . _('We do not yet have details for the council that covers this location.')
+ . ' '
+ . _("If you submit a report here it will be left on the site, but not reported to the council &ndash; please still leave your report, so that we can show to the council the activity in their area.");
}
$vars{text_help} .= '<input type="hidden" name="council" value="-1">';
}
@@ -754,27 +767,18 @@ EOF
}
if ($q->{site} ne 'emptyhomes') {
- $vars{text_notes} = <<EOF;
-<p>Please note:</p>
-<ul>
-<li>We will only use your personal
-information in accordance with our <a href="/faq#privacy">privacy policy.</a></li>
-<li>Please be polite, concise and to the point.</li>
-<li>Please do not be abusive &mdash; abusing your council devalues the service for all users.</li>
-<li>Writing your message entirely in block capitals makes it hard to read,
-as does a lack of punctuation.</li>
-<li>Remember that FixMyStreet is primarily for reporting physical
-problems that can be fixed. If your problem is not appropriate for
-submission via this site remember that you can contact your council
-directly using their own website.</li>
-<li>
-FixMyStreet and the Guardian are providing this service in
-partnership in <a href="/faq#privacy">certain cities</a>. In those cities, both have access to
-any information submitted, including names and email addresses, and will use it only to ensure the
-smooth running of the service, in accordance with their privacy policies.
-</li>
-</ul>
-EOF
+ $vars{text_notes} =
+ $q->p(_("Please note:")) .
+ "<ul>" .
+ $q->li(_("We will only use your personal information in accordance with our <a href=\"/faq#privacy\">privacy policy.</a>")) .
+ $q->li(_("Please be polite, concise and to the point.")) .
+ $q->li(_("Please do not be abusive &mdash; abusing your council devalues the service for all users.")) .
+ $q->li(_("Writing your message entirely in block capitals makes it hard to read, as does a lack of punctuation.")) .
+ $q->li(_("Remember that FixMyStreet is primarily for reporting physical problems that can be fixed. If your problem is not appropriate for submission via this site remember that you can contact your council directly using their own website."));
+ $vars{text_notes} .=
+ $q->li(_("FixMyStreet and the Guardian are providing this service in partnership in <a href=\"/faq#privacy\">certain cities</a>. In those cities, both have access to any information submitted, including names and email addresses, and will use it only to ensure the smooth running of the service, in accordance with their privacy policies."))
+ if mySociety::Config::get('COUNTRY') eq 'GB';
+ $vars{text_notes} .= "</ul>\n";
}
%vars = (%vars,
@@ -783,7 +787,10 @@ EOF
url_home => Cobrand::url($cobrand, '/', $q),
submit_button => _('Submit')
);
- return (Page::template_include('report-form', $q, Page::template_root($q), %vars), robots => 'noindex,nofollow');
+ return (Page::template_include('report-form', $q, Page::template_root($q), %vars),
+ robots => 'noindex,nofollow',
+ js => FixMyStreet::Map::header_js(),
+ );
}
# redirect from osgb
@@ -883,7 +890,7 @@ sub display_location {
my ($on_map_all, $on_map, $around_map, $dist) = FixMyStreet::Map::map_features($q, $latitude, $longitude, $interval);
my @pins;
foreach (@$on_map_all) {
- push @pins, [ $_->{latitude}, $_->{longitude}, $_->{state} eq 'fixed' ? 'green' : 'red' ];
+ push @pins, [ $_->{latitude}, $_->{longitude}, ($_->{state} eq 'fixed' ? 'green' : 'red'), $_->{id} ];
}
my $on_list = '';
foreach (@$on_map) {
@@ -902,14 +909,14 @@ sub display_location {
foreach (@$around_map) {
my $report_url = Cobrand::url($cobrand, NewURL($q, -retain => 1, -url => '/report/' . $_->{id}, pc => undef, x => undef, 'y' => undef), $q);
$around_list .= '<li><a href="' . $report_url . '">';
- my $dist = int($_->{distance}/100+0.5);
+ my $dist = int($_->{distance}*10+0.5);
$dist = $dist / 10;
$around_list .= ent($_->{title}) . '</a> <small>(';
$around_list .= Page::prettify_epoch($q, $_->{time}, 1) . ', ';
$around_list .= $dist . 'km)</small>';
$around_list .= ' <small>' . _('(fixed)') . '</small>' if $_->{state} eq 'fixed';
$around_list .= '</li>';
- push @pins, [ $_->{latitude}, $_->{longitude}, $_->{state} eq 'fixed' ? 'green' : 'red' ];
+ push @pins, [ $_->{latitude}, $_->{longitude}, ($_->{state} eq 'fixed' ? 'green' : 'red'), $_->{id} ];
}
$around_list = $q->li(_('No problems found.'))
unless $around_list;
@@ -936,6 +943,17 @@ sub display_location {
);
my $pc_h = ent($q->param('pc') || '');
+ my $rss_url;
+ if ($pc_h) {
+ $rss_url = "/rss/pc/" . URI::Escape::uri_escape($pc_h);
+ } else {
+ $rss_url = "/rss/l/$short_lat,$short_lon";
+ }
+ $rss_url = Cobrand::url( $cobrand,
+ NewURL($q, -retain => 1, -url=> $rss_url,
+ pc => undef, x => undef, y => undef, lat=> undef, lon => undef ),
+ $q);
+
my %vars = (
'map' => FixMyStreet::Map::display_map($q,
latitude => $latitude, longitude => $longitude,
@@ -945,7 +963,7 @@ sub display_location {
),
map_end => FixMyStreet::Map::display_map_end(1),
url_home => Cobrand::url($cobrand, '/', $q),
- url_rss => Cobrand::url($cobrand, NewURL($q, -retain => 1, -url=> "/rss/l/$short_lat,$short_lon", pc => undef, x => undef, y => undef, lat => undef, lon => undef ), $q),
+ url_rss => $rss_url,
url_email => Cobrand::url($cobrand, NewURL($q, -retain => 1, pc => undef, lat => $short_lat, lon => $short_lon, -url=>'/alert', feed=>"local:$short_lat:$short_lon"), $q),
url_skip => $url_skip,
email_me => _('Email me new local problems'),
@@ -966,7 +984,8 @@ sub display_location {
);
my %params = (
- rss => [ _('Recent local problems, FixMyStreet'), "/rss/l/$short_lat,$short_lon" ],
+ rss => [ _('Recent local problems, FixMyStreet'), $rss_url ],
+ js => FixMyStreet::Map::header_js(),
robots => 'noindex,nofollow',
);
@@ -1013,11 +1032,12 @@ sub display_problem {
map { Utils::truncate_coordinate($_) } #
( $problem->{latitude}, $problem->{longitude} );
- my $map_links =
- "<p id='sub_map_links'>"
+ my $map_links = '';
+ $map_links = "<p id='sub_map_links'>"
. "<a href=\"http://maps.google.co.uk/maps?output=embed&amp;z=16&amp;q="
. URI::Escape::uri_escape_utf8( $problem->{title} . ' - ' . $google_link )
- . "\@$short_lat,$short_lon\">View on Google Maps</a></p>";
+ . "\@$short_lat,$short_lon\">View on Google Maps</a></p>"
+ if mySociety::Config::get('COUNTRY') eq 'GB';
my $banner;
if ($q->{site} ne 'emptyhomes' && $problem->{state} eq 'confirmed' && $problem->{duration} > 8*7*24*60*60) {
@@ -1073,6 +1093,7 @@ sub display_problem {
cobrand_form_elements => Cobrand::form_elements($cobrand, 'updateForm', $q),
form_action => Cobrand::url($cobrand, '/', $q),
input_h => \%input_h,
+ optional => _('(optional)'),
);
$vars{update_blurb} = $q->p($q->small(_('Please note that updates are not sent to the council. If you leave your name it will be public. Your information will only be used in accordance with our <a href="/faq#privacy">privacy policy</a>')))
@@ -1097,6 +1118,7 @@ EOF
my %params = (
rss => [ _('Updates to this problem, FixMyStreet'), "/rss/$input_h{id}" ],
robots => 'index, nofollow',
+ js => FixMyStreet::Map::header_js(),
title => $problem->{title}
);
diff --git a/web/js/map-OpenStreetMap.js b/web/js/map-OpenStreetMap.js
index 04237e075..c5aa318b0 100644
--- a/web/js/map-OpenStreetMap.js
+++ b/web/js/map-OpenStreetMap.js
@@ -1,5 +1,5 @@
YAHOO.util.Event.onContentReady('map', function() {
- var map = new OpenLayers.Map("map", {
+ fixmystreet.map = new OpenLayers.Map("map", {
controls: [
new OpenLayers.Control.ArgParser(),
//new OpenLayers.Control.LayerSwitcher(),
@@ -8,20 +8,82 @@ YAHOO.util.Event.onContentReady('map', function() {
],
displayProjection: new OpenLayers.Projection("EPSG:4326")
});
- var streetview = new fixmystreet.map_type("", {
+ var osm = new fixmystreet.map_type("", {
zoomOffset: 14,
numZoomLevels: 4
});
- map.addLayer(streetview);
+ fixmystreet.map.addLayer(osm);
- var centre = new OpenLayers.LonLat( fixmystreet.easting, fixmystreet.northing );
+ var centre = new OpenLayers.LonLat( fixmystreet.longitude, fixmystreet.latitude );
centre.transform(
- new OpenLayers.Projection("EPSG:27700"),
- map.getProjectionObject()
+ new OpenLayers.Projection("EPSG:4326"),
+ fixmystreet.map.getProjectionObject()
);
- map.setCenter(centre, 2);
+ fixmystreet.map.setCenter(centre, 2);
+
+ if (document.getElementById('mapForm')) {
+ var click = new OpenLayers.Control.Click();
+ fixmystreet.map.addControl(click);
+ click.activate();
+ }
+
+ var markers = new OpenLayers.Layer.Markers("Markers");
+ var cols = { 'red':'R', 'green':'G', 'blue':'B', 'purple':'P' };
+ for (var i=0; i<fixmystreet.pins.length; i++) {
+ var pin = fixmystreet.pins[i];
+ var src = '/i/pin' + cols[pin[2]] + '.gif';
+ var size = new OpenLayers.Size(32, 59);
+ var offset = new OpenLayers.Pixel(-3, -size.h-2);
+ var icon = new OpenLayers.Icon(src, size, offset);
+ var loc = new OpenLayers.LonLat(pin[1], pin[0]);
+ loc.transform(
+ new OpenLayers.Projection("EPSG:4326"),
+ fixmystreet.map.getProjectionObject()
+ );
+ var marker = new OpenLayers.Marker(loc, icon);
+ if (pin[3]) {
+ marker.events.register('click', marker, function(evt) { window.location = '/report/' + pin[3]; OpenLayers.Event.stop(evt); });
+ }
+ markers.addMarker(marker);
+ }
+ fixmystreet.map.addLayer(markers);
+
});
+OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
+ defaultHandlerOptions: {
+ 'single': true,
+ 'double': false,
+ 'pixelTolerance': 0,
+ 'stopSingle': false,
+ 'stopDouble': false
+ },
+
+ initialize: function(options) {
+ this.handlerOptions = OpenLayers.Util.extend(
+ {}, this.defaultHandlerOptions
+ );
+ OpenLayers.Control.prototype.initialize.apply(
+ this, arguments
+ );
+ this.handler = new OpenLayers.Handler.Click(
+ this, {
+ 'click': this.trigger
+ }, this.handlerOptions
+ );
+ },
+
+ trigger: function(e) {
+ var lonlat = fixmystreet.map.getLonLatFromViewPortPx(e.xy);
+ lonlat.transform(
+ fixmystreet.map.getProjectionObject(),
+ new OpenLayers.Projection("EPSG:4326")
+ );
+ document.getElementById('fixmystreet.latitude').value = lonlat.lat;
+ document.getElementById('fixmystreet.longitude').value = lonlat.lon;
+ document.getElementById('mapForm').submit();
+ }
+});
// http://www.openstreetmap.org/openlayers/OpenStreetMap.js (added maxResolution)
diff --git a/web/photo.cgi b/web/photo.cgi
index fc89fc0f7..bd38e3bf1 100755
--- a/web/photo.cgi
+++ b/web/photo.cgi
@@ -39,7 +39,7 @@ sub main {
print $photo;
}
-Page::do_fastcgi(\&main);
+Page::do_fastcgi(\&main, 0, 1);
sub resize {
my ($photo, $size) = @_;
diff --git a/web/questionnaire.cgi b/web/questionnaire.cgi
index cb5e553d3..1eb62d03e 100755
--- a/web/questionnaire.cgi
+++ b/web/questionnaire.cgi
@@ -25,7 +25,10 @@ sub main {
} else {
$out = display_questionnaire($q);
}
- print Page::header($q, title=>_('Questionnaire'));
+ print Page::header($q,
+ title => _('Questionnaire'),
+ js => FixMyStreet::Map::header_js(),
+ );
print $out;
print Page::footer($q);
}
diff --git a/web/reports.cgi b/web/reports.cgi
index 999e82bb3..f0ecf9c7a 100755
--- a/web/reports.cgi
+++ b/web/reports.cgi
@@ -11,6 +11,7 @@
use strict;
use Standard;
+use Encode;
use URI::Escape;
use FixMyStreet::Alert;
use mySociety::MaPit;
@@ -40,24 +41,50 @@ sub main {
print $q->redirect($base_url . '/reports');
return;
}
- $area_name = Page::short_name($va_info->{name});
+ $area_name = Page::short_name($va_info);
if (length($q_council) == 6) {
$va_info = mySociety::MaPit::call('area', $va_info->{parent_area});
- $area_name = Page::short_name($va_info->{name}) . '/' . $area_name;
+ $area_name = Page::short_name($va_info) . '/' . $area_name;
}
$rss = '/rss' if $rss;
print $q->redirect($base_url . $rss . '/reports/' . $area_name);
return;
+ } elsif (mySociety::Config::get('COUNTRY') eq 'NO' && $q_council eq 'Oslo') {
+ $one_council = mySociety::MaPit::call('area', 3);
+ $area_type = $one_council->{type};
+ $area_name = $one_council->{name};
+ } elsif (mySociety::Config::get('COUNTRY') eq 'NO' && $q_council =~ /,/) {
+ my ($kommune, $fylke) = split /\s*,\s*/, $q_council;
+ my @area_types = Cobrand::area_types($cobrand);
+ my $areas_k = mySociety::MaPit::call('areas', $kommune, type => \@area_types);
+ my $areas_f = mySociety::MaPit::call('areas', $fylke, type => \@area_types);
+ if (keys %$areas_f == 1) {
+ ($fylke) = values %$areas_f;
+ $kommune = decode_utf8($kommune);
+ foreach (values %$areas_k) {
+ if ($_->{name} eq $kommune && $_->{parent_area} == $fylke->{id}) {
+ $one_council = $_;
+ $area_type = $_->{type};
+ $area_name = $_->{name};
+ last;
+ }
+ }
+ }
+ if (!$one_council) { # Given a false council name
+ print $q->redirect($base_url . '/reports');
+ return;
+ }
} elsif ($q_council =~ /\D/) {
- my $areas = mySociety::MaPit::call('areas', $q_council, type => $mySociety::VotingArea::council_parent_types, min_generation=>10 );
+ my @area_types = Cobrand::area_types($cobrand);
+ my $areas = mySociety::MaPit::call('areas', $q_council, type => \@area_types, min_generation=>Cobrand::area_min_generation($cobrand) );
if (keys %$areas == 1) {
- ($one_council) = keys %$areas;
- $area_type = $areas->{$one_council}->{type};
- $area_name = $areas->{$one_council}->{name};
+ ($one_council) = values %$areas;
+ $area_type = $one_council->{type};
+ $area_name = $one_council->{name};
} else {
foreach (keys %$areas) {
if ($areas->{$_}->{name} =~ /^\Q$q_council\E (Borough|City|District|County) Council$/) {
- $one_council = $_;
+ $one_council = $areas->{$_};
$area_type = $areas->{$_}->{type};
$area_name = $q_council;
}
@@ -73,8 +100,7 @@ sub main {
print $q->redirect($base_url . '/reports');
return;
}
- $area_name = $va_info->{name};
- print $q->redirect($base_url . '/reports/' . Page::short_name($area_name));
+ print $q->redirect($base_url . '/reports/' . Page::short_name($va_info));
return;
}
$all = 0 unless $one_council;
@@ -83,23 +109,24 @@ sub main {
my $q_ward = $q->param('ward') || '';
my $ward;
if ($one_council && $q_ward) {
- my $qw = mySociety::MaPit::call('areas', $q_ward, type => $mySociety::VotingArea::council_child_types, min_generation => 10);
+ my $qw = mySociety::MaPit::call('areas', $q_ward, type => $mySociety::VotingArea::council_child_types,
+ min_generation => Cobrand::area_min_generation($cobrand));
foreach my $id (sort keys %$qw) {
- if ($qw->{$id}->{parent_area} == $one_council) {
- $ward = $id;
+ if ($qw->{$id}->{parent_area} == $one_council->{id}) {
+ $ward = $qw->{$id};
last;
}
}
if (!$ward) { # Given a false ward name
- print $q->redirect($base_url . '/reports/' . Page::short_name($q_council));
+ print $q->redirect($base_url . '/reports/' . Page::short_name($one_council));
return;
}
}
# RSS - reports for sent reports, area for all problems in area
if ($rss && $one_council) {
- my $url = Page::short_name($q_council);
- $url .= '/' . Page::short_name($q_ward) if $ward;
+ my $url = Page::short_name($one_council);
+ $url .= '/' . Page::short_name($ward) if $ward;
if ($rss eq 'area' && $area_type ne 'DIS' && $area_type ne 'CTY') {
# Two possibilites are the same for one-tier councils, so redirect one to the other
print $q->redirect($base_url . '/rss/reports/' . $url);
@@ -108,8 +135,8 @@ sub main {
my $type = 'council_problems'; # Problems sent to a council
my (@params, %title_params);
$title_params{COUNCIL} = $area_name;
- push @params, $one_council if $rss eq 'reports';
- push @params, $ward ? $ward : $one_council;
+ push @params, $one_council->{id} if $rss eq 'reports';
+ push @params, $ward ? $ward->{id} : $one_council->{id};
if ($ward && $rss eq 'reports') {
$type = 'ward_problems'; # Problems sent to a council, restricted to a ward
$title_params{WARD} = $q_ward;
@@ -127,16 +154,20 @@ sub main {
my $areas_info;
if ($one_council) {
- $areas_info = mySociety::MaPit::call('areas', $one_council);
+ $areas_info = mySociety::MaPit::call('areas', [ $one_council->{id}, $one_council->{parent_area} ])
+ if $one_council->{parent_area};
+ $areas_info = { $one_council->{id} => $one_council }
+ unless $areas_info;
} else {
# Show all councils on main report page
- my $ignore = 'LGD';
- $ignore .= '|CTY' if $q->{site} eq 'emptyhomes';
- my @types = grep { !/$ignore/ } @$mySociety::VotingArea::council_parent_types;
- $areas_info = mySociety::MaPit::call('areas', [ @types ], min_generation=>10 );
+ my @area_types = Cobrand::area_types($cobrand);
+ $areas_info = mySociety::MaPit::call('areas', \@area_types, min_generation=>Cobrand::area_min_generation($cobrand) );
}
- my $problems = Problems::council_problems($ward, $one_council);
+ my $problems = Problems::council_problems(
+ $ward ? $ward->{id} : undef,
+ $one_council ? $one_council->{id} : undef
+ );
my (%fixed, %open);
my $re_councils = join('|', keys %$areas_info);
@@ -151,7 +182,7 @@ sub main {
$row->{council} =~ s/\|.*$//;
my @council = split /,/, $row->{council};
foreach (@council) {
- next if $one_council && $_ != $one_council;
+ next if $one_council && $_ != $one_council->{id};
add_row($row, scalar @council, $_, \%fixed, \%open);
}
}
@@ -171,17 +202,22 @@ sub main {
}
print '<th>' . _('Recently fixed') . '</th><th>' . _('Older fixed') . '</th></tr>';
foreach (sort { $areas_info->{$a}->{name} cmp $areas_info->{$b}->{name} } keys %$areas_info) {
+ next if mySociety::Config::get('COUNTRY') eq 'NO' && $_ eq 301; # Only want one Oslo
print '<tr align="center"';
++$c;
- if ($areas_info->{$_}->{generation_high}==10) {
+ if (mySociety::Config::get('COUNTRY') eq 'GB' && $areas_info->{$_}->{generation_high} == 10) {
print ' class="gone"';
} elsif ($c%2) {
print ' class="a"';
}
- my $url = Page::short_name($areas_info->{$_}->{name});
+ my $url = Page::short_name($areas_info->{$_}, $areas_info);
my $cobrand_url = Cobrand::url($cobrand, "/reports/$url", $q);
print '><td align="left"><a href="' . $cobrand_url . '">' .
- $areas_info->{$_}->{name} . '</a></td>';
+ $areas_info->{$_}->{name};
+ if ($areas_info->{$_}->{parent_area} && $url =~ /,|%2C/) {
+ print ', ' . $areas_info->{$areas_info->{$_}->{parent_area}}->{name};
+ }
+ print '</a></td>';
summary_cell(\@{$open{$_}{new}});
if ($q->{site} eq 'emptyhomes') {
my $c = 0;
@@ -198,17 +234,17 @@ sub main {
}
print '</table>';
} else {
- my $name = $areas_info->{$one_council}->{name};
+ my $name = $one_council->{name};
if (!$name) {
print Page::header($q, title=>_("Summary reports"));
- print "Council with identifier " . ent($one_council). " not found. ";
+ print "Council with identifier " . ent($one_council->{id}). " not found. ";
print $q->a({href => Cobrand::url($cobrand, '/reports', $q) }, 'Show all councils');
print ".";
} else {
- my $rss_url = '/rss/reports/' . Page::short_name($name);
+ my $rss_url = '/rss/reports/' . Page::short_name($one_council, $areas_info);
my $thing = _('council');
if ($ward) {
- $rss_url .= '/' . Page::short_name($q_ward);
+ $rss_url .= '/' . Page::short_name($ward);
$thing = 'ward';
$name = ent($q_ward) . ", $name";
}
@@ -234,24 +270,25 @@ sub main {
$vars{summary_line} = sprintf(_('You can <a href="%s">see more details</a> or go back and <a href="/reports">show all councils</a>.'), Cobrand::url($cobrand, NewURL($q, all=>1), $q));
}
- if ($open{$one_council}) {
- my $col = list_problems($q, _('New problems'), $open{$one_council}{new}, $all, 0);
+ my $id = $one_council->{id};
+ if ($open{$id}) {
+ my $col = list_problems($q, _('New problems'), $open{$id}{new}, $all, 0);
my $old = [];
if ($q->{site} eq 'emptyhomes') {
- push @$old, @{$open{$one_council}{older}} if $open{$one_council}{older};
- push @$old, @{$open{$one_council}{unknown}} if $open{$one_council}{unknown};
+ push @$old, @{$open{$id}{older}} if $open{$id}{older};
+ push @$old, @{$open{$id}{unknown}} if $open{$id}{unknown};
} else {
- $old = $open{$one_council}{older};
+ $old = $open{$id}{older};
}
$col .= list_problems($q, _('Older problems'), $old, $all, 0);
if ($q->{site} ne 'emptyhomes') {
- $col .= list_problems($q, _('Old problems, state unknown'), $open{$one_council}{unknown}, $all, 0);
+ $col .= list_problems($q, _('Old problems, state unknown'), $open{$id}{unknown}, $all, 0);
}
$vars{col_problems} = $col;
}
- if ($fixed{$one_council}) {
- my $col = list_problems($q, _('Recently fixed'), $fixed{$one_council}{new}, $all, 1);
- $col .= list_problems($q, _('Old fixed'), $fixed{$one_council}{old}, $all, 1);
+ if ($fixed{$id}) {
+ my $col = list_problems($q, _('Recently fixed'), $fixed{$id}{new}, $all, 1);
+ $col .= list_problems($q, _('Old fixed'), $fixed{$id}{old}, $all, 1);
$vars{col_fixed} = $col;
}
print Page::header($q, context => 'reports', title=>sprintf(_('%s - Summary reports'), $name), rss => [ sprintf(_('Problems within %s, FixMyStreet'), $name), Cobrand::url($cobrand, $rss_url, $q) ]);
@@ -294,7 +331,7 @@ sub list_problems {
$out .= ent($_->{title});
$out .= '</a>';
$out .= ' <small>(sent to both)</small>' if $_->{councils}>1;
- $out .= ' <small>(not sent to council)</small>' if $_->{councils}==0 && $q->{site} ne 'emptyhomes';
+ $out .= ' <small>' . _('(not sent to council)') . '</small>' if $_->{councils}==0 && $q->{site} ne 'emptyhomes';
$out .= '<br><small>' . ent($_->{detail}) . '</small>' if $all;
$out .= '</li>';
}
diff --git a/web/rss.cgi b/web/rss.cgi
index cb5221537..1ca2a1fe2 100755
--- a/web/rss.cgi
+++ b/web/rss.cgi
@@ -11,11 +11,11 @@
use strict;
use Error qw(:try);
use Standard;
+use Encode;
use URI::Escape;
use FixMyStreet::Alert;
use FixMyStreet::Geocode;
use mySociety::MaPit;
-use mySociety::GeoUtil;
use mySociety::Gaze;
use Utils;
@@ -63,6 +63,7 @@ Page::do_fastcgi(\&main);
sub rss_local_problems {
my $q = shift;
my $pc = $q->param('pc');
+
my $x = $q->param('x');
my $y = $q->param('y');
my $lat = $q->param('lat');
@@ -82,6 +83,10 @@ sub rss_local_problems {
$state = 'confirmed' if $state eq 'open';
+ my $qs;
+ my %title_params;
+ my $alert_type;
+
my $cobrand = Page::get_cobrand($q);
my $base = Cobrand::base_url($cobrand);
if ($x && $y) {
@@ -102,11 +107,22 @@ sub rss_local_problems {
} catch Error::Simple with {
$error = shift;
};
- unless ($error) {
+ if ($error) {
+ return '';
+ } else {
( $lat, $lon ) = map { Utils::truncate_coordinate($_) } ( $lat, $lon );
- print $q->redirect(-location => "$base/rss/l/$lat,$lon$d_str$state_qs");
+
+ my $pretty_pc = $pc;
+ if (mySociety::PostcodeUtil::is_valid_postcode($pc)) {
+ $pretty_pc = mySociety::PostcodeUtil::canonicalise_postcode($pc);
+ }
+ my $pretty_pc_escaped = URI::Escape::uri_escape_utf8($pretty_pc);
+ $pretty_pc_escaped =~ s/%20/+/g;
+ $qs = "?pc=$pretty_pc_escaped";
+
+ $title_params{'POSTCODE'} = $pretty_pc;
}
- return '';
+ # pass through rather than redirecting.
} elsif ( $lat || $lon ) {
# pass through
} else {
@@ -116,7 +132,9 @@ sub rss_local_problems {
# truncate the lat,lon for nicer urls
( $lat, $lon ) = map { Utils::truncate_coordinate($_) } ( $lat, $lon );
- my $qs = "?lat=$lat;lon/=$lon";
+ if (!$qs) {
+ $qs = "?lat=$lat;lon=$lon";
+ }
if ($d) {
$qs .= ";d=$d";
@@ -127,10 +145,20 @@ sub rss_local_problems {
}
my $xsl = Cobrand::feed_xsl($cobrand);
- if ($state eq 'all') {
- return FixMyStreet::Alert::generate_rss('local_problems', $xsl, $qs, [$lat, $lon, $d], undef, $cobrand, $q);
+
+ if ($pc) {
+ $alert_type = 'postcode_local_problems';
} else {
- return FixMyStreet::Alert::generate_rss('local_problems_state', $xsl, $qs, [$lat, $lon, $d, $state], undef, $cobrand, $q);
+ $alert_type = 'local_problems';
}
+
+ my @db_params = ($lat, $lon, $d);
+
+ if ($state ne 'all') {
+ $alert_type .= '_state';
+ push @db_params, $state;
+ }
+
+ return FixMyStreet::Alert::generate_rss($alert_type, $xsl, $qs, \@db_params, \%title_params, $cobrand, $q);
}