Skip to content

Commit

Permalink
discard duplicate GC attributes in GPX; fixes #257
Browse files Browse the repository at this point in the history
  • Loading branch information
following5 committed Jul 9, 2013
1 parent 9ccecf1 commit 7c157ff
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions htdocs/lib/search.gpx.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -480,13 +480,22 @@
FROM `caches_attributes` FROM `caches_attributes`
INNER JOIN `cache_attrib` ON `cache_attrib`.`id`=`caches_attributes`.`attrib_id` INNER JOIN `cache_attrib` ON `cache_attrib`.`id`=`caches_attributes`.`attrib_id`
WHERE `caches_attributes`.`cache_id`=&1", $r['cacheid']); WHERE `caches_attributes`.`cache_id`=&1", $r['cacheid']);
$gc_ids = array();
while ($rAttrib = sql_fetch_array($rsAttributes)) while ($rAttrib = sql_fetch_array($rsAttributes))
{ {
$thisattribute = mb_ereg_replace('{attrib_id}', $rAttrib['gc_id'], $gpxAttributes); // Multiple OC attributes can be mapped to one GC attribute, either with
$thisattribute = mb_ereg_replace('{attrib_inc}', $rAttrib['gc_inc'], $thisattribute); // the same "inc"s or with different. Both may disturb applications, so we
$thisattribute = mb_ereg_replace('{attrib_name}', xmlentities($rAttrib['gc_name']), $thisattribute); // output each GC ID only once.
$attribentries .= $thisattribute . "\n"; if (!isset($gc_ids[$rAttrib['gc_id']]))
{
$thisattribute = mb_ereg_replace('{attrib_id}', $rAttrib['gc_id'], $gpxAttributes);
$thisattribute = mb_ereg_replace('{attrib_inc}', $rAttrib['gc_inc'], $thisattribute);
$thisattribute = mb_ereg_replace('{attrib_name}', xmlentities($rAttrib['gc_name']), $thisattribute);
$attribentries .= $thisattribute . "\n";
$gc_ids[$rAttrib['gc_id']] = true;
}
} }

mysql_free_result($rsAttributes); mysql_free_result($rsAttributes);
$thisline = mb_ereg_replace('{attributes}', $attribentries, $thisline); $thisline = mb_ereg_replace('{attributes}', $attribentries, $thisline);


Expand Down

0 comments on commit 7c157ff

Please sign in to comment.