203 lines
11 KiB
PHP
203 lines
11 KiB
PHP
<?
|
|
|
|
namespace okapi\services\caches\formatters\gpx;
|
|
|
|
use okapi\Okapi;
|
|
|
|
echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
|
|
|
|
?>
|
|
<gpx xmlns="http://www.topografix.com/GPX/1/0" version="1.0" creator="OKAPI r<?= $vars['installation']['okapi_revision'] ?>"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="
|
|
http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd
|
|
http://www.opencaching.com/xmlschemas/opencaching/1/0 http://www.opencaching.com/xmlschemas/opencaching/1/0/opencaching.xsd
|
|
http://www.groundspeak.com/cache/1/0/1 http://www.groundspeak.com/cache/1/0/1/cache.xsd
|
|
http://geocaching.com.au/geocache/1 http://geocaching.com.au/geocache/1/geocache.xsd
|
|
http://www.gsak.net/xmlv1/5 http://www.gsak.net/xmlv1/5/gsak.xsd
|
|
">
|
|
<name><?= $vars['installation']['site_name'] ?> Geocache Search Results</name>
|
|
<desc><?= $vars['installation']['site_name'] ?> Geocache Search Results, downloaded via OKAPI - <?= $vars['installation']['okapi_base_url'] . ($vars['alt_wpts'] && $vars['ns_gsak'] ? ' (HasChildren)' : '') ?></desc>
|
|
<author><?= $vars['installation']['site_name'] ?></author>
|
|
<url><?= $vars['installation']['site_url'] ?></url>
|
|
<urlname><?= $vars['installation']['site_name'] ?></urlname>
|
|
<time><?= date('c') ?></time>
|
|
<? foreach ($vars['caches'] as $c) { ?>
|
|
<? if ($c == null) continue; /* This happens when there is an invalid code in cache_codes */ ?>
|
|
<? list($lat, $lon) = explode("|", $c['location']); ?>
|
|
<wpt lat="<?= $lat ?>" lon="<?= $lon ?>">
|
|
<time><?= $c['date_created'] ?></time>
|
|
<name><?= $c['code'] ?></name>
|
|
<desc><?= Okapi::xmlescape($c['name']) ?> <?= _("hidden by") ?> <?= Okapi::xmlescape($c['owner']['username']) ?> :: <?= ucfirst($c['type']) ?> Cache (<?= $c['difficulty'] ?>/<?= $c['terrain'] ?><? if ($c['size'] !== null) { echo "/".$c['size']; } else { echo "/X"; } ?>/<?= $c['rating'] ?>)</desc>
|
|
<url><?= $c['url'] ?></url>
|
|
<urlname><?= Okapi::xmlescape($c['name']) ?></urlname>
|
|
<sym><?= ($vars['mark_found'] && $c['is_found']) ? "Geocache Found" : "Geocache" ?></sym>
|
|
<type>Geocache|<?= $vars['cache_GPX_types'][$c['type']] ?></type>
|
|
<? if ($vars['ns_ground']) { /* Does user want us to include Groundspeak's <cache> element? */ ?>
|
|
<groundspeak:cache archived="<?= ($c['status'] == 'Archived') ? "True" : "False" ?>" available="<?= ($c['status'] == 'Available') ? "True" : "False" ?>" id="<?= $c['internal_id'] ?>" xmlns:groundspeak="http://www.groundspeak.com/cache/1/0/1">
|
|
<groundspeak:name><?= Okapi::xmlescape($c['name']) ?></groundspeak:name>
|
|
<groundspeak:placed_by><?= Okapi::xmlescape($c['owner']['username']) ?></groundspeak:placed_by>
|
|
<groundspeak:owner id="<?= $vars['user_uuid_to_internal_id'][$c['owner']['uuid']] ?>"><?= Okapi::xmlescape($c['owner']['username']) ?></groundspeak:owner>
|
|
<groundspeak:type><?= $vars['cache_GPX_types'][$c['type']] ?></groundspeak:type>
|
|
<groundspeak:container><?= $vars['cache_GPX_sizes'][$c['size2']] ?></groundspeak:container>
|
|
<? if ($vars['gc_attrs'] || $vars['gc_ocde_attrs']) { /* Does user want us to include groundspeak:attributes? */ ?>
|
|
<groundspeak:attributes>
|
|
<?
|
|
foreach ($c['gc_attrs'] as $gc_id => $gc_attr) {
|
|
print "<groundspeak:attribute id=\"".$gc_id."\" ";
|
|
print "inc=\"".$gc_attr['inc']."\">";
|
|
print Okapi::xmlescape($gc_attr['name']);
|
|
print "</groundspeak:attribute>";
|
|
}
|
|
?>
|
|
</groundspeak:attributes>
|
|
<? } ?>
|
|
<groundspeak:difficulty><?= $c['difficulty'] ?></groundspeak:difficulty>
|
|
<groundspeak:terrain><?= $c['terrain'] ?></groundspeak:terrain>
|
|
<groundspeak:long_description html="True">
|
|
<p>
|
|
<a href="<?= $c['url'] ?>"><?= Okapi::xmlescape($c['name']) ?></a>
|
|
<?= _("hidden by") ?> <a href='<?= $c['owner']['profile_url'] ?>'><?= Okapi::xmlescape($c['owner']['username']) ?></a><br/>
|
|
<? if ($vars['recommendations'] == 'desc:count') { /* Does user want us to include recommendations count? */ ?>
|
|
<?= sprintf(ngettext("%d recommendation", "%d recommendations", $c['recommendations']), $c['recommendations']) ?>
|
|
(<?= sprintf(ngettext("found %d time", "found %d times", $c['founds']), $c['founds']) ?>).
|
|
<? } ?>
|
|
<? if ($vars['trackables'] == 'desc:count') { /* Does user want us to include trackables count? */ ?>
|
|
<?= sprintf(ngettext("%d trackable", "%d trackables", $c['trackables_count']), $c['trackables_count']) ?>.
|
|
<? } ?>
|
|
</p>
|
|
<? if ((in_array('desc:text', $vars['my_notes'])) && ($c['my_notes'] != null)) { /* Does user want us to include personal notes? */ ?>
|
|
<p><b><?= _("Personal notes") ?>:</b><br><?= Okapi::xmlescape(nl2br($c['my_notes'])) ?></p>
|
|
<? } ?>
|
|
|
|
<? if (in_array('desc:text', $vars['attrs']) && count($c['attrnames']) > 0) { /* Does user want us to include attributes? */ ?>
|
|
<p><?= _("Attributes") ?>:</p>
|
|
<ul><li><?= implode("</li><li>", $c['attrnames']) ?></li></ul>
|
|
<? } ?>
|
|
<? if ($vars['trackables'] == 'desc:list' && count($c['trackables']) > 0) { /* Does user want us to include trackables list? */ ?>
|
|
<p><?= _("Trackables") ?>:</p>
|
|
<ul>
|
|
<? foreach ($c['trackables'] as $t) { ?>
|
|
<li><a href='<?= Okapi::xmlescape($t['url']) ?>'><?= Okapi::xmlescape($t['name']) ?></a> (<?= $t['code'] ?>)</li>
|
|
<? } ?>
|
|
</ul>
|
|
<? } ?>
|
|
<?= Okapi::xmlescape($c['description']) ?>
|
|
<? if ((strpos($vars['images'], "descrefs:") === 0) && count($c['images']) > 0) { /* Does user want us to include <img> references in cache descriptions? */
|
|
if ($vars['images'] == "descrefs:thumblinks") { ?>
|
|
<h2><?= _("Images") ?> (<?= count($c['images']) ?>)</h2>
|
|
<div>
|
|
<? foreach ($c['images'] as $img) { ?>
|
|
<div style='float:left; padding:6px'><a href='<?= Okapi::xmlescape($img['url']) ?>'><img src='<?= Okapi::xmlescape($img['thumb_url']) ?>'></a><br>
|
|
<?= Okapi::xmlescape($img['caption']) ?></div>
|
|
<? } ?>
|
|
</div>
|
|
<? } else {
|
|
# We will split images into two subcategories: spoilers and nonspoilers.
|
|
$spoilers = array();
|
|
$nonspoilers = array();
|
|
foreach ($c['images'] as $img)
|
|
if ($img['is_spoiler']) $spoilers[] = $img;
|
|
else $nonspoilers[] = $img;
|
|
?>
|
|
<? if (count($nonspoilers) > 0) { ?>
|
|
<h2><?= _("Images") ?> (<?= count($nonspoilers) ?>)</h2>
|
|
<? foreach ($nonspoilers as $img) { ?>
|
|
<p><img src='<?= Okapi::xmlescape($img['url']) ?>'><br>
|
|
<?= Okapi::xmlescape($img['caption']) ?></p>
|
|
<? } ?>
|
|
<? } ?>
|
|
<? if (count($spoilers) > 0 && $vars['images'] == 'descrefs:all') { ?>
|
|
<h2><?= _("Spoilers") ?> (<?= count($spoilers) ?>)</h2>
|
|
<? foreach ($spoilers as $img) { ?>
|
|
<p><img src='<?= Okapi::xmlescape($img['url']) ?>'><br>
|
|
<?= Okapi::xmlescape($img['caption']) ?></p>
|
|
<? } ?>
|
|
<? } ?>
|
|
<? } ?>
|
|
<? } ?>
|
|
<? if ((strpos($vars['images'], "ox:") === 0) && count($c['images']) > 0) { /* Include image descriptions (for ox:image numbers)? */ ?>
|
|
<p><?= _("Image descriptions") ?>:</p>
|
|
<ul>
|
|
<? foreach ($c['images'] as $no => $img) { ?>
|
|
<li><?= $img['unique_caption'] ?>. <?= Okapi::xmlescape($img['caption']) ?></li>
|
|
<? } ?>
|
|
</ul>
|
|
<? } ?>
|
|
<? if ($vars['protection_areas'] == 'desc:text' && count($c['protection_areas'])) { ?>
|
|
<p><?= _("The cache probably is located in the following protection areas:") ?></p>
|
|
<ul>
|
|
<? foreach($c['protection_areas'] as $protection_area) { ?>
|
|
<li><?= Okapi::xmlescape($protection_area['type'])." - ".Okapi::xmlescape($protection_area['name']) ?></li>
|
|
<? } ?>
|
|
</ul;>
|
|
<? } ?>
|
|
</groundspeak:long_description>
|
|
<groundspeak:encoded_hints><?= Okapi::xmlescape($c['hint2']) ?></groundspeak:encoded_hints>
|
|
<? if ((in_array('gc:personal_note', $vars['my_notes'])) && ($c['my_notes'] != null)) { /* Does user want us to include personal notes? -> Issue 294 */ ?>
|
|
<groundspeak:personal_note><?= Okapi::xmlescape($c['my_notes']) ?></groundspeak:personal_note>
|
|
<? } ?>
|
|
<? if ($vars['latest_logs']) { /* Does user want us to include latest log entries? */ ?>
|
|
<groundspeak:logs>
|
|
<? foreach ($c['latest_logs'] as $log) { ?>
|
|
<groundspeak:log id="<?= $log['internal_id'] ?>">
|
|
<groundspeak:date><?= $log['date'] ?></groundspeak:date>
|
|
<groundspeak:type><?= $log['type'] ?></groundspeak:type>
|
|
<groundspeak:finder id="<?= $vars['user_uuid_to_internal_id'][$log['user']['uuid']] ?>"><?= Okapi::xmlescape($log['user']['username']) ?></groundspeak:finder>
|
|
<groundspeak:text encoded="False"><?= $log['was_recommended'] ? "(*) ": "" ?><?= Okapi::xmlescape($log['comment']) ?></groundspeak:text>
|
|
</groundspeak:log>
|
|
<? } ?>
|
|
</groundspeak:logs>
|
|
<? } ?>
|
|
<? /* groundspeak:travelbugs - does it actually DO anything? WRTODO */ ?>
|
|
</groundspeak:cache>
|
|
<? } ?>
|
|
<? if ($vars['ns_ox']) { /* Does user want us to include Garmin's <opencaching> element? */ ?>
|
|
<ox:opencaching xmlns:ox="http://www.opencaching.com/xmlschemas/opencaching/1/0">
|
|
<ox:ratings>
|
|
<? if ($c['rating'] !== null) { ?><ox:awesomeness><?= $c['rating'] ?></ox:awesomeness><? } ?>
|
|
<ox:difficulty><?= $c['difficulty'] ?></ox:difficulty>
|
|
<? if ($c['oxsize'] !== null) { ?><ox:size><?= $c['oxsize'] ?></ox:size><? } ?>
|
|
<ox:terrain><?= $c['terrain'] ?></ox:terrain>
|
|
</ox:ratings>
|
|
<? if (in_array('ox:tags', $vars['attrs']) && count($c['attrnames']) > 0) { /* Does user want us to include ox:tags? */ ?>
|
|
<ox:tags><ox:tag><?= implode("</ox:tag><ox:tag>", $c['attrnames']) ?></ox:tag></ox:tags>
|
|
<? } ?>
|
|
<? if ((strpos($vars['images'], "ox:") === 0) && count($c['images']) > 0) { /* Does user want us to include ox:image references? */ ?>
|
|
<ox:images>
|
|
<? foreach ($c['images'] as $no => $img) { ?>
|
|
<ox:image>
|
|
<ox:name><?= $img['unique_caption'] ?>.jpg</ox:name>
|
|
<ox:size>0</ox:size>
|
|
<ox:required>false</ox:required>
|
|
<ox:spoiler><?= ($img['is_spoiler'] ? "true" : "false") ?></ox:spoiler>
|
|
</ox:image>
|
|
<? } ?>
|
|
</ox:images>
|
|
<? } ?>
|
|
</ox:opencaching>
|
|
<? } ?>
|
|
</wpt>
|
|
<? if ($vars['alt_wpts']) { ?>
|
|
<? foreach ($c['alt_wpts'] as $wpt) { ?>
|
|
<? list($lat, $lon) = explode("|", $wpt['location']); ?>
|
|
<wpt lat="<?= $lat ?>" lon="<?= $lon ?>">
|
|
<time><?= $c['date_created'] ?></time>
|
|
<name><?= Okapi::xmlescape($wpt['name']) ?></name>
|
|
<cmt><?= Okapi::xmlescape($wpt['description']) ?></cmt>
|
|
<desc><?= Okapi::xmlescape($wpt['type_name']) ?></desc>
|
|
<url><?= $c['url'] ?></url>
|
|
<urlname><?= Okapi::xmlescape($c['name']) ?></urlname>
|
|
<sym><?= $wpt['sym'] ?></sym>
|
|
<type>Waypoint|<?= $wpt['sym'] ?></type>
|
|
<? if ($vars['ns_gsak']) { ?>
|
|
<gsak:wptExtension xmlns:gsak="http://www.gsak.net/xmlv1/5">
|
|
<gsak:Parent><?= $c['code'] ?></gsak:Parent>
|
|
</gsak:wptExtension>
|
|
<? } ?>
|
|
</wpt>
|
|
<? } ?>
|
|
<? } ?>
|
|
<? } ?>
|
|
</gpx>
|