Skip to content
Permalink
Browse files

Merge pull request #446 from following5/editcache-fix

prevent data loss in listing editor; updates #36
  • Loading branch information...
teiling88 committed Jan 6, 2017
2 parents b7a2b08 + 634104c commit eabc2abcb0cecad43c7245458dc581ea9da6e506
@@ -190,6 +190,7 @@ function getWaypoints($cacheid)
$cache_terrain = isset($_POST['terrain']) ? $_POST['terrain'] : $cache_record['terrain']; // Ocprop
$cache_country = isset($_POST['country']) ? $_POST['country'] : $cache_record['country']; // Ocprop
$show_all_countries = isset($_POST['show_all_countries']) ? $_POST['show_all_countries'] : 0;
$listing_modified = isset($_POST['listing_modified']) ? $_POST['listing_modified'] + 0 : 0;
$status = isset($_POST['status']) ? $_POST['status'] : $cache_record['status']; // Ocprop
$status_old = $cache_record['status'];
$search_time = isset($_POST['search_time']) ? $_POST['search_time'] : $cache_record['search_time'];
@@ -847,7 +848,7 @@ function getWaypoints($cacheid)
$removedesc =
'&nbsp;[<a href="'
. htmlspecialchars($remove_url, ENT_COMPAT, 'UTF-8')
. '">' . $remove . '</a>]';
. '" onclick="testListingModified(this)" >' . $remove . '</a>]';
} else {
$removedesc = '';
}
@@ -869,7 +870,8 @@ function getWaypoints($cacheid)
'<tr><td colspan="2">'
. htmlspecialchars(db_LanguageFromShort($desclang), ENT_COMPAT, 'UTF-8')
. ' [<a href="' . htmlspecialchars($edit_url, ENT_COMPAT, 'UTF-8')
. '">' . $edit . '</a>]' . $removedesc . '</td></tr>';
. '" onclick="testListingModified(this)" >' . $edit . '</a>]'
. $removedesc . '</td></tr>';
}
tpl_set_var('cache_descs', $cache_descs);
@@ -914,7 +916,9 @@ function getWaypoints($cacheid)
. '</option>';
}
tpl_set_var('statusoptions', $statusoptions);
tpl_set_var('statuschange', $status_old == 5 ? '' : mb_ereg_replace('%1', $cache_id, $status_change));
$statuschange_a_msg = mb_ereg_replace('%1', $cache_id, $status_change_a);
$statuschange_msg = mb_ereg_replace('{a}', $statuschange_a_msg, $status_change);
tpl_set_var('statuschange', $status_old == 5 ? '' : $statuschange_msg);
// show activation form?
if ($status_old == 5) { // status = not yet published
@@ -1039,6 +1043,8 @@ function getWaypoints($cacheid)
);
tpl_set_var('show_all_countries', $show_all_countries);
tpl_set_var('show_all_countries_submit', ($show_all_countries == 0) ? $all_countries_submit : '');
tpl_set_var('listing_modified', $listing_modified);
tpl_set_var('savealert', $savealert);
$st_hours = floor($search_time);
$st_minutes = sprintf('%02.0F', ($search_time - $st_hours) * 60);
@@ -19,6 +19,7 @@
$edit = t('Edit');
$error_wrong_node = t('This cache has been created on another Opencaching website. The cache can only be edited there.');
$savealert = t('Please save the changed geocache properties first.');
$all_countries_submit = '<input type="submit" name="show_all_countries_submit" id="showallcountries" value="' . t('Show all') . '" class="formbutton" onclick="submitbutton(\'showallcountries\')" />';
$error_general = "<tr><td class='error' colspan='2'><b>" . t('Some errors occured, please check the marked fields.') . "</b></td></tr>";
@@ -29,19 +30,22 @@
$way_length_not_ok_message = '<span class="errormsg">' . t('The distance you have entered is invalid. Format aa.aaa') . '</span>';
$sizemismatch_message = '&nbsp;<span class="errormsg">' . t('For virtual and webcam caches, the cache size has to be -no container-!') . '</span>';
$status_message = '&nbsp;<span class="errormsg">' . t('The cache-status does not fit to your publishing options') . '</span>';
$status_change = '<br /><div style="margin-top:6px"><img src="lang/de/ocstyle/images/misc/hint.gif" border="0" width="15" height="11" >' . t('To change the state, you need to <a href="log.php?cacheid=%1">log</a> the new state.') . '</div>';
$status_change = '<br /><div style="margin-top:6px"><img src="lang/de/ocstyle/images/misc/hint.gif" border="0" width="15" height="11" >' . t('To change the state, you need to {a}log</a> the new state.') . '</div>';
$status_change_a = '<a href="log.php?cacheid=%1" onclick="testListingModified(this)">';
$diff_not_ok_message = '&nbsp;<span class="errormsg">' . t('Choose both valuations!') . '</span>';
$safari_not_allowed_message = '<span class="errormsg">' . t('Only virtual caches can be safari caches.') . '</span>';
$bad_wpgc_message = '<span class="errormsg">' . t('GC waypoint is invalid, must be GCxxxxx') . '</span>';
$nopictures = '<tr><td colspan="2">' . t('No pictures available') . '</td></tr><tr><td colspan="2">&nbsp;</td></tr>';
$pictureline0 = '<tr><td colspan="2"><a href="{link}">{title}</a> [<a href="picture.php?action=edit&uuid={uuid}">' . t('edit') . '</a>] [<a href="picture.php?action=delete&uuid={uuid}">' . t('delete') . '</a>]</td></tr>';
$pictureline = '<tr><td colspan="2"><a href="{link}">{title}</a> [<a href="picture.php?action=edit&uuid={uuid}">' . t('edit') . '</a>] [<a href="picture.php?action=delete&uuid={uuid}">' . t('delete') . '</a>] [<a href="picture.php?action=up&uuid={uuid}">' . t('move up') . '</a>]</td></tr>';
$pic_editdel = '<a href="{link}" target="_blank">{title}</a> [<a href="picture.php?action=edit&uuid={uuid}" onclick="testListingModified(this)">' . t('edit') . '</a>] [<a href="picture.php?action=delete&uuid={uuid}" onclick="testListingModified(this)">' . t('delete') . '</a>]';
$pictureline0 = '<tr><td colspan="2">' . $pic_editdel . '</td></tr>';
$pictureline = '<tr><td colspan="2">' . $pic_editdel . ' [<a href="picture.php?action=up&uuid={uuid}" onclick="testListingModified(this)">' . t('move up') . '</a>]</td></tr>';
// Ocprop: <a href=\"http://.*?\.opencaching\.de/images/uploads/.*?\">(.*?)<\/a>.*?\[<a href=\"picture\.php\?action=[a-z]*?\&uuid=(.*?)\">
$picturelines = '{lines}<tr><td colspan="2">&nbsp;</td></tr>';
$gc_com_msg2 = t('To prevent any problems with geocaching.com we want to please you to upload all linked pictures to %1 as well and link the pictures in the HTML code to these on %1');
$nowaypoints = '<tr><td colspan="2">' . t('No waypoints available') . '</td></tr>';
$waypointline = '<tr bgcolor="#ffffff"><td><table class="narrowtable" cellspacing="0" cellpadding="0"><tr><td><img src="{wp_image}" /></td><td>{wp_type}</td></tr></table></td><td><table class="narrowtable"><tr><td style="white-space:nowrap">{wp_coordinate}</td></tr></table></tp><td>{wp_show_description}</td><td>[<a href="childwp.php?cacheid={cacheid}&childid={childid}">' . t('Edit') . '</a>] [<a href="childwp.php?cacheid={cacheid}&deleteid={childid}">' . t('Delete') . '</a>]</td></tr>';
$waypointline = '<tr bgcolor="#ffffff"><td><table class="narrowtable" cellspacing="0" cellpadding="0"><tr><td><img src="{wp_image}" /></td><td>{wp_type}</td></tr></table></td><td><table class="narrowtable"><tr><td style="white-space:nowrap">{wp_coordinate}</td></tr></table></tp><td>{wp_show_description}</td><td>[<a href="childwp.php?cacheid={cacheid}&childid={childid}" onclick="testListingModified(this)">' . t('Edit') . '</a>] [<a href="childwp.php?cacheid={cacheid}&deleteid={childid}" onclick="testListingModified(this)">' . t('Delete') . '</a>]</td></tr>';
$waypointlines = '<tr><td colspan="2"><table class="edit_wptable">{lines}</table></td></tr><tr><td colspan="2">&nbsp;</td></tr>';
$cache_attrib_js = "new Array({id}, {selected}, '{img_undef}', '{img_large}')";
@@ -54,16 +54,29 @@
<!--
var maAttributes = new Array({jsattributes_array});
function setListingModified()
{
document.getElementById('listing_modified').value = '1';
return true;
}
function testListingModified(a)
{
if (document.getElementById('listing_modified').value == '1') {
alert('{savealert}');
a.href = 'javascript:void(0)';
}
}
function _chkVirtual () {
if (document.editcache_form.type.value == "4" || document.editcache_form.type.value == "5") {
document.editcache_form.size.value = "7";
document.editcache_form.size.disabled = true;
}
else
{
document.editcache_form.size.disabled = false;
}
return false;
if (document.editcache_form.type.value == '4' || document.editcache_form.type.value == '5') {
document.editcache_form.size.value = '7';
document.editcache_form.size.disabled = true;
}
else {
document.editcache_form.size.disabled = false;
}
return false;
}
function rebuildCacheAttr()
@@ -99,6 +112,7 @@ function toggleAttr(id)
maAttributes[i][1] = 0;
rebuildCacheAttr();
setListingModified();
break;
}
}
@@ -115,17 +129,18 @@ function toggleAttr(id)
<input type="hidden" name="cacheid" value="{cacheid}"/> <!-- Ocprop -->
<input type="hidden" id="cache_attribs" name="cache_attribs" value="{cache_attribs}" />
<input type="hidden" name="show_all_countries" value="{show_all_countries}"/>
<input type="hidden" name="listing_modified" value="{listing_modified}" id="listing_modified" />
<table class="table">
<tr>
<td>{t}Name:{/t}</td>
<td>
<input type="text" name="name" value="{name}" maxlength="60" class="input400" />{name_message}
<input type="text" name="name" value="{name}" maxlength="60" class="input400" onchange="setListingModified()" />{name_message}
</td>
</tr>
<tr>
<td>{t}Owner:{/t}</td>
<td>
{ownername} [<a href="adoptcache.php?action=listbycache&cacheid={cacheid_urlencode}">{t}offer for adoption{/t}</a>]
{ownername} [<a href="adoptcache.php?action=listbycache&cacheid={cacheid_urlencode}" onclick="testListingModified(this)" >{t}offer for adoption{/t}</a>]
</td>
</tr>
<tr>
@@ -135,7 +150,7 @@ function toggleAttr(id)
<tr>
<td>{t}State:{/t}</td>
<td>
<select name="status" class="input200">
<select name="status" class="input200" onchange="setListingModified()" >
{statusoptions}
</select>{status_message}{statuschange}
</td>
@@ -145,15 +160,15 @@ function toggleAttr(id)
<tr>
<td>{t}Cachetype:{/t}</td>
<td>
<select name="type" class="input200" onChange="return _chkVirtual()">
<select name="type" class="input200" onchange="setListingModified(); return _chkVirtual()" >
{typeoptions}
</select>
</td>
</tr>
<tr>
<td>{t}Size:{/t}</td>
<td>
<select name="size" class="input200" onChange="return _chkVirtual()">
<select name="size" class="input200" onchange="setListingModified(); return _chkVirtual()" >
{sizeoptions}
</select>{size_message}
</td>
@@ -162,20 +177,20 @@ function toggleAttr(id)
<tr>
<td valign="top">{t}Coordinates:{/t}</td>
<td>
<select name="latNS">
<select name="latNS" onchange="setListingModified()" >
<option value="N"{selLatN}>{t}N{/t}</option>
<option value="S"{selLatS}>{t}S{/t}</option>
</select>
&nbsp;<input type="text" name="lat_h" maxlength="3" value="{lat_h}" class="input30" />
°&nbsp;<input type="text" name="lat_min" maxlength="6" value="{lat_min}" class="input50" />&nbsp;'&nbsp;
&nbsp;<input type="text" name="lat_h" maxlength="3" value="{lat_h}" class="input30" onchange="setListingModified()" />
°&nbsp;<input type="text" name="lat_min" maxlength="6" value="{lat_min}" class="input50" onchange="setListingModified()" />&nbsp;'&nbsp;
{lat_message}
&nbsp;&nbsp;
<select name="lonEW">
<select name="lonEW" onchange="setListingModified()" >
<option value="E"{selLonE}>{t}E{/t}</option>
<option value="W"{selLonW}>{t}W{/t}</option>
</select>
&nbsp;<input type="text" name="lon_h" maxlength="3" value="{lon_h}" class="input30" />
°&nbsp;<input type="text" name="lon_min" maxlength="6" value="{lon_min}" class="input50" />&nbsp;'&nbsp;
&nbsp;<input type="text" name="lon_h" maxlength="3" value="{lon_h}" class="input30" onchange="setListingModified()" />
°&nbsp;<input type="text" name="lon_min" maxlength="6" value="{lon_min}" class="input50" onchange="setListingModified()" />&nbsp;'&nbsp;
{lon_message}
</td>
</tr>
@@ -184,7 +199,7 @@ function toggleAttr(id)
<tr>
<td>{t}Country:{/t}</td>
<td>
<select name="country" class="input200">
<select name="country" class="input200" onchange="setListingModified()" >
{countryoptions}
</select>
&nbsp;{show_all_countries_submit}
@@ -195,22 +210,22 @@ function toggleAttr(id)
<tr><td>{t}Rating:{/t}</td>
<td>
{t}Difficulty:{/t}
<select name="difficulty" class="input60">
<select name="difficulty" class="input60" onchange="setListingModified()" >
{difficultyoptions}
</select>&nbsp;&nbsp;
{t}Terrain:{/t}
<select name="terrain" class="input60">
<select name="terrain" class="input60" onchange="setListingModified()" >
{terrainoptions}
</select>{diff_message}
</td>
</tr>
<tr><td>{t}Time and effort (optional):{/t}</td>
<td>
{t}Time effort:{/t}
<input type="text" name="search_time" maxLength="10" value="{search_time}" class="input30" /> h
<input type="text" name="search_time" maxLength="10" value="{search_time}" class="input30" onchange="setListingModified()" /> h
&nbsp;&nbsp;
{t}Distance:{/t}
<input type="text" name="way_length" maxlength="10" value="{way_length}" class="input30" /> km &nbsp; {effort_message}
<input type="text" name="way_length" maxlength="10" value="{way_length}" class="input30" onchange="setListingModified()" /> km &nbsp; {effort_message}
</td>
</tr>
<tr>
@@ -224,7 +239,7 @@ function toggleAttr(id)
<tr>
<td>{t}Waypoints (optional):{/t}</td>
<!-- allow wp_gc copy&paste with leading spaces; will be trimmed later -->
<td>geocaching.com: <input type="text" name="wp_gc" value="{wp_gc}" maxlength="12" class="input70 waypoint" />
<td>geocaching.com: <input type="text" name="wp_gc" value="{wp_gc}" maxlength="12" class="input70 waypoint" onchange="setListingModified()" />
{wpgc_message}
</td>
</tr>
@@ -260,7 +275,7 @@ function toggleAttr(id)
<img src="lang/de/ocstyle/images/description/22x22-description.png" width="22" height="22" align="middle" border="0" />
{t}Descriptions{/t}&nbsp;&nbsp;
<img src="lang/de/ocstyle/images/action/16x16-adddesc.png" width="16" height="16" align="middle" border="0" alt="" >
<span style="font-weight: 400;font-size: small;">[<a href="newdesc.php?cacheid={cacheid_urlencode}">{t}Add description in another language{/t}</a>]</span>
<span style="font-weight: 400;font-size: small;">[<a href="newdesc.php?cacheid={cacheid_urlencode}" onclick="testListingModified(this)" >{t}Add description in another language{/t}</a>]</span>
</p>
</div>
</td>
@@ -281,7 +296,7 @@ function toggleAttr(id)
<img src="lang/de/ocstyle/images/description/22x22-image.png" width="22" height="22" align="middle" border="0" />
{t}Pictures{/t}&nbsp;&nbsp;
<img src="lang/de/ocstyle/images/action/16x16-addimage.png" width="16" height="16" align="middle" border="0" />
<span style="font-weight: 400;font-size: small;">[<!-- Ocprop >> --><a href="picture.php?action=add&cacheuuid={cacheuuid_urlencode}">{t}Upload a picture{/t}</a>]</span>
<span style="font-weight: 400;font-size: small;">[<!-- Ocprop >> --><a href="picture.php?action=add&cacheuuid={cacheuuid_urlencode}" onclick="testListingModified(this)" >{t}Upload a picture{/t}</a>]</span>
</p>
</div>
</td>
@@ -296,7 +311,7 @@ function toggleAttr(id)
<p class="content-title-noshade-size2">
<img src="resource2/ocstyle/images/description/20x20-compass.png" align="middle" border="0" />
{t}Additional waypoints{/t}&nbsp;&nbsp;
<span style="font-weight: 400;font-size: small;">[<a href="childwp.php?cacheid={cacheid_urlencode}">{t}Add a waypoint{/t}</a>]</span>
<span style="font-weight: 400;font-size: small;">[<a href="childwp.php?cacheid={cacheid_urlencode}" onclick="testListingModified(this)" >{t}Add a waypoint{/t}</a>]</span>
</p>
</div>
</td>
@@ -324,9 +339,9 @@ function toggleAttr(id)
<tr>
<td>{t}Hidden since:{/t}</td><!-- << Ocprop -->
<td>
<input class="input20" type="text" name="hidden_day" maxlength="2" value="{date_day}"/>.
<input class="input20" type="text" name="hidden_month" maxlength="2" value="{date_month}"/>.
<input class="input40" type="text" name="hidden_year" maxlength="4" value="{date_year}"/>&nbsp;
<input class="input20" type="text" name="hidden_day" maxlength="2" value="{date_day}" onchange="setListingModified()" />.
<input class="input20" type="text" name="hidden_month" maxlength="2" value="{date_month}" onchange="setListingModified()" />.
<input class="input40" type="text" name="hidden_year" maxlength="4" value="{date_year}" onchange="setListingModified()" />&nbsp;
{date_message}
&nbsp;
<img src="lang/de/ocstyle/images/misc/hint.gif" border="0" width="15" height="11" alt="{t}Notice{/t}" title="{t}Notice{/t}" />
@@ -339,7 +354,7 @@ function toggleAttr(id)
<tr><td class="spacer" colspan="2"></td></tr>
<tr>
<td><nobr>{t}Password for 'found' logs:{/t}</nobr></td>
<td><input class="input100" type="text" name="log_pw" value="{log_pw}" maxlength="20"/> &nbsp; {t}(leave blank for no password){/t}</td>
<td><input class="input100" type="text" name="log_pw" value="{log_pw}" maxlength="20" onchange="setListingModified()" /> &nbsp; {t}(leave blank for no password){/t}</td>
</tr>
<tr>
<td class="help" colspan="2">
@@ -350,11 +365,11 @@ function toggleAttr(id)
<tr><td class="spacer" colspan="2"></td></tr>
<tr>
<td><nobr><label for="showlists">{t}Show all cache lists{/t}</label></nobr></td>
<td><input type="checkbox" id="showlists" name="showlists" value="1" {showlists_checked} /></td>
<td><input type="checkbox" id="showlists" name="showlists" value="1" {showlists_checked} onchange="setListingModified()" /></td>
</tr>
<tr>
<td><nobr><label for="protect_old_coords">{t}Protect old coordinates{/t}</label></nobr></td>
<td><input type="checkbox" id="protect_old_coords" name="protect_old_coords" value="1" {protectcoords_checked} /></td>
<td><input type="checkbox" id="protect_old_coords" name="protect_old_coords" value="1" {protectcoords_checked} onchange="setListingModified()" /></td>
</tr>

<tr><td class="spacer" colspan="2"></td></tr>
Oops, something went wrong.

0 comments on commit eabc2ab

Please sign in to comment.
You can’t perform that action at this time.