okapi r786: added geocaches.gc_code field
This commit is contained in:
@@ -799,7 +799,7 @@ class Okapi
|
|||||||
{
|
{
|
||||||
public static $data_store;
|
public static $data_store;
|
||||||
public static $server;
|
public static $server;
|
||||||
public static $revision = 781; # This gets replaced in automatically deployed packages
|
public static $revision = 786; # This gets replaced in automatically deployed packages
|
||||||
private static $okapi_vars = null;
|
private static $okapi_vars = null;
|
||||||
|
|
||||||
/** Get a variable stored in okapi_vars. If variable not found, return $default. */
|
/** Get a variable stored in okapi_vars. If variable not found, return $default. */
|
||||||
|
|||||||
@@ -19,7 +19,13 @@
|
|||||||
Selected fields will be included in the response.</p>
|
Selected fields will be included in the response.</p>
|
||||||
<p>Currently available fields:</p>
|
<p>Currently available fields:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><b>code</b> - unique code of the geocache,</li>
|
<li><b>code</b> - unique Opencaching code of the geocache,</li>
|
||||||
|
<li><p><b>gc_code</b> - geocaching.com code (GC code) of the geocache;
|
||||||
|
<b>null</b> if not crosslisted or unknown.</p>
|
||||||
|
<p>Please note that many cache owners do not provide this information.
|
||||||
|
It may be missing or wrong, or the GC listing may be inactive
|
||||||
|
(<a href='https://code.google.com/p/opencaching-api/issues/detail?id=195'>Discussion</a>).</p>
|
||||||
|
</li>
|
||||||
<li><b>name</b> - name of the geocache,</li>
|
<li><b>name</b> - name of the geocache,</li>
|
||||||
<li><b>names</b> - a dictionary (language code => plain-text string) of
|
<li><b>names</b> - a dictionary (language code => plain-text string) of
|
||||||
names of the geocache (at this time, there will be only one language,
|
names of the geocache (at this time, there will be only one language,
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class WebService
|
|||||||
'my_notes', 'trackables_count', 'trackables', 'alt_wpts', 'last_found',
|
'my_notes', 'trackables_count', 'trackables', 'alt_wpts', 'last_found',
|
||||||
'last_modified', 'date_created', 'date_hidden', 'internal_id', 'is_watched',
|
'last_modified', 'date_created', 'date_hidden', 'internal_id', 'is_watched',
|
||||||
'is_ignored', 'willattends', 'country', 'state', 'preview_image',
|
'is_ignored', 'willattends', 'country', 'state', 'preview_image',
|
||||||
'trip_time', 'trip_distance', 'attribution_note');
|
'trip_time', 'trip_distance', 'attribution_note','gc_code');
|
||||||
|
|
||||||
public static function call(OkapiRequest $request)
|
public static function call(OkapiRequest $request)
|
||||||
{
|
{
|
||||||
@@ -157,7 +157,7 @@ class WebService
|
|||||||
select
|
select
|
||||||
c.cache_id, c.name, c.longitude, c.latitude, c.listing_last_modified as last_modified,
|
c.cache_id, c.name, c.longitude, c.latitude, c.listing_last_modified as last_modified,
|
||||||
c.date_created, c.type, c.status, c.date_hidden, c.size, c.difficulty,
|
c.date_created, c.type, c.status, c.date_hidden, c.size, c.difficulty,
|
||||||
c.terrain, c.wp_oc, c.logpw, c.user_id,
|
c.terrain, c.wp_oc, c.wp_gc, c.logpw, c.user_id,
|
||||||
if(c.search_time=0, null, c.search_time) as trip_time,
|
if(c.search_time=0, null, c.search_time) as trip_time,
|
||||||
if(c.way_length=0, null, c.way_length) as trip_distance,
|
if(c.way_length=0, null, c.way_length) as trip_distance,
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ class WebService
|
|||||||
select
|
select
|
||||||
c.cache_id, c.name, c.longitude, c.latitude, c.last_modified,
|
c.cache_id, c.name, c.longitude, c.latitude, c.last_modified,
|
||||||
c.date_created, c.type, c.status, c.date_hidden, c.size, c.difficulty,
|
c.date_created, c.type, c.status, c.date_hidden, c.size, c.difficulty,
|
||||||
c.terrain, c.wp_oc, c.logpw, c.user_id,
|
c.terrain, c.wp_oc, c.wp_gc, c.logpw, c.user_id,
|
||||||
if(c.search_time=0, null, c.search_time) as trip_time,
|
if(c.search_time=0, null, c.search_time) as trip_time,
|
||||||
if(c.way_length=0, null, c.way_length) as trip_distance,
|
if(c.way_length=0, null, c.way_length) as trip_distance,
|
||||||
|
|
||||||
@@ -220,6 +220,14 @@ class WebService
|
|||||||
switch ($field)
|
switch ($field)
|
||||||
{
|
{
|
||||||
case 'code': $entry['code'] = $row['wp_oc']; break;
|
case 'code': $entry['code'] = $row['wp_oc']; break;
|
||||||
|
case 'gc_code':
|
||||||
|
// OC software allows entering anything here, and that's what users do.
|
||||||
|
// We do a formal verification so that only a valid GC code is returned:
|
||||||
|
if (preg_match('/^\s*[Gg][Cc][A-Za-z0-9]+\s*$/', $row['wp_gc']))
|
||||||
|
$entry['gc_code'] = strtoupper(trim($row['wp_gc']));
|
||||||
|
else
|
||||||
|
$entry['gc_code'] = null;
|
||||||
|
break;
|
||||||
case 'name': $entry['name'] = $row['name']; break;
|
case 'name': $entry['name'] = $row['name']; break;
|
||||||
case 'names': $entry['names'] = array(Settings::get('SITELANG') => $row['name']); break; // for the future
|
case 'names': $entry['names'] = array(Settings::get('SITELANG') => $row['name']); break; // for the future
|
||||||
case 'location': $entry['location'] = round($row['latitude'], 6)."|".round($row['longitude'], 6); break;
|
case 'location': $entry['location'] = round($row['latitude'], 6)."|".round($row['longitude'], 6); break;
|
||||||
|
|||||||
Reference in New Issue
Block a user