diff options
-rwxr-xr-x | bin/gettext-extract | 53 | ||||
-rwxr-xr-x | bin/make_emptyhomes_po | 79 | ||||
-rw-r--r-- | conf/crontab.ugly | 4 | ||||
-rw-r--r-- | perllib/Page.pm | 57 | ||||
-rw-r--r-- | templates/website/emptyhomes-header | 5 | ||||
-rw-r--r-- | web/css/core.css | 9 | ||||
-rw-r--r-- | web/css/emptyhomes.css (renamed from web/css/main-emptyhomes.css) | 18 | ||||
-rw-r--r-- | web/css/ie6.css | 4 | ||||
-rw-r--r-- | web/css/main-scambs.css | 8 | ||||
-rwxr-xr-x | web/index.cgi | 281 | ||||
-rw-r--r-- | web/js.js | 4 | ||||
-rw-r--r-- | web/mojwatermark5.png | bin | 0 -> 11431 bytes | |||
-rwxr-xr-x | web/questionnaire.cgi | 9 | ||||
-rwxr-xr-x | web/reports.cgi | 43 |
14 files changed, 396 insertions, 178 deletions
diff --git a/bin/gettext-extract b/bin/gettext-extract new file mode 100755 index 000000000..70ed66a4f --- /dev/null +++ b/bin/gettext-extract @@ -0,0 +1,53 @@ +#!/bin/bash +# +# bci/bin/gettext-extract +# Generate English language .po files from the source code and email templates, +# for FixMyStreet. Writes the output to appropriate .po files in locale/. +# +# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. +# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ +# +# $Id: gettext-extract,v 1.1 2008-05-06 10:01:23 matthew Exp $ + +if [ -e ../../locale ] +then + cd ../../ +else if [ -e ../locale ] +then + cd ../ +else if [ -e locale ] +then + cd . +else + echo "Please run with current directory bci/bin" + exit 1 +fi +fi +fi + + +# File to write to, clear it to start with +PO=locale/FixMyStreet.po +rm -f $PO + +# Extract from Perl +xgettext --add-comments=TRANS --language=Perl --keyword=_ --from-code=utf-8 -o $PO perllib/mySociety/*.pm bci/perllib/*.pm bci/web/*.cgi bci/bin/send-reports + +# Fix headers +TEMP=`tempfile` +cat $PO | sed " + s/SOME DESCRIPTIVE TITLE/FixMyStreet original .po file, autogenerated by gettext-extract/; + s/YEAR THE PACKAGE'S COPYRIGHT HOLDER/2008 UK Citizens Online Democracy/; + s/PACKAGE package/main FixMyStreet code/; + s/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR./Matthew Somerville <matthew@mysociety.org>, 2008-04-15./; + + s/PACKAGE VERSION/1.0/; + s/Report-Msgid-Bugs-To: /Report-Msgid-Bugs-To: matthew@mysociety.org/; + s/LL@li.org/team@fixmystreet.com/; + s/charset=CHARSET/charset=UTF-8/; +" >> $TEMP +mv $TEMP $PO + +# XXX: Email templates - should be in >1 language... +# And the XSL page too. + diff --git a/bin/make_emptyhomes_po b/bin/make_emptyhomes_po new file mode 100755 index 000000000..69e8c625b --- /dev/null +++ b/bin/make_emptyhomes_po @@ -0,0 +1,79 @@ +#!/usr/bin/perl -w +use strict; + +# Generates EmptyHomes version of .po file, which is a translation +# into a language the same as English, only "problem" becomes "empty property". + +use POSIX; +use FindBin; + +chdir("$FindBin::Bin/../../locale"); +mkdir("en_GB.UTF-8"); +mkdir("en_GB.UTF-8/LC_MESSAGES"); + +open(MAINPO, "FixMyStreet.po") or die ""; +open(NEWPO, ">en_GB.UTF-8/LC_MESSAGES/FixMyStreet-EmptyHomes.po") or die ""; + +print NEWPO "# AUTOMATICALLY GENERATED by make_emptyhomes_po, do not edit\n"; +print NEWPO "\n"; + +my $buffer = ""; +my $start = 0; +while(<MAINPO>) { + if (!$start) { + s/#, fuzzy//; + } + if (m/"Last-Translator: FULL NAME/) { + $_ = '"Last-Translator: mysociety/bin/make_emptyhomes_po\\n"'."\n"; + } + if (m/"PO-Revision-Date: YEAR-MO-DA/) { + my $time = POSIX::strftime("%Y-%m-%d %H:%M%z", localtime(time())); + $_ = '"PO-Revision-Date: '.$time.'\\n"'."\n"; + } + if (m/"Language-Team: LANGUAGE/) { + $_ = '"Language-Team: Live Simply Promise\\n"'."\n"; + } + if (m/"Plural-Forms: nplurals=/) { + $_ = '"Plural-Forms: nplurals=2; plural=n != 1;\\n"'."\n"; + } + + if (m/^#/) { + # comment or blank line + print NEWPO $_; + } elsif (m/^\s+$/) { + # blank line + $start = 1; + $buffer = ""; + print NEWPO $_; + } elsif ($start && (m/^msgstr ""/ || m/^msgstr\[0\] ""/)) { + # start of translated text - translate English into Live Simple Promise + # langauage + if (m/^msgstr\[0\] ""/) { + $buffer =~ s/^msgid "/msgstr[0] "/m; + $buffer =~ s/^msgid_plural "/msgstr[1] "/m; + <MAINPO>; # skip untranslated plural + } else { + $buffer =~ s/^msgid "/msgstr "/; + } + + # Basics + $buffer =~ s/FixMyStreet/Empty Homes Agency/g; + $buffer =~ s/\bproblem\b/empty property/g; + $buffer =~ s/\bProblem\b/Empty property/g; + $buffer =~ s/\bproblems\b/empty properties/g; + $buffer =~ s/\bProblems\b/Empty properties/g; + $buffer =~ s/a empty/an empty/g; + + $buffer =~ s/^\(like graffiti.*/ /; + + print NEWPO $buffer; + $buffer = ""; + } else { + # English text + print NEWPO $_; + $buffer .= $_; + } + + +} + diff --git a/conf/crontab.ugly b/conf/crontab.ugly index 3eba692dd..b4d3191bf 100644 --- a/conf/crontab.ugly +++ b/conf/crontab.ugly @@ -4,10 +4,10 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org/ # -# $Id: crontab.ugly,v 1.12 2008-04-11 11:21:31 francis Exp $ +# $Id: crontab.ugly,v 1.13 2008-05-06 10:01:25 matthew Exp $ PATH=/usr/local/bin:/usr/bin:/bin -!!(* if ($vhost eq "matthew.bci.mysociety.org") { *)!! +!!(* if ($vhost eq "matthew.fixmystreet.com") { *)!! MAILTO=matthew@mysociety.org !!(* } else {*)!! MAILTO=team@fixmystreet.com diff --git a/perllib/Page.pm b/perllib/Page.pm index c6868f508..a3afa5888 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.91 2008-04-15 13:54:53 matthew Exp $ +# $Id: Page.pm,v 1.92 2008-05-06 10:01:30 matthew Exp $ # package Page; @@ -24,6 +24,7 @@ use URI::Escape; use mySociety::Config; use mySociety::DBHandle qw/dbh select_all/; use mySociety::EvEl; +use mySociety::Locale; use mySociety::MaPit; use mySociety::PostcodeUtil; use mySociety::Tracking; @@ -75,6 +76,16 @@ sub microsite { $q->{site} = 'fixmystreet'; $q->{site} = 'scambs' if $host =~ /scambs/; $q->{site} = 'emptyhomes' if $host =~ /emptyhomes/; + + if ($q->{site} eq 'emptyhomes') { + $q->{thing} = 'empty property'; + mySociety::Locale::negotiate_language('en-gb,English,en_GB', 'en-gb'); + mySociety::Locale::gettext_domain('FixMyStreet-EmptyHomes'); + mySociety::Locale::change(); + } else { + $q->{thing} = 'problem'; + mySociety::Locale::gettext_domain('FixMyStreet'); + } } =item header Q [PARAM VALUE ...] @@ -124,6 +135,10 @@ sub header ($%) { <script type="text/javascript" src="/js.js"></script> <title>${title}FixMyStreet</title> <style type="text/css">\@import url("/css/core.css"); \@import url("/css/main.css");</style> +<!--[if LT IE 7]> +<style type="text/css">\@import url("/css/ie6.css");</style> +<![endif]--> + <!-- RSS --> </head> <body> @@ -215,8 +230,12 @@ sub display_map { $params{pins} ||= ''; $params{pre} ||= ''; $params{post} ||= ''; - my $px = defined($params{px}) ? 254-$params{px} : 0; - my $py = defined($params{py}) ? 254-$params{py} : 0; + my $mid_point = 254; + if ($q->{site} eq 'emptyhomes' || $q->{site} eq 'scambs') { # Map is c. 380px wide + $mid_point = 189; + } + my $px = defined($params{px}) ? $mid_point - $params{px} : 0; + my $py = defined($params{py}) ? $mid_point - $params{py} : 0; my $x = int($params{x})<=0 ? 0 : $params{x}; my $y = int($params{y})<=0 ? 0 : $params{y}; my $url = mySociety::Config::get('TILES_URL'); @@ -266,6 +285,7 @@ $params{pre} $params{pins} </div> EOF + $out .= '<div id="watermark"></div>'; $out .= compass($q, $x, $y); $out .= <<EOF; </div> @@ -290,7 +310,7 @@ sub display_pin { $num = '' unless $num; my %cols = (red=>'R', green=>'G', blue=>'B', purple=>'P'); my $out = '<img class="pin" src="/i/pin' . $cols{$col} - . $num . '.gif" alt="Problem" style="top:' . ($py-59) + . $num . '.gif" alt="' . _('Problem') . '" style="top:' . ($py-59) . 'px; left:' . ($px) . 'px; position: absolute;">'; return $out unless $_ && $_->{id} && $col ne 'blue'; my $url = NewURL($q, id=>$_->{id}, x=>undef, y=>undef); @@ -362,6 +382,28 @@ sub click_to_tile { return $pin_tile + $pin / 254; } +sub os_to_px_with_adjust { + my ($q, $easting, $northing, $in_x, $in_y) = @_; + + my $x = Page::os_to_tile($easting); + my $y = Page::os_to_tile($northing); + my $x_tile = $in_x || int($x); + my $y_tile = $in_y || int($y); + my $px = Page::os_to_px($easting, $x_tile); + my $py = Page::os_to_px($northing, $y_tile, 1); + if ($q->{site} eq 'emptyhomes' || $q->{site} eq 'scambs') { # Map is 380px + if ($py > 380) { + $y_tile--; + $py = Page::os_to_px($northing, $y_tile, 1); + } + if ($px > 380) { + $x_tile--; + $px = Page::os_to_px($easting, $x_tile); + } + } + return ($x, $y, $x_tile, $y_tile, $px, $py); +} + # send_email TO (NAME) TEMPLATE-NAME PARAMETERS sub send_email { my ($email, $name, $thing, %h) = @_; @@ -373,7 +415,7 @@ sub send_email { mySociety::EvEl::send({ _template_ => $template, _parameters_ => \%h, - From => [ $sender, 'FixMyStreet'], + From => [ $sender, _('FixMyStreet')], To => $to, }, $email); my $out; @@ -435,11 +477,6 @@ sub _part { } } -# Simply so I can gettext the code without making the locale stuff all work -sub _ { - return $_[0]; -} - sub display_problem_text { my ($q, $problem) = @_; my $out = $q->h1(ent($problem->{title})); diff --git a/templates/website/emptyhomes-header b/templates/website/emptyhomes-header index 79728aa16..e0d86bca5 100644 --- a/templates/website/emptyhomes-header +++ b/templates/website/emptyhomes-header @@ -8,10 +8,7 @@ <link href="http://www.emptyhomes.com/eha2.css" rel="stylesheet" type="text/css"> <style type="text/css" media="screen, projection"> @import "/css/core.css"; -@import "/css/main-emptyhomes.css"; -/* -@import "/css/scambs.css"; -*/ +@import "/css/emptyhomes.css"; </style> <!-- RSS --> </head> diff --git a/web/css/core.css b/web/css/core.css index a1fa31b64..9efc0b35a 100644 --- a/web/css/core.css +++ b/web/css/core.css @@ -160,6 +160,15 @@ ul#error { /* Map */ +#watermark { + background: url("/mojwatermark5.png"); + height: 508px; + width: 508px; + position: absolute; + top: 0; + left: 0; +} + #map_box { float: right; width: 510px; diff --git a/web/css/main-emptyhomes.css b/web/css/emptyhomes.css index 5e8422601..fe2304a71 100644 --- a/web/css/main-emptyhomes.css +++ b/web/css/emptyhomes.css @@ -1,3 +1,11 @@ +label { + width: 3em; +} + +#alert_links { + float: none; +} + #map_box { width: 380px; } @@ -10,14 +18,18 @@ margin-top: 0.5em; } #middle { - width: 570px; + width: 620px; } #middle p { - width: 580px; + width: 620px; } #middle p#copyright { width: auto; } +p#fixed, p#unknown { + margin-right: 400px; + width: auto; +} #left #topbox a, #left #bottombox a { color: #30517A; @@ -49,7 +61,7 @@ blockquote { .a { color: #000000; - background-color: #427499; + background-color: #DCDCED; /* #427499; */ } #postcodeForm, #front_stats div { diff --git a/web/css/ie6.css b/web/css/ie6.css new file mode 100644 index 000000000..073905425 --- /dev/null +++ b/web/css/ie6.css @@ -0,0 +1,4 @@ +#watermark { + background: none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/mojwatermark5.png',sizingMethod='scale'); +} diff --git a/web/css/main-scambs.css b/web/css/main-scambs.css index 08ed4011e..a8fb0a548 100644 --- a/web/css/main-scambs.css +++ b/web/css/main-scambs.css @@ -17,3 +17,11 @@ blockquote { width: 7em; } +#map_box { + width: 380px; +} +#map, #drag { + width: 378px; + height: 378px; +} + diff --git a/web/index.cgi b/web/index.cgi index c84acc934..d69c7248a 100755 --- a/web/index.cgi +++ b/web/index.cgi @@ -6,7 +6,7 @@ # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: index.cgi,v 1.190 2008-04-14 16:06:03 matthew Exp $ +# $Id: index.cgi,v 1.191 2008-05-06 10:01:31 matthew Exp $ use strict; use Standard; @@ -45,20 +45,20 @@ sub main { my $out = ''; my %params; if ($q->param('submit_problem') || ($q->param('submit_map') && $q->param('submit_map')==2)) { - $params{title} = 'Submitting your problem'; + $params{title} = _('Submitting your report'); ($out) = submit_problem($q); } elsif ($q->param('submit_update')) { - $params{title} = 'Submitting your update'; + $params{title} = _('Submitting your update'); ($out) = submit_update($q); } elsif ($q->param('submit_map')) { ($out, %params) = display_form($q); - $params{title} = 'Reporting a problem'; + $params{title} = _('Reporting a problem'); } elsif ($q->param('id')) { ($out, %params) = display_problem($q); - $params{title} .= ' - Viewing a problem'; + $params{title} .= ' - ' . _('Viewing a problem'); } elsif ($q->param('pc') || ($q->param('x') && $q->param('y'))) { ($out, %params) = display_location($q); - $params{title} = 'Viewing a location'; + $params{title} = _('Viewing a location'); } else { $out = front_page($q); } @@ -74,10 +74,8 @@ Page::do_fastcgi(\&main); sub front_page { my ($q, $error) = @_; my $pc_h = ent($q->param('pc') || ''); - my $out = <<EOF; -<p id="expl"><strong>Report, view, or discuss local problems</strong> -<br><small>(like graffiti, fly tipping, broken paving slabs, or street lighting)</small></p> -EOF + my $out = '<p id="expl"><strong>' . _('Report, view, or discuss local problems') . '</strong> +<br><small>' . _('(like graffiti, fly tipping, broken paving slabs, or street lighting)') . '</small></p>'; $out .= '<p id="error">' . $error . '</p>' if ($error); my $fixed = dbh()->selectrow_array("select count(*) from problem where state='fixed' and lastupdate>ms_current_timestamp()-'1 month'::interval"); my $updates = dbh()->selectrow_array("select count(*) from comment where state='confirmed'"); @@ -114,17 +112,17 @@ EOF </form> <div id="front_intro"> +EOF + $out .= $q->h2(_('How to report a problem')); + $out .= $q->ol( + $q->li(_('Enter a nearby UK postcode, or street name and area')), + $q->li(_('Locate the problem on a map of the area')), + $q->li(_('Enter details of the problem')), + $q->li(_('We send it to the council on your behalf')) + ); -<h2>How to report a problem</h2> - -<ol> -<li>Enter a nearby UK postcode, or street name and area -<li>Locate the problem on a map of the area -<li>Enter details of the problem -<li>We send it to the council on your behalf -</ol> - -<h2>FixMyStreet updates</h2> + $out .= $q->h2(_('FixMyStreet updates')); + $out .= <<EOF; <div id="front_stats"> <div><big>$new</big> reports $new_text</div> @@ -138,12 +136,12 @@ EOF EOF my $recent_photos = Page::recent_photos(3); - $out .= "<h2>Photos of recent reports</h2>$recent_photos" if $recent_photos; + $out .= $q->h2(_('Photos of recent reports')) . $recent_photos if $recent_photos; my $probs = select_all("select id,title from problem where state in ('confirmed', 'fixed') order by confirmed desc limit 5"); - $out .= '<h2>Recently reported problems</h2> <ul>' if @$probs; + $out .= $q->h2(_('Recently reported problems')) . ' <ul>' if @$probs; foreach (@$probs) { $out .= '<li><a href="/?id=' . $_->{id} . '">'. ent($_->{title}); $out .= '</a>'; @@ -180,7 +178,7 @@ sub submit_update { $image = Page::process_photo($fh); } catch Error::Simple with { my $e = shift; - push(@errors, "That image doesn't appear to have uploaded correctly ($e), please try again."); + push(@errors, sprintf(_("That image doesn't appear to have uploaded correctly (%s), please try again."), $e)); }; } @@ -201,7 +199,7 @@ sub submit_update { my %h = (); $h{update} = $input{update}; - $h{name} = $input{name} ? $input{name} : "Anonymous"; + $h{name} = $input{name} ? $input{name} : _("Anonymous"); $h{url} = mySociety::Config::get('BASE_URL') . '/C/' . mySociety::AuthToken::store('update', $id); dbh()->commit(); @@ -216,7 +214,7 @@ sub submit_problem { for (qw(title detail)) { $input{$_} = lc $input{$_} if $input{$_} !~ /[a-z]/; $input{$_} = ucfirst $input{$_}; - $input{$_} =~ s/\b(dog\s*)shit\b/$1poo/ig; + $input{$_} =~ s/\b(dog\s*)shit\b/$1poo/ig; } my @errors; @@ -226,21 +224,21 @@ sub submit_problem { push @errors, $err if $err; } - push(@errors, 'No council selected') unless ($input{council} && $input{council} =~ /^(?:-1|[\d,]+(?:\|[\d,]+)?)$/); - push(@errors, 'Please enter a subject') unless $input{title} =~ /\S/; - push(@errors, 'Please enter some details') unless $input{detail} =~ /\S/; + push(@errors, _('No council selected')) unless ($input{council} && $input{council} =~ /^(?:-1|[\d,]+(?:\|[\d,]+)?)$/); + push(@errors, _('Please enter a subject')) unless $input{title} =~ /\S/; + push(@errors, _('Please enter some details')) unless $input{detail} =~ /\S/; if ($input{name} !~ /\S/) { - push @errors, 'Please enter your name'; + push @errors, _('Please enter your name'); } elsif (length($input{name}) < 5 || $input{name} !~ /\s/ || $input{name} =~ /\ba\s*n+on+((y|o)mo?u?s)?(ly)?\b/i) { - push @errors, 'Please enter your full name, councils need this information - if you do not wish your name to be shown on the site, untick the box'; + push @errors, _('Please enter your full name, councils need this information - if you do not wish your name to be shown on the site, untick the box'); } if ($input{email} !~ /\S/) { - push(@errors, 'Please enter your email'); + push(@errors, _('Please enter your email')); } elsif (!mySociety::EmailUtil::is_valid_email($input{email})) { - push(@errors, 'Please enter a valid email'); + push(@errors, _('Please enter a valid email')); } if ($input{category} && $input{category} eq '-- Pick a category --') { - push (@errors, 'Please choose a category'); + push (@errors, _('Please choose a category')); $input{category} = ''; } @@ -262,7 +260,7 @@ sub submit_problem { my @input_councils = split /,|\|/, $input{council}; foreach (@input_councils) { if (!$councils{$_}) { - push(@errors, 'That location is not part of that council'); + push(@errors, _('That location is not part of that council')); last; } } @@ -282,7 +280,7 @@ sub submit_problem { @valid_councils = map { $_->{area_id} } @$categories; foreach my $c (@valid_councils) { if ($no_details =~ /$c/) { - push(@errors, 'We have details for that council'); + push(@errors, _('We have details for that council')); $no_details =~ s/,?$c//; } } @@ -291,9 +289,9 @@ sub submit_problem { } $areas = ',' . join(',', sort keys %$areas) . ','; } elsif ($input{easting} || $input{northing}) { - push(@errors, 'Somehow, you only have one co-ordinate. Please try again.'); + push(@errors, _('Somehow, you only have one co-ordinate. Please try again.')); } else { - push(@errors, 'You haven\'t specified any sort of co-ordinates. Please try again.'); + push(@errors, _('You haven\'t specified any sort of co-ordinates. Please try again.')); } my $image; @@ -302,7 +300,7 @@ sub submit_problem { $image = Page::process_photo($fh); } catch Error::Simple with { my $e = shift; - push(@errors, "That image doesn't appear to have uploaded correctly ($e), please try again."); + push(@errors, sprintf(_("That image doesn't appear to have uploaded correctly (%s), please try again."), $e)); }; } @@ -316,7 +314,7 @@ sub submit_problem { delete $input{council} if $input{council} eq '-1'; my $used_map = $input{skipped} ? 'f' : 't'; - $input{category} = 'Other' unless $input{category}; + $input{category} = _('Other') unless $input{category}; my ($id, $out); if (my $token = $input{flickr}) { @@ -330,9 +328,9 @@ sub submit_problem { $input{phone}, $input{council}, $input{anonymous} ? 'f' : 't', $input{category}, $id); dbh()->commit(); - $out = $q->p(sprintf(_('You have successfully confirmed your problem and you can now <a href="%s">view it on the site</a>.'), "/?id=$id")); + $out = $q->p(sprintf(_('You have successfully confirmed your report and you can now <a href="%s">view it on the site</a>.'), "/?id=$id")); } else { - $out = $q->p('There appears to have been a problem.'); + $out = $q->p(_('There appears to have been a problem.')); } } else { $id = dbh()->selectrow_array("select nextval('problem_id_seq');"); @@ -405,10 +403,10 @@ sub display_form { $py = Page::os_to_px($northing, $input{y}, 1); } else { # Normal form submission - $input{x} = int(Page::os_to_tile($input{easting})); - $input{y} = int(Page::os_to_tile($input{northing})); - $px = Page::os_to_px($input{easting}, $input{x}); - $py = Page::os_to_px($input{northing}, $input{y}, 1); + my ($x, $y, $tile_x, $tile_y); + ($x, $y, $tile_x, $tile_y, $px, $py) = Page::os_to_px_with_adjust($q, $input{easting}, $input{northing}, undef, undef); + $input{x} = $tile_x; + $input{y} = $tile_y; $easting = $input_h{easting}; $northing = $input_h{northing}; } @@ -423,27 +421,29 @@ sub display_form { #'Litter', 'Neighbourhood noise'); } $all_councils = [ keys %$all_councils ]; - return display_location($q, 'That spot does not appear to be covered by a council - if it is past the shoreline, for example, please specify the closest point on land.') unless @$all_councils; + return display_location($q, _('That spot does not appear to be covered by a council - if it is past the shoreline, for example, please specify the closest point on land.')) unless @$all_councils; my $areas_info = mySociety::MaPit::get_voting_areas_info($all_councils); # Look up categories for this council or councils my $category = ''; my %council_ok; - my $categories = select_all("select area_id, category from contacts - where deleted='f' and area_id in (" . join(',', @$all_councils) . ')'); - @$categories = sort { $a->{category} cmp $b->{category} } @$categories; - my @categories; - foreach (@$categories) { - $council_ok{$_->{area_id}} = 1; - next if $_->{category} eq 'Other'; - push @categories, $_->{category}; - } - if (@categories) { - @categories = ('-- Pick a category --', @categories, 'Other'); - $category = $q->div($q->label({'for'=>'form_category'}, 'Category:'), - $q->popup_menu(-name=>'category', -values=>\@categories, - -attributes=>{id=>'form_category'}) - ); + if ($q->{site} ne 'emptyhomes') { # No category + my $categories = select_all("select area_id, category from contacts + where deleted='f' and area_id in (" . join(',', @$all_councils) . ')'); + @$categories = sort { $a->{category} cmp $b->{category} } @$categories; + my @categories; + foreach (@$categories) { + $council_ok{$_->{area_id}} = 1; + next if $_->{category} eq _('Other'); + push @categories, $_->{category}; + } + if (@categories) { + @categories = ('-- Pick a category --', @categories, _('Other')); + $category = $q->div($q->label({'for'=>'form_category'}, _('Category:')), + $q->popup_menu(-name=>'category', -values=>\@categories, + -attributes=>{id=>'form_category'}) + ); + } } my @councils = keys %council_ok; @@ -463,65 +463,66 @@ sub display_form { <input type="hidden" name="x" value="$input_h{x}"> <input type="hidden" name="y" value="$input_h{y}"> <input type="hidden" name="skipped" value="1"> -<h1>Reporting a problem</h1> -<ul> EOF + $out .= $q->h1(_('Reporting a problem')) . '<ul>'; } else { my $pins = Page::display_pin($q, $px, $py, 'purple'); $out .= Page::display_map($q, x => $input{x}, y => $input{y}, type => 2, pins => $pins, px => $px, py => $py ); - $out .= '<h1>Reporting a problem</h1> '; - $out .= '<p>You have located the problem at the point marked with a purple pin on the map. -If this is not the correct location, simply click on the map again. '; - } - - if ($details eq 'all') { - $out .= '<p>All the information you provide here will be sent to <strong>' - . join('</strong> or <strong>', map { $areas_info->{$_}->{name} } @$all_councils) - . '</strong>. On the site, we will show the subject and details of the problem, - plus your name if you give us permission.'; - $out .= '<input type="hidden" name="council" value="' . join(',',@$all_councils) . '">'; - } elsif ($details eq 'some') { - my $e = mySociety::Config::get('CONTACT_EMAIL'); - my %councils = map { $_ => 1 } @councils; - my @missing; - foreach (@$all_councils) { - push @missing, $_ unless $councils{$_}; - } - my $n = @missing; - my $list = join(' or ', map { $areas_info->{$_}->{name} } @missing); - $out .= '<p>All the information you provide here will be sent to <strong>' - . join('</strong> or <strong>', map { $areas_info->{$_}->{name} } @councils) - . '</strong>. On the site, we will show the subject and details of the problem, - plus your name if you give us permission.'; - $out .= ' We do <strong>not</strong> yet have details for the other council'; - $out .= ($n>1) ? 's that cover' : ' that covers'; - $out .= " this location. You can help us by finding a contact email address for local + $out .= $q->h1(_('Reporting a problem')) . ' '; + $out .= $q->p(_('You have located the problem at the point marked with a purple pin on the map. +If this is not the correct location, simply click on the map again. ')); + } + + if ($q->{site} ne 'emptyhomes') { # No "send to council" blurb + if ($details eq 'all') { + $out .= '<p>All the information you provide here will be sent to <strong>' + . join('</strong> or <strong>', map { $areas_info->{$_}->{name} } @$all_councils) + . '</strong>. On the site, we will show the subject and details of the problem, + plus your name if you give us permission.'; + $out .= '<input type="hidden" name="council" value="' . join(',',@$all_councils) . '">'; + } elsif ($details eq 'some') { + my $e = mySociety::Config::get('CONTACT_EMAIL'); + my %councils = map { $_ => 1 } @councils; + my @missing; + foreach (@$all_councils) { + push @missing, $_ unless $councils{$_}; + } + my $n = @missing; + my $list = join(' or ', map { $areas_info->{$_}->{name} } @missing); + $out .= '<p>All the information you provide here will be sent to <strong>' + . join('</strong> or <strong>', map { $areas_info->{$_}->{name} } @councils) + . '</strong>. On the site, we will show the subject and details of the problem, + plus your name if you give us permission.'; + $out .= ' We do <strong>not</strong> yet have details for the other council'; + $out .= ($n>1) ? 's that cover' : ' that covers'; + $out .= " 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>."; - $out .= '<input type="hidden" name="council" value="' . join(',', @councils) - . '|' . join(',', @missing) . '">'; - } else { - my $e = mySociety::Config::get('CONTACT_EMAIL'); - my $list = join(' or ', map { $areas_info->{$_}->{name} } @$all_councils); - my $n = @$all_councils; - $out .= '<p>We do not yet have details for the council'; - $out .= ($n>1) ? 's that cover' : ' that covers'; - $out .= " this location. If you submit a problem here it will be + $out .= '<input type="hidden" name="council" value="' . join(',', @councils) + . '|' . join(',', @missing) . '">'; + } else { + my $e = mySociety::Config::get('CONTACT_EMAIL'); + my $list = join(' or ', map { $areas_info->{$_}->{name} } @$all_councils); + my $n = @$all_councils; + $out .= '<p>We do not yet have details for the council'; + $out .= ($n>1) ? 's that cover' : ' that covers'; + $out .= " this location. If you submit a problem here it will be left on the site, but <strong>not</strong> 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>."; - $out .= '<input type="hidden" name="council" value="-1">'; + $out .= '<input type="hidden" name="council" value="-1">'; + } } if ($input{skipped}) { - $out .= '<p>Please fill in the form below with details of the problem, and -describe the location as precisely as possible in the details box.'; + $out .= $q->p(_('Please fill in the form below with details of the problem, +and describe the location as precisely as possible in the details box.')); } elsif ($details ne 'none') { $out .= '<p>Please fill in details of the problem below. The council won\'t be able to help unless you leave as much detail as you can, so please describe the exact location of the problem (e.g. on a wall), what it is, how long it has been there, a description (and a photo of the problem if you have one), etc.'; } else { - $out .= '<p>Please fill in details of the problem below.'; + $out .= $q->p(_('Please fill in details of the problem below.')); } $out .= ' <input type="hidden" name="easting" value="' . $easting . '"> @@ -534,10 +535,14 @@ photo of the problem if you have one), etc.'; $out .= <<EOF; <div id="fieldset"> $category +EOF + $out .= <<EOF unless $q->{site} eq 'emptyhomes'; # No Subject <div><label for="form_title">Subject:</label> <input type="text" value="$input_h{title}" name="title" id="form_title" size="30"></div> +EOF + $out .= <<EOF; <div><label for="form_detail">Details:</label> -<textarea name="detail" id="form_detail" rows="7" cols="27">$input_h{detail}</textarea></div> +<textarea name="detail" id="form_detail" rows="7" cols="15">$input_h{detail}</textarea></div> EOF if (my $token = $input{flickr}) { my $id = mySociety::AuthToken::retrieve('flickr', $token); @@ -568,8 +573,10 @@ EOF <div><label for="form_email">Email:</label> <input type="text" value="$input_h{email}" name="email" id="form_email" size="30"></div> <div><label for="form_phone">Phone:</label> -<input type="text" value="$input_h{phone}" name="phone" id="form_phone" size="20"> +<input type="text" value="$input_h{phone}" name="phone" id="form_phone" size="15"> <small>(optional)</small></div> +EOF + $out .= <<EOF unless $q->{site} eq 'emptyhomes'; # No notes <p>Please note:</p> <ul> <li>Please be polite, concise and to the point. @@ -581,6 +588,8 @@ 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. </ul> +EOF + $out .= <<EOF; <p align="right"><input type="submit" name="submit_problem" value="Submit"></p> </div> EOF @@ -619,24 +628,18 @@ sub display_location { my ($pins, $current_map, $current, $fixed, $dist) = map_pins($q, $x, $y); my $out = Page::display_map($q, x => $x, y => $y, type => 1, pins => $pins ); - $out .= '<h1>Problems in this area</h1>'; + $out .= $q->h1(_('Problems in this area')); if (@errors) { $out .= '<ul id="error"><li>' . join('</li><li>', @errors) . '</li></ul>'; } my $skipurl = NewURL($q, 'submit_map'=>1, skipped=>1); - $out .= <<EOF; -<p id="text_map">To report a problem, simply <strong>click on the map</strong> at the correct location.</p> - -<p id="text_no_map"><small>If you cannot see a map – if you have images turned off, + $out .= $q->p({-id=>'text_map'}, _('To report a problem, simply <strong>click on the map</strong> at the correct location.')); + $out .= $q->p({-id=>'text_no_map'}, sprintf(_("<small>If you cannot see a map – if you have images turned off, or are using a text only browser, for example – and you wish to report a problem, please -<a href="$skipurl">skip this step</a> and we will ask you -to describe the location of your problem instead.</small></p> -EOF - $out .= <<EOF; -<div> -<h2>Recent problems reported near here</h2> -EOF +<a href='%s'>skip this step</a> and we will ask you +to describe the location of the problem instead.</small>"), $skipurl)); + $out .= '<div' . $q->h2(_('Recent problems reported near here')); my $list = ''; foreach (@$current_map) { $list .= '<li><a href="' . NewURL($q, id=>$_->{id}, x=>undef, y=>undef) . '">'; @@ -646,13 +649,16 @@ EOF if (@$current_map) { $out .= '<ol id="current">' . $list . '</ol>'; } else { - $out .= '<p>No problems have been reported yet.</p>'; + $out .= $q->p(_('No problems have been reported yet.')); } + $out .= $q->h2(sprintf(_('Closest problems within %skm'), $dist)); + my $email_me = _('Email me problems'); + my $rss_title = _('RSS feed of recent local problems'); + my $rss_alt = _('RSS feed'); $out .= <<EOF; - <h2>Closest problems within ${dist}km</h2> <div id="alert_links"> - <a id="email_alert" href="/alert?pc=$input_h{pc};type=local;feed=local:$x:$y;alert=Subscribe">Email me problems</a> - <span id="rss_link"><a href="/rss/$x,$y"><img src="/i/feed.png" width="16" height="16" title="RSS feed of recent local problems" alt="RSS feed" border="0" style="vertical-align: middle"></a></span> + <a id="email_alert" href="/alert?pc=$input_h{pc};type=local;feed=local:$x:$y;alert=Subscribe">$email_me</a> + <span id="rss_link"><a href="/rss/$x,$y"><img src="/i/feed.png" width="16" height="16" title="$rss_title" alt="$rss_alt" border="0" style="vertical-align: middle"></a></span> </div> EOF $list = ''; @@ -665,11 +671,9 @@ EOF my $list_start = @$current_map + 1; $out .= '<ol id="current_near" start="' . $list_start . '">' . $list . '</ol>'; } else { - $out .= '<p>No problems have been reported yet.</p>'; + $out .= $q->p(_('No problems have been reported yet.')); } - $out .= <<EOF; - <h2>Recently fixed problems within ${dist}km</h2> -EOF + $out .= $q->h2(sprintf(_('Recently fixed problems within %skm'), $dist)); $list = ''; foreach (@$fixed) { $list .= '<li><a href="' . NewURL($q, id=>$_->{id}, x=>undef, y=>undef) . '">'; @@ -679,13 +683,13 @@ EOF if (@$fixed) { $out .= "<ol>$list</ol>\n"; } else { - $out .= '<p>No problems have been fixed yet</p>'; + $out .= $q->p(_('No problems have been fixed yet')); } $out .= '</div>'; $out .= Page::display_map_end(1); my %params = ( - rss => [ 'Recent local problems, FixMyStreet', "/rss/$x,$y" ] + rss => [ _('Recent local problems, FixMyStreet'), "/rss/$x,$y" ] ); return ($out, %params); @@ -710,12 +714,7 @@ sub display_problem { from problem where id=? and state in ('confirmed','fixed', 'hidden')", {}, $input{id}); return display_location($q, 'Unknown problem ID') unless $problem; return front_page($q, 'That problem has been hidden from public view as it contained inappropriate public details') if $problem->{state} eq 'hidden'; - my $x = Page::os_to_tile($problem->{easting}); - my $y = Page::os_to_tile($problem->{northing}); - my $x_tile = $input{x} || int($x); - my $y_tile = $input{y} || int($y); - my $px = Page::os_to_px($problem->{easting}, $x_tile); - my $py = Page::os_to_px($problem->{northing}, $y_tile, 1); + my ($x, $y, $x_tile, $y_tile, $px, $py) = Page::os_to_px_with_adjust($q, $problem->{easting}, $problem->{northing}, $input{x}, $input{y}); my $out = ''; @@ -738,9 +737,10 @@ sub display_problem { $x_tile -= 1 if $x - $x_tile < 0.5; $y_tile -= 1 if $y - $y_tile < 0.5; my $back = NewURL($q, id=>undef, x=>$x_tile, y=>$y_tile, submit_update=>undef); - $out .= '<p style="padding-bottom: 0.5em; border-bottom: dotted 1px #999999;" align="right"><a href="' . $back . '">More problems nearby</a></p>'; + $out .= '<p style="padding-bottom: 0.5em; border-bottom: dotted 1px #999999;" align="right"><a href="' + . $back . '">' . _('More problems nearby') . '</a></p>'; $out .= '<div id="alert_links">'; - $out .= '<a id="email_alert" href="/alert?type=updates;id='.$input_h{id}.'">Email me updates</a>'; + $out .= '<a id="email_alert" href="/alert?type=updates;id='.$input_h{id}.'">' . _('Email me updates') . '</a>'; $out .= <<EOF; <form action="alert" method="post" id="email_alert_box"> <p>Receive email when updates are left on this problem</p> @@ -751,12 +751,13 @@ sub display_problem { <input type="submit" value="Subscribe"> </form> EOF - $out .= ' <span id="rss_link"><a href="/rss/'.$input_h{id}.'"><img src="/i/feed.png" width="16" height="16" title="RSS feed" alt="RSS feed of updates to this problem" border="0" style="vertical-align: middle"></a></span>'; + $out .= ' <span id="rss_link"><a href="/rss/'.$input_h{id}.'"><img src="/i/feed.png" width="16" height="16" title="' . _('RSS feed') . '" alt="' . _('RSS feed of updates to this problem') . '" border="0" style="vertical-align: middle"></a></span>'; $out .= '</div>'; $out .= Page::display_problem_updates($input{id}); - $out .= '<h2>Provide an update</h2>'; - $out .= $q->p($q->small('Please note that updates are not sent to the council.')); + $out .= $q->h2(_('Provide an update')); + $out .= $q->p($q->small(_('Please note that updates are not sent to the council.'))) + unless $q->{site} eq 'emptyhomes'; # No council blurb if (@errors) { $out .= '<ul id="error"><li>' . join('</li><li>', @errors) . '</li></ul>'; } @@ -764,7 +765,7 @@ EOF my $fixed = ($input{fixed}) ? ' checked' : ''; my $fixedline = $problem->{state} eq 'fixed' ? '' : qq{ <div class="checkbox"><input type="checkbox" name="fixed" id="form_fixed" value="1"$fixed> -<label for="form_fixed">This problem has been fixed</label></div> +<label for="form_fixed">} . _('This problem has been fixed') . qq{</label></div> }; $out .= <<EOF; <form method="post" action="./" id="fieldset" enctype="multipart/form-data"> @@ -798,7 +799,7 @@ swfu = new SWFUpload(swfu_settings); EOF my %params = ( - rss => [ 'Updates to this problem, FixMyStreet', "/rss/$input_h{id}" ], + rss => [ 'Updates to this ' . $q->{thing} . ', FixMyStreet', "/rss/$input_h{id}" ], js => $js, title => $problem->{title} ); @@ -26,7 +26,8 @@ function compass_pan(e, a) { YAHOO.util.Event.onContentReady('compass', function() { var ua=navigator.userAgent.toLowerCase(); - if (document.getElementById('mapForm') && /safari/.test(ua)) return; + if (document.getElementById('mapForm') && (/safari/.test(ua) || /Konqueror/.test(ua))) return; + if (document.getElementById('map').offsetWidth > 510) return; var points = this.getElementsByTagName('a'); YAHOO.util.Event.addListener(points[1], 'click', compass_pan, { x:0, y:tileheight }); @@ -43,6 +44,7 @@ YAHOO.util.Event.onContentReady('compass', function() { YAHOO.util.Event.onContentReady('map', function() { var ua=navigator.userAgent.toLowerCase(); if (document.getElementById('mapForm') && (/safari/.test(ua) || /Konqueror/.test(ua))) return; + if (document.getElementById('map').offsetWidth > 510) return; new YAHOO.util.DDMap('map'); update_tiles(start_x, start_y, true); diff --git a/web/mojwatermark5.png b/web/mojwatermark5.png Binary files differnew file mode 100644 index 000000000..972c7b441 --- /dev/null +++ b/web/mojwatermark5.png diff --git a/web/questionnaire.cgi b/web/questionnaire.cgi index 356ee7225..3b36216b8 100755 --- a/web/questionnaire.cgi +++ b/web/questionnaire.cgi @@ -6,7 +6,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: questionnaire.cgi,v 1.29 2008-04-30 13:10:56 matthew Exp $ +# $Id: questionnaire.cgi,v 1.30 2008-05-06 10:01:31 matthew Exp $ use strict; use Standard; @@ -175,12 +175,7 @@ sub display_questionnaire { }; return $error if $error; - my $x = Page::os_to_tile($problem->{easting}); - my $y = Page::os_to_tile($problem->{northing}); - my $x_tile = int($x); - my $y_tile = int($y); - my $px = Page::os_to_px($problem->{easting}, $x_tile); - my $py = Page::os_to_px($problem->{northing}, $y_tile, 1); + my ($x, $y, $x_tile, $y_tile, $px, $py) = Page::os_to_px_with_adjust($q, $problem->{easting}, $problem->{northing}, undef, undef); my $pins = Page::display_pin($q, $px, $py, $problem->{state} eq 'fixed'?'green':'red'); my $problem_text = Page::display_problem_text($q, $problem); diff --git a/web/reports.cgi b/web/reports.cgi index c7003c38a..05cfd5b3f 100755 --- a/web/reports.cgi +++ b/web/reports.cgi @@ -7,7 +7,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: reports.cgi,v 1.14 2008-01-28 15:27:00 matthew Exp $ +# $Id: reports.cgi,v 1.15 2008-05-06 10:01:31 matthew Exp $ use strict; use Standard; @@ -148,8 +148,12 @@ sub main { print $q->p(_('This is a summary of all reports on this site; select a particular council to see the reports sent there.')); my $c = 0; print '<table cellpadding="3" cellspacing="1" border="0">'; - print '<tr><th>Name</th><th>New problems</th><th>Older problems</th> -<th>Old problems,<br>state unknown</th><th>Recently fixed</th><th>Old fixed</th></tr>'; + print '<tr><th>Name</th><th>' . _('New problems') . '</th><th>' . _('Older problems') . '</th>'; + if ($q->{site} eq 'emptyhomes') { + print '<th>Recently in use</th><th>Old in use</th></tr>'; + } else { + print '<th>Old problems,<br>state unknown</th><th>Recently fixed</th><th>Old fixed</th></tr>'; + } foreach (sort { $areas_info->{$a}->{name} cmp $areas_info->{$b}->{name} } keys %councils) { print '<tr align="center"'; print ' class="a"' if (++$c%2); @@ -157,8 +161,15 @@ sub main { print '><td align="left"><a href="/reports/' . $url . '">' . $areas_info->{$_}->{name} . '</a></td>'; summary_cell(\@{$open{$_}{new}}); - summary_cell(\@{$open{$_}{older}}); - summary_cell(\@{$open{$_}{unknown}}); + if ($q->{site} eq 'emptyhomes') { + my $c = 0; + $c += @{$open{$_}{older}} if $open{$_}{older}; + $c += @{$open{$_}{unknown}} if $open{$_}{unknown}; + summary_cell($c); + } else { + summary_cell(\@{$open{$_}{older}}); + summary_cell(\@{$open{$_}{unknown}}); + } summary_cell(\@{$fixed{$_}{new}}); summary_cell(\@{$fixed{$_}{old}}); print "</tr>\n"; @@ -180,8 +191,10 @@ sub main { $name = ent($q_ward) . ", $name"; } print Page::header($q, title=>"$name - Summary reports", rss => [ "Problems within $name, FixMyStreet", $rss_url ]); + my $rss_title = _('RSS feed'); + my $rss_alt = _('RSS feed of problems in this %s'); print $q->p( - $q->a({ href => $rss_url }, '<img align="right" src="/i/feed.png" width="16" height="16" title="RSS feed" alt="RSS feed of problems in this ' . $thing . '" border="0" hspace="4">'), + $q->a({ href => $rss_url }, '<img align="right" src="/i/feed.png" width="16" height="16" title="' . $rss_title . '" alt="' . sprintf($rss_alt, $thing) . '" border="0" hspace="4">'), 'This is a summary of all reports for one ' . $thing . '. You can ' . ($all ? $q->a({href => NewURL($q, council=>undef, ward=>undef, all=>undef) }, 'see less detail') : @@ -192,9 +205,16 @@ sub main { print "<h2>$name</h2>\n"; if ($open{$one_council}) { print '<div id="col_problems">'; - list_problems('New problems', $open{$one_council}{new}, $all); - list_problems('Older problems', $open{$one_council}{older}, $all); - list_problems('Old problems, state unknown', $open{$one_council}{unknown}, $all); + list_problems(_('New problems'), $open{$one_council}{new}, $all); + if ($q->{site} eq 'emptyhomes') { + my @old = (); + push @old, @{$open{$one_council}{older}} if $open{$one_council}{older}; + push @old, @{$open{$one_council}{unknown}} if $open{$one_council}{unknown}; + list_problems('Older empty properties', \@old, $all); + } else { + list_problems('Older problems', $open{$one_council}{older}, $all); + list_problems('Old problems, state unknown', $open{$one_council}{unknown}, $all); + } print '</div>'; } if ($fixed{$one_council}) { @@ -225,8 +245,9 @@ sub add_row { sub summary_cell { my $c = shift; - $c ||= []; - print '<td>' . scalar @$c . '</td>'; + $c = 0 unless defined $c; + $c = @$c if ref($c) eq 'ARRAY'; + print '<td>' . $c . '</td>'; } sub list_problems { |