diff options
author | Matthew Somerville <matthew@mysociety.org> | 2011-05-24 11:25:31 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2011-05-24 11:25:31 +0100 |
commit | 8111b9db1356cd10d1610b4ae1e99ea8054aad46 (patch) | |
tree | 320befc7946b5545f95afc145947bc8073d0677a | |
parent | c95aa5c23fca1f9fc85fe48731ea5348bdda1fdb (diff) |
Put form header in templates, not code.
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 26 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map.pm | 21 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Bing.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/BingOL.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Google.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/OSM.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/OSM/StreetView.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Tilma/Original.pm | 2 | ||||
-rwxr-xr-x | templates/web/default/around/display_location.html | 5 | ||||
-rw-r--r-- | templates/web/default/report/new/fill_in_details.html | 18 |
12 files changed, 31 insertions, 55 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 5a33718da..6e959c830 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -898,31 +898,7 @@ sub generate_map : Private { my $allow_photo_upload = $c->cobrand->allow_photo_upload; # Don't do anything if the user skipped the map - if ( $c->req->param('skipped') ) { - - my $enctype = - $allow_photo_upload - ? ' enctype="multipart/form-data"' - : ''; - - my $cobrand_form_elements = - $c->cobrand->form_elements('mapSkippedForm'); - - my $form_action = $c->uri_for(''); - my $pc = encode_entities( $c->stash->{pc} ); - - $c->stash->{map_html} = <<"END_MAP_HTML"; -<form action="$form_action" method="post" name="mapSkippedForm"$enctype> -<input type="hidden" name="latitude" value="$latitude"> -<input type="hidden" name="longitude" value="$longitude"> -<input type="hidden" name="pc" value="$pc"> -<input type="hidden" name="skipped" value="1"> -$cobrand_form_elements -<div> -END_MAP_HTML - - } - else { + unless ( $c->req->param('skipped') ) { my $map_type = $allow_photo_upload ? 2 : 1; $c->stash->{map_html} = FixMyStreet::Map::display_map( diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm index 1d9ce1527..279f799e4 100644 --- a/perllib/FixMyStreet/Map.pm +++ b/perllib/FixMyStreet/Map.pm @@ -63,27 +63,6 @@ sub display_map { return $map_class->display_map(@_); } -sub header { - my ( $q, $type ) = @_; - return '' unless $type; - - my $cobrand = Page::get_cobrand($q); - my $cobrand_form_elements = - Cobrand::form_elements( $cobrand, 'mapForm', $q ); - my $form_action = Cobrand::url( $cobrand, '/report/new', $q ); - my $encoding = ''; - $encoding = ' enctype="multipart/form-data"' if $type == 2; - my $pc = ent($q->param('pc') || ''); - my $map = ent($q->param('map') || ''); - return <<EOF; -<form action="$form_action" method="post" name="mapForm" id="mapForm"$encoding> -<input type="hidden" name="submit_map" value="1"> -<input type="hidden" name="map" value="$map"> -<input type="hidden" name="pc" value="$pc"> -$cobrand_form_elements -EOF -} - sub map_features { my ( $q, $lat, $lon, $interval ) = @_; diff --git a/perllib/FixMyStreet/Map/Bing.pm b/perllib/FixMyStreet/Map/Bing.pm index 3d3f4bb09..8378cd871 100644 --- a/perllib/FixMyStreet/Map/Bing.pm +++ b/perllib/FixMyStreet/Map/Bing.pm @@ -36,7 +36,7 @@ sub display_map { } my $pins_js = join(",\n", @pins); - my $out = FixMyStreet::Map::header($q, $params{type}); + my $out = ''; my $copyright = _('Map contains Ordnance Survey data © Crown copyright and database right 2010.'); my $key = mySociety::Config::get('BING_MAPS_API_KEY'); $out .= <<EOF; diff --git a/perllib/FixMyStreet/Map/BingOL.pm b/perllib/FixMyStreet/Map/BingOL.pm index 41b7c1051..ca6057a26 100644 --- a/perllib/FixMyStreet/Map/BingOL.pm +++ b/perllib/FixMyStreet/Map/BingOL.pm @@ -38,7 +38,7 @@ sub display_map { } my $pins_js = join(",\n", @pins); - my $out = FixMyStreet::Map::header($q, $params{type}); + my $out = ''; my $copyright = _('Map contains Ordnance Survey data © Crown copyright and database right 2010. Microsoft'); $out .= <<EOF; <input type="hidden" name="latitude" id="fixmystreet.latitude" value="$params{latitude}"> diff --git a/perllib/FixMyStreet/Map/Google.pm b/perllib/FixMyStreet/Map/Google.pm index f51cae43d..b7753223b 100644 --- a/perllib/FixMyStreet/Map/Google.pm +++ b/perllib/FixMyStreet/Map/Google.pm @@ -36,7 +36,7 @@ sub display_map { } my $pins_js = join(",\n", @pins); - my $out = FixMyStreet::Map::header($q, $params{type}); + my $out = ''; my $copyright = _('Map contains Ordnance Survey data © Crown copyright and database right 2010.'); $out .= <<EOF; <input type="hidden" name="latitude" id="fixmystreet.latitude" value="$params{latitude}"> diff --git a/perllib/FixMyStreet/Map/OSM.pm b/perllib/FixMyStreet/Map/OSM.pm index 028b48125..9608f9f01 100644 --- a/perllib/FixMyStreet/Map/OSM.pm +++ b/perllib/FixMyStreet/Map/OSM.pm @@ -71,7 +71,7 @@ sub display_map { } else { $img_type = '<img'; } - my $out = FixMyStreet::Map::header($q, $params{type}); + my $out = ''; my $copyright = _('Map © <a id="osm_link" href="http://www.openstreetmap.org/">OpenStreetMap</a> and contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'); my $compass = compass($q, $x_tile, $y_tile, $zoom); my $map_type = $self->map_type(); diff --git a/perllib/FixMyStreet/Map/OSM/StreetView.pm b/perllib/FixMyStreet/Map/OSM/StreetView.pm index 5cc1ed5ba..2024a83fc 100644 --- a/perllib/FixMyStreet/Map/OSM/StreetView.pm +++ b/perllib/FixMyStreet/Map/OSM/StreetView.pm @@ -37,7 +37,7 @@ sub display_map { } my $pins_js = join(",\n", @pins); - my $out = FixMyStreet::Map::header($q, $params{type}); + my $out = ''; my $copyright = _('Map contains Ordnance Survey data © Crown copyright and database right 2010.'); $out .= <<EOF; <input type="hidden" name="latitude" id="fixmystreet.latitude" value="$params{latitude}"> diff --git a/perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm b/perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm index 785c8eafe..fc57b8d9d 100644 --- a/perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm +++ b/perllib/FixMyStreet/Map/Tilma/OL/1_10k.pm @@ -43,7 +43,7 @@ sub display_map { } my $pins_js = join(",\n", @pins); - my $out = FixMyStreet::Map::header($q, $params{type}); + my $out = ''; my $tile_width = TILE_WIDTH; my $tile_type = TILE_TYPE; my $sf = SCALE_FACTOR / TILE_WIDTH; diff --git a/perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm b/perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm index 632e75e39..0ff556a17 100644 --- a/perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm +++ b/perllib/FixMyStreet/Map/Tilma/OL/StreetView.pm @@ -43,7 +43,7 @@ sub display_map { } my $pins_js = join(",\n", @pins); - my $out = FixMyStreet::Map::header($q, $params{type}); + my $out = ''; my $tile_width = TILE_WIDTH; my $tile_type = TILE_TYPE; my $sf = SCALE_FACTOR / TILE_WIDTH; diff --git a/perllib/FixMyStreet/Map/Tilma/Original.pm b/perllib/FixMyStreet/Map/Tilma/Original.pm index 20fc79a60..f1bf054f7 100644 --- a/perllib/FixMyStreet/Map/Tilma/Original.pm +++ b/perllib/FixMyStreet/Map/Tilma/Original.pm @@ -96,7 +96,7 @@ sub display_map { my $cobrand = Page::get_cobrand($q); my $root_path_js = Cobrand::root_path_js($cobrand, $q); - my $out = FixMyStreet::Map::header($q, $params{type}); + my $out = ''; my $img_type; if ($params{type}) { $out .= <<EOF; diff --git a/templates/web/default/around/display_location.html b/templates/web/default/around/display_location.html index 61d31e5a5..bbdc9aa92 100755 --- a/templates/web/default/around/display_location.html +++ b/templates/web/default/around/display_location.html @@ -34,6 +34,11 @@ robots => 'noindex,nofollow'; %] +<form action="[% c.uri_for('/report/new') %]" method="post" name="mapForm" id="mapForm"> +<input type="hidden" name="submit_map" value="1"> +<input type="hidden" name="map" value="[% c.req.params.map | html %]"> +<input type="hidden" name="pc" value="[% pc | html %]"> +[% c.cobrand.form_elements('mapForm') %] [% map_html %] [% map_links %] </div> diff --git a/templates/web/default/report/new/fill_in_details.html b/templates/web/default/report/new/fill_in_details.html index 1384bd7e5..7c66dc7d5 100644 --- a/templates/web/default/report/new/fill_in_details.html +++ b/templates/web/default/report/new/fill_in_details.html @@ -1,8 +1,24 @@ [% INCLUDE 'header.html', title => loc('Reporting a problem') %] +[% IF report.used_map %] +<form action="[% c.uri_for('/report/new') %]" method="post" name="mapForm" id="mapForm"[% IF c.cobrand.allow_photo_upload %] enctype="multipart/form-data"[% END %]> +<input type="hidden" name="submit_map" value="1"> +<input type="hidden" name="map" value="[% c.req.params.map | html %]"> +<input type="hidden" name="pc" value="[% pc | html %]"> +[% c.cobrand.form_elements('mapForm') %] +[% ELSE %] +<form action="[% c.uri_for('/report/new') %]" method="post" name="mapSkippedForm"[% IF c.cobrand.allow_photo_upload %] enctype="multipart/form-data"[% END %]> +<input type="hidden" name="latitude" value="[% latitude | html %]"> +<input type="hidden" name="longitude" value="[% longitude | html %]"> +<input type="hidden" name="pc" value="[% pc | html %]"> +<input type="hidden" name="skipped" value="1"> +[% c.cobrand.form_elements('mapSkippedForm') %] +[% END %] + [% map_html %] -</div> + [% IF report.used_map %] +</div> <div id="side"> [% ELSE %] <div id="skipped-map"> |