aboutsummaryrefslogtreecommitdiffstats
path: root/web-admin/index.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'web-admin/index.cgi')
-rwxr-xr-xweb-admin/index.cgi304
1 files changed, 158 insertions, 146 deletions
diff --git a/web-admin/index.cgi b/web-admin/index.cgi
index 2868cf2d6..62fcfb587 100755
--- a/web-admin/index.cgi
+++ b/web-admin/index.cgi
@@ -18,7 +18,8 @@ use strict;
use FindBin;
use lib "$FindBin::Bin/../perllib";
use lib "$FindBin::Bin/../commonlib/perllib";
-use POSIX qw(strftime);
+use Encode;
+use POSIX qw(strftime strcoll);
use Digest::MD5 qw(md5_hex);
use Page;
@@ -64,10 +65,10 @@ sub allowed_pages($) {
my $pages = Cobrand::admin_pages($cobrand);
if (!$pages) {
$pages = {
- 'summary' => ['Summary', 0],
- 'councilslist' => ['Council contacts', 1],
- 'reports' => ['Reports', 2],
- 'timeline' => ['Timeline', 3],
+ 'summary' => [_('Summary'), 0],
+ 'councilslist' => [_('Council contacts'), 1],
+ 'reports' => [_('Search Reports'), 2],
+ 'timeline' => [_('Timeline'), 3],
'councilcontacts' => [undef, undef],
'counciledit' => [undef, undef],
'report_edit' => [undef, undef],
@@ -80,10 +81,11 @@ sub allowed_pages($) {
sub html_head($$) {
my ($q, $title) = @_;
my $ret = $q->header(-type => 'text/html', -charset => 'utf-8');
+ my $site_title = _('FixMyStreet administration');
$ret .= <<END;
<html>
<head>
-<title>$title - FixMyStreet administration</title>
+<title>$title - $site_title</title>
<style type="text/css">
dt { clear: left; float: left; font-weight: bold; }
dd { margin-left: 8em; }
@@ -95,7 +97,7 @@ END
my $pages = allowed_pages($q);
my @links = sort {$pages->{$a}[1] <=> $pages->{$b}[1]} grep {$pages->{$_}->[0] } keys %$pages;
$ret .= $q->p(
- $q->strong("FixMyStreet admin:"),
+ $q->strong(_("FixMyStreet admin:")),
map { $q->a( { href => NewURL($q, page => $_) }, $pages->{$_}->[0]) } @links
);
@@ -118,8 +120,8 @@ sub fetch_data {
sub admin_summary ($) {
my ($q) = @_;
my $cobrand = Page::get_cobrand($q);
- print html_head($q, "Summary");
- print $q->h1("Summary");
+ print html_head($q, _("Summary"));
+ print $q->h1(_("Summary"));
my $contacts = Problems::contact_counts($cobrand);
my %contacts = @$contacts;
@@ -148,24 +150,24 @@ sub admin_summary ($) {
my $questionnaires_pc = $questionnaires{total} ? $questionnaires{1} / $questionnaires{total} * 100 : 'na';
print $q->ul(
- $q->li("<strong>$total_problems_live</strong> live problems"),
- $q->li("$comments{confirmed} live updates"),
- $q->li("$alerts{1} confirmed alerts, $alerts{0} unconfirmed"),
- $q->li("$questionnaires{total} questionnaires sent &ndash; $questionnaires{1} answered ($questionnaires_pc%)"),
- $q->li("$contacts{total} council contacts &ndash; $contacts{1} confirmed, $contacts{0} unconfirmed"),
+ $q->li(sprintf(_("<strong>%d</strong> live problems"), $total_problems_live)),
+ $q->li(sprintf(_("%d live updates"), $comments{confirmed})),
+ $q->li(sprintf(_("%d confirmed alerts, %d unconfirmed"), $alerts{1}, $alerts{0})),
+ $q->li(sprintf(_("%d questionnaires sent &ndash; %d answered (%d%%)"), $questionnaires{total}, $questionnaires{1}, $questionnaires_pc)),
+ $q->li(sprintf(_("%d council contacts &ndash; %d confirmed, %d unconfirmed"), $contacts{total}, $contacts{1}, $contacts{0})),
);
if (Cobrand::admin_show_creation_graph($cobrand)) {
print $q->p( $q->a({ href => mySociety::Config::get('BASE_URL') . "/bci-live-creation.png" },
- "Graph of problem creation by status over time" ));
+ _("Graph of problem creation by status over time") ));
}
- print $q->h2("Problem breakdown by state");
+ print $q->h2(_("Problem breakdown by state"));
print $q->ul(
map { $q->li("$problems{$_} $_") } sort keys %problems
);
- print $q->h2("Update breakdown by state");
+ print $q->h2(_("Update breakdown by state"));
print $q->ul(
map { $q->li("$comments{$_} $_") } sort keys %comments
);
@@ -177,23 +179,27 @@ sub admin_summary ($) {
sub admin_councils_list ($) {
my ($q) = @_;
- print html_head($q, "Council contacts");
- print $q->h1("Council contacts");
+ print html_head($q, _("Council contacts"));
+ print $q->h1(_("Council contacts"));
# Table of editors
- print $q->h2("Diligency prize league table");
+ print $q->h2(_("Diligency prize league table"));
my $edit_activity = dbh()->selectall_arrayref("select count(*) as c, editor from contacts_history group by editor order by c desc");
- print $q->ul(
- map { $q->li($_->[0] . " edits by " . $_->[1]) } @$edit_activity
- );
+ if (@$edit_activity) {
+ print $q->ul(
+ map { $q->li( sprintf(_('%d edits by %s'), $_->[0], $_->[1])) } @$edit_activity
+ );
+ } else {
+ print $q->p(_('No edits have yet been made.'));
+ }
# Table of councils
- print $q->h2("Councils");
- my $ignore = 'LGD';
- $ignore .= '|CTY' if $q->{site} eq 'emptyhomes';
- my @types = grep { !/$ignore/ } @$mySociety::VotingArea::council_parent_types; # LGD are NI councils
- my $areas = mySociety::MaPit::call('areas', \@types);
- my @councils_ids = sort { $areas->{$a}->{name} cmp $areas->{$b}->{name} } keys %$areas;
+ print $q->h2(_("Councils"));
+ my $cobrand = Page::get_cobrand($q);
+ my @area_types = Cobrand::area_types($cobrand);
+ my $areas = mySociety::MaPit::call('areas', \@area_types);
+ my @councils_ids = sort { strcoll($areas->{$a}->{name}, $areas->{$b}->{name}) } keys %$areas;
+ @councils_ids = grep { $_ ne 301 } @councils_ids;
my $bci_info = dbh()->selectall_hashref("
select area_id, count(*) as c, count(case when deleted then 1 else null end) as deleted,
count(case when confirmed then 1 else null end) as confirmed
@@ -202,26 +208,31 @@ sub admin_councils_list ($) {
my $list_part = sub {
my @ids = @_;
if (!scalar(@ids)) {
- print "None";
+ print _("None");
return;
}
- print $q->p(join($q->br(),
- map {
- $q->a({ href => NewURL($q, area_id => $_, page => 'councilcontacts') },
- $areas->{$_}->{name}) . " " .
+ my @li;
+ foreach (@ids) {
+ my $parent = '';
+ $parent = ', ' . $areas->{$areas->{$_}->{parent_area}}->{name}
+ if $areas->{$_}->{parent_area};
+
+ push @li, $q->li($q->a({ href => NewURL($q, area_id => $_, page => 'councilcontacts') },
+ $areas->{$_}->{name}) . $parent . ' ' .
($bci_info->{$_} && $q->{site} ne 'emptyhomes' ?
- $bci_info->{$_}->{c} . ' addresses'
- : '')
- } @ids));
+ sprintf(_('%d addresses'), $bci_info->{$_}->{c})
+ : ''));
+ }
+ print $q->ul(@li);
};
- print $q->h3('No info at all');
+ print $q->h3(_('No info at all'));
&$list_part(grep { !$bci_info->{$_} } @councils_ids);
- print $q->h3('Currently has 1+ deleted');
+ print $q->h3(_('Currently has 1+ deleted'));
&$list_part(grep { $bci_info->{$_} && $bci_info->{$_}->{deleted} } @councils_ids);
- print $q->h3('Some unconfirmeds');
+ print $q->h3(_('Some unconfirmeds'));
&$list_part(grep { $bci_info->{$_} && !$bci_info->{$_}->{deleted} && $bci_info->{$_}->{confirmed} != $bci_info->{$_}->{c} } @councils_ids);
- print $q->h3('All confirmed');
+ print $q->h3(_('All confirmed'));
&$list_part(grep { $bci_info->{$_} && !$bci_info->{$_}->{deleted} && $bci_info->{$_}->{confirmed} == $bci_info->{$_}->{c} } @councils_ids);
print html_tail($q);
}
@@ -251,20 +262,20 @@ sub admin_council_contacts ($$) {
", {},
$email, ($q->param('confirmed') ? 1 : 0),
($q->param('deleted') ? 1 : 0),
- ($q->remote_user() || "*unknown*"), $q->param('note'),
+ ($q->remote_user() || _("*unknown*")), $q->param('note'),
$area_id, $category
);
- $updated = $q->p($q->em("Values updated"));
+ $updated = $q->p($q->em(_("Values updated")));
unless ($update > 0) {
dbh()->do('insert into contacts
(area_id, category, email, editor, whenedited, note, confirmed, deleted)
values
(?, ?, ?, ?, ms_current_timestamp(), ?, ?, ?)', {},
$area_id, $category, $email,
- ($q->remote_user() || '*unknown*'), $q->param('note'),
+ ($q->remote_user() || _('*unknown*')), $q->param('note'),
($q->param('confirmed') ? 1 : 0), ($q->param('deleted') ? 1 : 0)
);
- $updated = $q->p($q->em("New category contact added"));
+ $updated = $q->p($q->em(_("New category contact added")));
}
dbh()->commit();
} elsif ($posted eq 'update') {
@@ -278,11 +289,11 @@ sub admin_council_contacts ($$) {
where area_id = ?
and category = ?
", {},
- ($q->remote_user() || "*unknown*"),
+ ($q->remote_user() || _("*unknown*")),
$area_id, $cat
);
}
- $updated = $q->p($q->em("Values updated"));
+ $updated = $q->p($q->em(_("Values updated")));
dbh()->commit();
}
@@ -301,7 +312,7 @@ sub admin_council_contacts ($$) {
# Title
my $mapit_data = mySociety::MaPit::call('area', $area_id);
- my $title = 'Council contacts for ' . $mapit_data->{name};
+ my $title = sprintf(_('Council contacts for %s'), $mapit_data->{name});
print html_head($q, $title);
print $q->h1($title);
print $updated;
@@ -314,20 +325,20 @@ sub admin_council_contacts ($$) {
"Example postcode " . $example_postcode) . " | ";
}
$links_html .= ' ' .
- $q->a({ href => mySociety::Config::get('BASE_URL') . "/reports?council=" . $area_id }, " List all reported problems");
+ $q->a({ href => mySociety::Config::get('BASE_URL') . "/reports?council=" . $area_id }, _(" List all reported problems"));
$links_html .= ' ' .
- $q->a({ href => NewURL($q, area_id => $area_id, page => 'councilcontacts', text => 1) }, 'Text only version');
+ $q->a({ href => NewURL($q, area_id => $area_id, page => 'councilcontacts', text => 1) }, _('Text only version'));
print $q->p($links_html);
# Display of addresses / update statuses form
print $q->start_form(-method => 'POST', -action => './');
print $q->start_table({border=>1, cellpadding=>2, cellspacing=>0});
- print $q->Tr({}, $q->th({}, ["Category", "Email", "Confirmed", "Deleted", "Last editor", "Note", "When edited", 'Confirm']));
+ print $q->Tr({}, $q->th({}, [_("Category"), _("Email"), _("Confirmed"), _("Deleted"), _("Last editor"), _("Note"), _("When edited"), _('Confirm')]));
foreach my $l (@$bci_data) {
print $q->Tr($q->td([
$q->a({ href => NewURL($q, area_id => $area_id, category => $l->{category}, page => 'counciledit') },
- $l->{category}), $l->{email}, $l->{confirmed} ? 'Yes' : 'No',
- $l->{deleted} ? 'Yes' : 'No', $l->{editor}, ent($l->{note}),
+ $l->{category}), $l->{email}, $l->{confirmed} ? _('Yes') : _('No'),
+ $l->{deleted} ? _('Yes') : _('No'), $l->{editor}, ent($l->{note}),
$l->{whenedited} =~ m/^(.+)\.\d+$/,
$q->checkbox(-name => 'confirmed', -value => $l->{category}, -label => '')
]));
@@ -339,34 +350,34 @@ sub admin_council_contacts ($$) {
$q->hidden('posted', 'update'),
$q->hidden('token', get_token($q)),
$q->hidden('page', 'councilcontacts'),
- $q->submit('Update statuses')
+ $q->submit(_('Update statuses'))
);
print $q->end_form();
# Display form for adding new category
- print $q->h2('Add new category');
+ print $q->h2(_('Add new category'));
print $q->start_form(-method => 'POST', -action => './');
if ($q->{site} ne 'emptyhomes') {
- print $q->p($q->strong("Category: "),
+ print $q->p($q->strong(_("Category: ")),
$q->textfield(-name => "category", -size => 30));
}
- print $q->p($q->strong("Email: "),
+ print $q->p($q->strong(_("Email: ")),
$q->textfield(-name => "email", -size => 30));
$q->autoEscape(0);
print $q->p(
- $q->checkbox(-id => 'confirmed', -name => "confirmed", -value => 1, -label => ' ' . $q->label({-for => 'confirmed'}, 'Confirmed')),
+ $q->checkbox(-id => 'confirmed', -name => "confirmed", -value => 1, -label => ' ' . $q->label({-for => 'confirmed'}, _('Confirmed'))),
' ',
- $q->checkbox(-id => 'deleted', -name => "deleted", -value => 1, -label => ' ' . $q->label({-for => 'deleted'}, 'Deleted'))
+ $q->checkbox(-id => 'deleted', -name => "deleted", -value => 1, -label => ' ' . $q->label({-for => 'deleted'}, _('Deleted')))
);
$q->autoEscape(1);
- print $q->p($q->strong("Note: "),
+ print $q->p($q->strong(_("Note: ")),
$q->textarea(-name => "note", -rows => 3, -columns=>40));
print $q->p(
$q->hidden('area_id', $area_id),
$q->hidden('posted', 'new'),
$q->hidden('token', get_token($q)),
$q->hidden('page', 'councilcontacts'),
- $q->submit('Create category')
+ $q->submit(_('Create category'))
);
print $q->end_form();
@@ -384,7 +395,7 @@ sub admin_council_edit ($$$) {
my $mapit_data = mySociety::MaPit::call('area', $area_id);
# Title
- my $title = 'Council contacts for ' . $mapit_data->{name};
+ my $title = sprintf(_('Council contacts for %s'), $mapit_data->{name});
print html_head($q, $title);
print $q->h1($title);
@@ -401,35 +412,35 @@ sub admin_council_edit ($$$) {
map { $q->param($_, $bci_data->{$_}) } qw/category email confirmed deleted/;
$q->param('page', 'councilcontacts');
$q->param('posted', 'new');
- print $q->strong("Category: ") . $bci_data->{category};
+ print $q->strong(_("Category: ")) . $bci_data->{category};
print $q->hidden('token', get_token($q)),
print $q->hidden("category");
- print $q->strong(" Email: ");
+ print $q->strong(' ' . _("Email: "));
print $q->textfield(-name => "email", -size => 30) . " ";
$q->autoEscape(0);
- print $q->checkbox(-id => 'confirmed', -name => "confirmed", -value => 1, -label => ' ' . $q->label({-for => 'confirmed'}, 'Confirmed'));
+ print $q->checkbox(-id => 'confirmed', -name => "confirmed", -value => 1, -label => ' ' . $q->label({-for => 'confirmed'}, _('Confirmed')));
print ' ';
- print $q->checkbox(-id => 'deleted', -name => "deleted", -value => 1, -label => ' ' . $q->label({-for => 'deleted'}, 'Deleted'));
+ print $q->checkbox(-id => 'deleted', -name => "deleted", -value => 1, -label => ' ' . $q->label({-for => 'deleted'}, _('Deleted')));
$q->autoEscape(1);
print $q->br();
- print $q->strong("Note: ");
+ print $q->strong(_("Note: "));
print $q->textarea(-name => "note", -rows => 3, -columns=>40) . " ";
print $q->br();
print $q->hidden('area_id');
print $q->hidden('posted');
print $q->hidden('page');
- print $q->submit('Save changes');
+ print $q->submit(_('Save changes'));
print $q->end_form();
# Display history of changes
- print $q->h2('History');
+ print $q->h2(_('History'));
print $q->start_table({border=>1});
- print $q->Tr({}, $q->th({}, ["When edited", "Email", "Confirmed", "Deleted", "Editor", "Note"]));
+ print $q->Tr({}, $q->th({}, [_("When edited"), _("Email"), _("Confirmed"), _("Deleted"), _("Editor"), _("Note")]));
my $html = '';
my $prev = undef;
foreach my $h (@$bci_history) {
- $h->{confirmed} = $h->{confirmed} ? "yes" : "no",
- $h->{deleted} = $h->{deleted} ? "yes" : "no",
+ $h->{confirmed} = $h->{confirmed} ? _("yes") : _("no"),
+ $h->{deleted} = $h->{deleted} ? _("yes") : _("no"),
my $emailchanged = ($prev && $h->{email} ne $prev->{email}) ? 1 : 0;
my $confirmedchanged = ($prev && $h->{confirmed} ne $prev->{confirmed}) ? 1 : 0;
my $deletedchanged = ($prev && $h->{deleted} ne $prev->{deleted}) ? 1 : 0;
@@ -450,20 +461,20 @@ sub admin_council_edit ($$$) {
sub admin_reports {
my $q = shift;
- my $title = 'Reports';
+ my $title = _('Search Reports');
my $cobrand = Page::get_cobrand($q);
my $pages = allowed_pages($q);
print html_head($q, $title);
print $q->h1($title);
print $q->start_form(-method => 'GET', -action => './');
- print $q->label({-for => 'search'}, 'Search:'), ' ', $q->textfield(-id => 'search', -name => "search", -size => 30);
+ print $q->label({-for => 'search'}, _('Search:')), ' ', $q->textfield(-id => 'search', -name => "search", -size => 30);
print $q->hidden('page');
print $q->end_form;
if (my $search = $q->param('search')) {
my $results = Problems::problem_search($search);
print $q->start_table({border=>1, cellpadding=>2, cellspacing=>0});
- print $q->Tr({}, $q->th({}, ['ID', 'Title', 'Name', 'Email', 'Council', 'Category', 'Anonymous', 'Cobrand', 'Created', 'State', 'When sent', '*']));
+ print $q->Tr({}, $q->th({}, [_('ID'), _('Title'), _('Name'), _('Email'), _('Council'), _('Category'), _('Anonymous'), _('Cobrand'), _('Created'), _('State'), _('When sent'), _('*') ]));
my $cobrand_data;
foreach (@$results) {
my $url = $_->{id};
@@ -485,11 +496,11 @@ sub admin_reports {
(my $whensent = $_->{whensent} || '&nbsp;') =~ s/\..*//;
my $state = $_->{state};
$state .= '<small>';
- $state .= "<br>Confirmed:&nbsp;$confirmed" if $_->{state} eq 'confirmed' || $_->{state} eq 'fixed';
- $state .= '<br>Fixed: ' . $lastupdate if $_->{state} eq 'fixed';
- $state .= "<br>Last&nbsp;update:&nbsp;$lastupdate" if $_->{state} eq 'confirmed';
+ $state .= "<br>" . _('Confirmed:') . "&nbsp;$confirmed" if $_->{state} eq 'confirmed' || $_->{state} eq 'fixed';
+ $state .= '<br>' . _('Fixed:') . ' ' . $lastupdate if $_->{state} eq 'fixed';
+ $state .= "<br>" . _('Last&nbsp;update:') . "&nbsp;$lastupdate" if $_->{state} eq 'confirmed';
$state .= '</small>';
- my $anonymous = $_->{anonymous} ? 'Yes' : 'No';
+ my $anonymous = $_->{anonymous} ? _('Yes') : _('No');
my $cobrand = $_->{cobrand};
$cobrand .= "<br>" . $_->{cobrand_data};
my $counciltext = '';
@@ -503,12 +514,12 @@ sub admin_reports {
print $q->Tr($attr, $q->td([ $url, ent($_->{title}), ent($_->{name}), ent($_->{email}),
$counciltext,
$category, $anonymous, $cobrand, $created, $state, $whensent,
- $q->a({ -href => NewURL($q, page=>'report_edit', id=>$_->{id}) }, 'Edit')
+ $q->a({ -href => NewURL($q, page=>'report_edit', id=>$_->{id}) }, _('Edit'))
]));
}
print $q->end_table;
- print $q->h2('Updates');
+ print $q->h2(_('Updates'));
my $updates = Problems::update_search($search);
admin_show_updates($q, $updates);
}
@@ -528,13 +539,13 @@ sub admin_edit_report {
dbh()->do('update problem set whensent=null where id=?', {}, $id);
admin_log_edit($q, $id, 'problem', 'resend');
dbh()->commit();
- $status_message = '<p><em>That problem will now be resent.</em></p>';
+ $status_message = '<p><em>' . _('That problem will now be resent.') . '</em></p>';
} elsif ($q->param('submit')) {
return not_found($q) if $q->param('token') ne get_token($q);
my $new_state = $q->param('state');
my $done = 0;
if ($new_state eq 'confirmed' && $row{state} eq 'unconfirmed' && $q->{site} eq 'emptyhomes') {
- $status_message = '<p><em>I am afraid you cannot confirm unconfirmed reports.</em></p>';
+ $status_message = '<p><em>' . _('I am afraid you cannot confirm unconfirmed reports.') . '</em></p>';
$done = 1;
}
my $query = 'update problem set anonymous=?, state=?, name=?, email=?, title=?, detail=?';
@@ -563,21 +574,21 @@ sub admin_edit_report {
}
dbh()->commit();
map { $row{$_} = $q->param($_) } qw(anonymous state name email title detail);
- $status_message = '<p><em>Updated!</em></p>';
+ $status_message = '<p><em>' . _('Updated!') . '</em></p>';
}
}
my %row_h = map { $_ => $row{$_} ? ent($row{$_}) : '' } keys %row;
- my $title = "Editing problem $id";
+ my $title = sprintf(_("Editing problem %d"), $id);
print html_head($q, $title);
print $q->h1($title);
print $status_message;
- my $council = $row{council} || '<em>None</em>';
+ my $council = $row{council} || '<em>' . _('None') . '</em>';
(my $areas = $row{areas}) =~ s/^,(.*),$/$1/;
- my $easting = int($row{easting}+0.5);
- my $northing = int($row{northing}+0.5);
- my $questionnaire = $row{send_questionnaire} ? 'Yes' : 'No';
- my $used_map = $row{used_map} ? 'used map' : "didn't use map";
+ my $latitude = $row{latitude};
+ my $longitude = $row{longitude};
+ my $questionnaire = $row{send_questionnaire} ? _('Yes') : _('No');
+ my $used_map = $row{used_map} ? _('used map') : _("didn't use map");
(my $whensent = $row{whensent} || '&nbsp;') =~ s/\..*//;
(my $confirmed = $row{confirmed} || '-') =~ s/ (.*?)\..*/&nbsp;$1/;
my $photo = '';
@@ -589,50 +600,50 @@ sub admin_edit_report {
}
$photo = '<li><img align="top" src="' . Cobrand::base_url_for_emails($cobrand, $cobrand_data) . '/photo?id=' . $row{id} . '">
<input type="checkbox" id="remove_photo" name="remove_photo" value="1">
-<label for="remove_photo">Remove photo (can\'t be undone!)</label>' if $row{photo};
+<label for="remove_photo">' . _("Remove photo (can't be undone!)") . '</label>' if $row{photo};
my $url_base = Cobrand::base_url_for_emails($cobrand, $cobrand_data);
my $url = $url_base . '/report/' . $row{id};
- my $anon = $q->label({-for=>'anonymous'}, 'Anonymous:') . ' ' . $q->popup_menu(-id => 'anonymous', -name => 'anonymous', -values => { 1=>'Yes', 0=>'No' }, -default => $row{anonymous});
- my $state = $q->label({-for=>'state'}, 'State:') . ' ' . $q->popup_menu(-id => 'state', -name => 'state', -values => { confirmed => 'Open', fixed => 'Fixed', hidden => 'Hidden', unconfirmed => 'Unconfirmed', partial => 'Partial' }, -default => $row{state});
+ my $anon = $q->label({-for=>'anonymous'}, _('Anonymous:')) . ' ' . $q->popup_menu(-id => 'anonymous', -name => 'anonymous', -values => { 1=>_('Yes'), 0=>_('No') }, -default => $row{anonymous});
+ my $state = $q->label({-for=>'state'}, _('State:')) . ' ' . $q->popup_menu(-id => 'state', -name => 'state', -values => { confirmed => _('Open'), fixed => _('Fixed'), hidden => _('Hidden'), unconfirmed => _('Unconfirmed'), partial => _('Partial') }, -default => $row{state});
my $resend = '';
- $resend = ' <input onclick="return confirm(\'You really want to resend?\')" type="submit" name="resend" value="Resend report">' if $row{state} eq 'confirmed';
+ $resend = ' <input onclick="return confirm(\'' . _('You really want to resend?') . '\')" type="submit" name="resend" value="' . _('Resend report') . '">' if $row{state} eq 'confirmed';
print $q->start_form(-method => 'POST', -action => './');
print $q->hidden('page');
print $q->hidden('id');
print $q->hidden('token', get_token($q));
print $q->hidden('submit', 1);
- print <<EOF;
+ print "
<ul>
-<li><a href="$url">View report on site</a>
-<li><label for="title">Subject:</label> <input size=60 type="text" id="title" name="title" value="$row_h{title}">
-<li><label for="detail">Details:</label><br><textarea name="detail" id="detail" cols=60 rows=10>$row_h{detail}</textarea>
-<li>Co-ordinates: $easting,$northing (originally entered $row_h{postcode}, $used_map)
-<li>For council(s): $council (other areas: $areas)
+<li><a href='$url'>" . _('View report on site') . "</a>
+<li><label for='title'>" . _('Subject:') . "</label> <input size=60 type='text' id='title' name='title' value='$row_h{title}'>
+<li><label for='detail'>" . _('Details:') . "</label><br><textarea name='detail' id='detail' cols=60 rows=10>$row_h{detail}</textarea>
+<li>" . _('Co-ordinates:') . " $latitude,$longitude (" . _('originally entered') . " $row_h{postcode}, $used_map)
+<li>" . _('For council(s):') . " $council (" . _('other areas:') . " $areas)
<li>$anon
<li>$state
-<li>Category: $row{category}
-<li>Name: <input type="text" name="name" id="name" value="$row_h{name}">
-<li>Email: <input type="text" id="email" name="email" value="$row_h{email}">
-<li>Phone: $row_h{phone}
-<li>Created: $row{created}
-<li>Confirmed: $confirmed
-<li>Sent: $whensent $resend
-<li>Last update: $row{lastupdate}
-<li>Service: $row{service}
-<li>Cobrand: $row{cobrand}
-<li>Cobrand data: $row{cobrand_data}
-<li>Going to send questionnaire? $questionnaire
+<li>" . _('Category:') . " $row{category}
+<li>" . _('Name:') . " <input type='text' name='name' id='name' value='$row_h{name}'>
+<li>" . _('Email:') . " <input type='text' id='email' name='email' value='$row_h{email}'>
+<li>" . _('Phone:') . " $row_h{phone}
+<li>" . _('Created:') . " $row{created}
+<li>" . _('Confirmed:') . " $confirmed
+<li>" . _('Sent:') . " $whensent $resend
+<li>" . _('Last update:') . " $row{lastupdate}
+<li>" . _('Service:') . " $row{service}
+<li>" . _('Cobrand:') . " $row{cobrand}
+<li>" . _('Cobrand data:') . " $row{cobrand_data}
+<li>" . _('Going to send questionnaire?') . " $questionnaire
$photo
</ul>
-EOF
- print $q->submit('Submit changes');
+";
+ print $q->submit(_('Submit changes'));
print $q->end_form;
- print $q->h2('Updates');
+ print $q->h2(_('Updates'));
my $updates = select_all('select * from comment where problem_id=? order by created', $id);
admin_show_updates($q, $updates);
print html_tail($q);
@@ -642,7 +653,7 @@ sub admin_show_updates {
my ($q, $updates) = @_;
my $cobrand = Page::get_cobrand($q);
print $q->start_table({border=>1, cellpadding=>2, cellspacing=>0});
- print $q->Tr({}, $q->th({}, ['ID', 'State', 'Name', 'Email', 'Created', 'Cobrand', 'Text', '*']));
+ print $q->Tr({}, $q->th({}, [ _('ID'), _('State'), _('Name'), _('Email'), _('Created'), _('Cobrand'), _('Text'), _('*') ]));
my $base_url = '';
my $cobrand_data;
foreach (@$updates) {
@@ -661,7 +672,7 @@ sub admin_show_updates {
$attr->{-class} = 'hidden' if $_->{state} eq 'hidden' || ($_->{problem_state} && $_->{problem_state} eq 'hidden');
print $q->Tr($attr, $q->td([ $url, $_->{state}, ent($_->{name} || ''),
ent($_->{email}), $_->{created}, $cobrand, ent($_->{text}),
- $q->a({ -href => NewURL($q, page=>'update_edit', id=>$_->{id}) }, 'Edit')
+ $q->a({ -href => NewURL($q, page=>'update_edit', id=>$_->{id}) }, _('Edit'))
]));
}
print $q->end_table;
@@ -683,12 +694,12 @@ sub admin_edit_update {
}
$query .= ' where id=?';
dbh()->do($query, {}, $q->param('state'), $q->param('name'), $q->param('email'), $q->param('text'), $id);
- $status_message = '<p><em>Updated!</em></p>';
+ $status_message = '<p><em>' . _('Updated!') . '</em></p>';
# If we're hiding an update, see if it marked as fixed and unfix if so
if ($q->param('state') eq 'hidden' && $row{mark_fixed}) {
dbh()->do("update problem set state='confirmed' where state='fixed' and id=?", {}, $row{problem_id});
- $status_message .= '<p><em>Problem marked as open.</em></p>';
+ $status_message .= '<p><em>' . _('Problem marked as open.') . '</em></p>';
}
if ($q->param('state') ne $row{state}) {
@@ -703,8 +714,8 @@ sub admin_edit_update {
dbh()->commit();
map { $row{$_} = $q->param($_) } qw(state name email text);
}
- my %row_h = map { $_ => $row{$_} ? ent($row{$_}) : '' } keys %row;
- my $title = "Editing update $id";
+ my %row_h = map { $_ => $row{$_} ? ent($row{$_}) : '' } keys %row;
+ my $title = sprintf(_("Editing update %d"), $id);
print html_head($q, $title);
print $q->h1($title);
print $status_message;
@@ -719,31 +730,31 @@ sub admin_edit_update {
my $photo = '';
$photo = '<li><img align="top" src="' . Cobrand::base_url_for_emails($cobrand, $cobrand_data) . '/photo?c=' . $row{id} . '">
<input type="checkbox" id="remove_photo" name="remove_photo" value="1">
-<label for="remove_photo">Remove photo (can\'t be undone!)</label>' if $row{photo};
+<label for="remove_photo">' . _("Remove photo (can't be undone!)") . '</label>' if $row{photo};
my $url = Cobrand::base_url_for_emails($cobrand, $cobrand_data) . '/report/' . $row{problem_id} . '#update_' . $row{id};
- my $state = $q->label({-for=>'state'}, 'State:') . ' ' . $q->popup_menu(-id => 'state', -name => 'state', -values => { confirmed => 'Confirmed', hidden => 'Hidden', unconfirmed => 'Unconfirmed' }, -default => $row{state});
+ my $state = $q->label({-for=>'state'}, _('State:')) . ' ' . $q->popup_menu(-id => 'state', -name => 'state', -values => { confirmed => _('Confirmed'), hidden => _('Hidden'), unconfirmed => _('Unconfirmed') }, -default => $row{state});
print $q->start_form(-method => 'POST', -action => './');
print $q->hidden('page');
print $q->hidden('id');
print $q->hidden('token', get_token($q));
print $q->hidden('submit', 1);
- print <<EOF;
+ print "
<ul>
-<li><a href="$url">View update on site</a>
-<li><label for="text">Text:</label><br><textarea name="text" id="text" cols=60 rows=10>$row_h{text}</textarea>
+<li><a href='$url'>" . _('View update on site') . "</a>
+<li><label for='text'>" . _('Text:') . "</label><br><textarea name='text' id='text' cols=60 rows=10>$row_h{text}</textarea>
<li>$state
-<li>Name: <input type="text" name="name" id="name" value="$name"> (blank to go anonymous)
-<li>Email: <input type="text" id="email" name="email" value="$row_h{email}">
-<li>Cobrand: $row{cobrand}
-<li>Cobrand data: $row{cobrand_data}
-<li>Created: $row{created}
+<li>" . _('Name:') . " <input type='text' name='name' id='name' value='$name'> " . _('(blank to go anonymous)') . "
+<li>" . _('Email:') . " <input type='text' id='email' name='email' value='$row_h{email}'>
+<li>" . _('Cobrand:') . " $row{cobrand}
+<li>" . _('Cobrand data:') . " $row{cobrand_data}
+<li>" . _('Created:') . " $row{created}
$photo
</ul>
-EOF
- print $q->submit('Submit changes');
+";
+ print $q->submit(_('Submit changes'));
print $q->end_form;
print html_tail($q);
}
@@ -769,8 +780,8 @@ sub admin_log_edit {
sub admin_timeline {
my $q = shift;
my $cobrand = Page::get_cobrand($q);
- print html_head($q, 'Timeline');
- print $q->h1('Timeline');
+ print html_head($q, _('Timeline'));
+ print $q->h1(_('Timeline'));
my %time;
#my $backto_unix = time() - 60*60*24*7;
@@ -807,41 +818,42 @@ sub admin_timeline {
my $date = '';
my $cobrand_data;
foreach (reverse sort keys %time) {
- my $curdate = strftime('%A, %e %B %Y', localtime($_));
+ my $curdate = decode_utf8(strftime('%A, %e %B %Y', localtime($_)));
if ($date ne $curdate) {
print '</dl>' if $date;
print "<h2>$curdate</h2> <dl>";
$date = $curdate;
}
- print '<dt><b>', strftime('%H:%M:%S', localtime($_)), ':</b></dt> <dd>';
+ print '<dt><b>', decode_utf8(strftime('%H:%M:%S', localtime($_))), ':</b></dt> <dd>';
foreach (@{$time{$_}}) {
my $type = $_->{type};
+ my $name_str = '; ' . sprintf(_("by %s"), ent($_->{name})) . " &lt;" . ent($_->{email}) . "&gt;, '" . ent($_->{title}) . "'";
if ($type eq 'problemCreated') {
- print "Problem $_->{id} created; by " . ent($_->{name}) . " &lt;" . ent($_->{email}) . "&gt;, '" . ent($_->{title}) . "'";
+ print sprintf(_("Problem %d created"), $_->{id}) . $name_str;
} elsif ($type eq 'problemConfirmed') {
$cobrand_data = get_cobrand_data_from_hash($cobrand, $_);
my $url = Cobrand::base_url_for_emails($cobrand, $cobrand_data) . "/report/$_->{id}";
- print "Problem <a href='$url'>$_->{id}</a> confirmed; by " . ent($_->{name}) ." &lt;" . ent($_->{email}) . "&gt;, '" . ent($_->{title}) ."'";
+ print sprintf(_("Problem %s confirmed"), "<a href='$url'>$_->{id}</a>") . $name_str;
} elsif ($type eq 'problemSent') {
$cobrand_data = get_cobrand_data_from_hash($cobrand, $_);
my $url = Cobrand::base_url_for_emails($cobrand, $cobrand_data) . "/report/$_->{id}";
- print "Problem <a href='$url'>$_->{id}</a> sent to council $_->{council}; by " . ent($_->{name}) . " &lt;" . ent($_->{email}) . "&gt;, '" . ent($_->{title}) . "'";
+ print sprintf(_("Problem %s sent to council %s"), "<a href='$url'>$_->{id}</a>", $_->{council});
} elsif ($type eq 'quesSent') {
- print "Questionnaire $_->{id} sent for problem $_->{problem_id}";
+ print sprintf(_("Questionnaire %d sent for problem %d"), $_->{id}, $_->{problem_id});
} elsif ($type eq 'quesAnswered') {
- print "Questionnaire $_->{id} answered for problem $_->{problem_id}, $_->{old_state} to $_->{new_state}";
+ print sprintf(_("Questionnaire %d answered for problem %d, %s to %s"), $_->{id}, $_->{problem_id}, $_->{old_state}, $_->{new_state});
} elsif ($type eq 'update') {
$cobrand_data = get_cobrand_data_from_hash($cobrand, $_);
my $url = Cobrand::base_url_for_emails($cobrand, $cobrand_data) . "/report/$_->{problem_id}#$_->{id}";
my $name = ent($_->{name} || 'anonymous');
- print "Update <a href='$url'>$_->{id}</a> created for problem $_->{problem_id}; by $name &lt;" . ent($_->{email}) . "&gt;";
+ print sprintf(_("Update %s created for problem %d; by %s"), "<a href='$url'>$_->{id}</a>", $_->{problem_id}, $name) . " &lt;" . ent($_->{email}) . "&gt;";
} elsif ($type eq 'alertSub') {
my $param = $_->{parameter} || '';
my $param2 = $_->{parameter2} || '';
- print "Alert $_->{id} created for " . ent($_->{email}) . ", type $_->{alert_type}, parameters $param / $param2";
+ print sprintf(_("Alert %d created for %s, type %s, parameters %s / %s"), $_->{id}, ent($_->{email}), $_->{alert_type}, $param, $param2);
} elsif ($type eq 'alertDel') {
- my $sub = strftime('%H:%M:%S %e %B %Y', localtime($_->{whensubscribed}));
- print "Alert $_->{id} disabled (created $sub)";
+ my $sub = decode_utf8(strftime('%H:%M:%S %e %B %Y', localtime($_->{whensubscribed})));
+ print sprintf(_("Alert %d disabled (created %s)"), $_->{id}, $sub);
}
print '<br>';
}