Skip to content

Commit 316fe67

Browse files
committed
Improve how to reset value part2 #122
1 parent c68963d commit 316fe67

2 files changed

Lines changed: 36 additions & 15 deletions

File tree

admin/admin_photo.php

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,23 @@
3939

4040
$admin_photo_base_url = get_root_url().'admin.php?page=photo-'.$_GET['image_id'];
4141
$self_url = get_root_url().'admin.php?page=plugin&section=piwigo-openstreetmap/admin/admin_photo.php&image_id='.$_GET['image_id'];
42+
$delete_url = get_root_url().'admin.php?page=plugin&section=piwigo-openstreetmap/admin/admin_photo.php&delete_coords=1&image_id='.$_GET['image_id'].'&pwg_token='.get_pwg_token();
4243

4344
load_language('plugin.lang', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
4445
load_language('plugin.lang', OSM_PATH);
4546

4647
global $template, $page, $conf;
4748

49+
// Delete the extra data
50+
if (isset($_GET['delete_coords']) and $_GET['delete_coords'] == 1)
51+
{
52+
check_pwg_token();
53+
$_POST['osmlat'] = "";
54+
$_POST['osmlon'] = "";
55+
$_POST['submit'] = 1;
56+
}
57+
58+
4859
if (isset($_POST['submit']))
4960
{
5061
check_pwg_token();
@@ -60,10 +71,12 @@
6071
else
6172
$page['errors'][] = 'Invalid latitude or longitude value';
6273
}
63-
elseif ( strlen($lat)==0 and strlen($lon)==0 )
74+
elseif ( (strlen($lat)==0 and strlen($lon)==0) or (isset($_GET['delete_coords']) and $_GET['delete_coords'] == 1)) {
6475
$update_query = 'latitude=NULL, longitude=NULL';
65-
else
76+
array_push( $page['infos'], l10n('Coordinates erased'));
77+
} else {
6678
$page['errors'][] = 'Both latitude/longitude must be empty or not empty';
79+
}
6780

6881
if (isset($update_query))
6982
{
@@ -159,16 +172,17 @@
159172
$jsplaces = "\nvar arr_places = ". json_encode($list_of_places) .";\n";
160173

161174
$template->assign(array(
162-
'PWG_TOKEN' => get_pwg_token(),
163-
'F_ACTION' => $self_url,
164-
'TN_SRC' => DerivativeImage::thumb_url($picture).'?'.time(),
165-
'TITLE' => render_element_name($picture),
166-
'OSM_PATH' => embellish_url(get_absolute_root_url().OSM_PATH),
167-
'OSM_JS' => $js,
168-
'LAT' => $lat,
169-
'LON' => $lon,
170-
'AVAILABLE_PLACES' => $available_places,
171-
'LIST_PLACES' => $jsplaces,
175+
'PWG_TOKEN' => get_pwg_token(),
176+
'F_ACTION' => $self_url,
177+
'DELETE_URL' => $delete_url,
178+
'TN_SRC' => DerivativeImage::thumb_url($picture).'?'.time(),
179+
'TITLE' => render_element_name($picture),
180+
'OSM_PATH' => embellish_url(get_absolute_root_url().OSM_PATH),
181+
'OSM_JS' => $js,
182+
'LAT' => $lat,
183+
'LON' => $lon,
184+
'AVAILABLE_PLACES' => $available_places,
185+
'LIST_PLACES' => $jsplaces,
172186
));
173187

174188
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');

admin/admin_photo.tpl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,14 @@
3636
<div style="float: left;">
3737
<img src="{$TN_SRC}" alt="{'Thumbnail'|@translate}" style="border: 2px solid rgb(221, 221, 221);">
3838
</div>
39-
<div style="float: left; margin: auto;">
40-
<ul>
39+
<div style="float: left; margin: auto; padding-left:20px; vertical-align:top;">
40+
<ul style="margin:0;">
4141
<li>
4242
<label><input type="text" size="9" id="osmlat" name="osmlat" value="{$LAT}"> {'LATITUDE'|@translate} (-90=S to 90=N)</label>
4343
</li>
4444
<li>
4545
<label><input type="text" size="9" id="osmlon" name="osmlon" value="{$LON}"> {'LONGITUDE'|@translate} (-180=W to 180=E)</label>
4646
</li>
47-
(Empty values will erase coordinates)
4847
</ul>
4948
<hr>
5049
<ul>
@@ -57,6 +56,14 @@
5756
</li>
5857
</ul>
5958
</div>
59+
<div style="float: left; margin: auto; padding-left:20px; vertical-align:top;" class="photoLinks">
60+
<ul style="margin:0;">
61+
<li>{'Empty values will erase coordinates'|@translate}</a></li>
62+
<li><a class="icon-trash" href="{$DELETE_URL}" onclick="return confirm('{'Are you sure?
63+
Latitude and Longitude will be delete.'|@translate|@escape:javascript}');">{'Erase coordinates'|@translate}</a></li>
64+
</ul>
65+
</div>
66+
6067
</fieldset>
6168

6269
<fieldset>

0 commit comments

Comments
 (0)