Skip to content
Permalink
Browse files

translated KML and TXT export data; updates #817

and
- unified English cache type names
- consolidated some cache type icon code
  • Loading branch information...
following5 committed Sep 2, 2015
1 parent f3c8a5b commit 99ec29b95cf7c4dc53f10c6da4ca70caf7ba8e90
@@ -562,6 +562,12 @@ function dbv_134() // fix removed cache list node IDs
sql("UPDATE `removed_objects` SET `node`='&1' WHERE `type`=8 AND `node`=0", $opt['logic']['node']['id']);
}
function dbv_135() // move KML cache type names from search.kml.inc.php to database
{
if (!sql_field_exists('cache_type','kml_name'))
sql("ALTER TABLE `cache_type` ADD COLUMN `kml_name` varchar(10) NOT NULL");
}
// When adding new mutations, take care that they behave well if run multiple
// times. This improves robustness of database versioning.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -11,6 +11,7 @@ CREATE TABLE `cache_type` (
`icon_large` varchar(60) NOT NULL,
`short2` varchar(15) NOT NULL,
`short2_trans_id` int(10) NOT NULL,
`kml_name` varchar(10) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='static content' ;
@@ -718,7 +718,7 @@ function getWaypoints($cacheid)
//build typeoptions
$types = '';
$rsTypes = sql("SELECT `cache_type`.`id`, IFNULL(`sys_trans_text`.`text`, `cache_type`.`name`) AS `name`
$rsTypes = sql("SELECT `cache_type`.`id`, IFNULL(`sys_trans_text`.`text`, `cache_type`.`en`) AS `name`
FROM `cache_type`
LEFT JOIN `sys_trans` ON `cache_type`.`trans_id`=`sys_trans`.`id`
LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND
@@ -7,70 +7,47 @@
function getCacheIcon($user_id, $cache_id, $cache_status, $cache_userid, $iconname)
{
$cacheicon_searchable = false;
$cacheicon_type = "";
$inactive = false;
$iconname = mb_eregi_replace("cache/", "", $iconname); // for old cache_type table contents
$iconext = "." . mb_eregi_replace("^.*\.", "", $iconname);
$iconname = mb_eregi_replace("\..*", "", $iconname);
// mark if found
if(isset($user_id))
// add status
switch ($cache_status)
{
$found = 0;
$resp = sqll("SELECT `type` FROM `cache_logs` WHERE `cache_id`='&1' AND `user_id`='&2' ORDER BY `type`", $cache_id, $user_id);
while($row = sql_fetch_assoc($resp))
{
if($found <= 0)
{
switch($row['type'])
{
case 1:
case 7:
$found = $row['type'];
$cacheicon_type = "-found";
$inactive = true;
break;
case 2:
$found = $row['type'];
$cacheicon_type = "-dnf";
break;
}
}
}
case 1: $iconname .= "-s"; break;
case 2: $iconname .= "-n"; break;
case 3: $iconname .= "-a"; break;
case 4: $iconname .= "-a"; break;
case 5: $iconname .= "-s"; break; // fix for RT ticket #3403
case 6: $iconname .= "-a"; break;
case 7: $iconname .= "-a"; break;
}
if($cache_userid == $user_id)
// mark if (not) found
if ($user_id)
{
$cacheicon_type = "-owner";
$inactive = true;
switch($cache_status)
if ($cache_userid == $user_id)
{
case 1: $cacheicon_searchable = "-s"; break;
case 2: $cacheicon_searchable = "-n"; break;
case 3: $cacheicon_searchable = "-a"; break;
case 4: $cacheicon_searchable = "-a"; break;
$iconname .= "-owner";
}
}
else
{
switch($cache_status)
else
{
case 1: $cacheicon_searchable = "-s"; break;
case 2: $inactive = true; $cacheicon_searchable = "-n"; break;
case 3: $inactive = true; $cacheicon_searchable = "-a"; break;
case 4: $inactive = true; $cacheicon_searchable = "-a"; break;
$logtype = sql_value_slave("
SELECT `type`
FROM `cache_logs`
WHERE `cache_id`='&1' AND `user_id`='&2' AND `type` IN (1,2,7)
ORDER BY `type`
LIMIT 1",
0, $cache_id, $user_id);
if ($logtype == 1 || $logtype == 7)
$iconname .= '-found';
elseif ($logtype == 2)
$iconname .= '-dnf';
}
}
// cacheicon
$iconname = mb_eregi_replace("\..*", "", $iconname);
$iconname .= $cacheicon_searchable . $cacheicon_type . ".gif";
return array($iconname, $inactive);
return $iconname . $iconext;
}
function getSmallCacheIcon($iconname)
{
$iconname = mb_eregi_replace('([^/]+)$', '16x16-\1', $iconname);
return $iconname;
}
?>
@@ -56,7 +56,7 @@ static function CreateCacheFile()
fwrite($f, 'labels::addLabels("cache_status", "' . str_replace('"', '\\"', serialize($a)) . '");' . "\n");
$a = array();
$rs = sql("SELECT `cache_type`.`id`, IFNULL(`sys_trans_text`.`text`, `cache_type`.`name`) AS `name`
$rs = sql("SELECT `cache_type`.`id`, IFNULL(`sys_trans_text`.`text`, `cache_type`.`en`) AS `name`
FROM `cache_type`
LEFT JOIN `sys_trans` ON `cache_type`.`trans_id`=`sys_trans`.`id` AND `cache_type`.`name`=`sys_trans`.`text`
LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'",
@@ -9,6 +9,8 @@
****************************************************************************/
require_once("lib2/logic/cacheIcon.inc.php");
$search_output_file_download = false;
$sAddFields .= ', `caches`.`name`, `caches`.`difficulty`, `caches`.`terrain`,
@@ -202,50 +204,4 @@ function dateDiff($interval, $dateTimeBegin, $dateTimeEnd)
}
function getCacheIcon($user_id, $cache_id, $cache_status, $cache_userid, $iconname)
{
$iconname = mb_eregi_replace("cache/", "", $iconname);
$iconext = "." . mb_eregi_replace("^.*\.", "", $iconname);
$iconname = mb_eregi_replace("\..*", "", $iconname);
// add status
switch ($cache_status)
{
case 1: $iconname .= "-s"; break;
case 2: $iconname .= "-n"; break;
case 3: $iconname .= "-a"; break;
case 4: $iconname .= "-a"; break;
case 5: $iconname .= "-s"; break; // fix for RT ticket #3403
case 6: $iconname .= "-a"; break;
case 7: $iconname .= "-a"; break;
}
// mark if (not) found
if ($user_id)
{
if ($cache_userid == $user_id)
{
$iconname .= "-owner";
}
else
{
$logtype = sql_value_slave("
SELECT `type`
FROM `cache_logs`
WHERE `cache_id`='&1' AND `user_id`='&2' AND `type` IN (1,2,7)
ORDER BY `type`
LIMIT 1",
0, $cache_id, $user_id);
if ($logtype == 1 || $logtype == 7)
$iconname .= '-found';
elseif ($logtype == 2)
$iconname .= '-dnf';
}
}
return $iconname . $iconext;
}
?>
@@ -11,16 +11,16 @@
$content_type_plain = 'vnd.google-earth.kml';
$content_type_zipped = 'vnd.google-earth.kmz';
function search_output()
{
global $opt;
global $state_temporarily_na, $state_archived, $state_locked;
global $t_showdesc, $t_by, $t_type, $t_size, $t_difficulty, $t_terrain;
$kmlLine =
'
<Placemark>
<description><![CDATA[<a href="'.$opt['page']['absolute_url'].'viewcache.php?cacheid={cacheid}">Beschreibung ansehen</a><br>Von {username}<br>&nbsp;<br><table cellspacing="0" cellpadding="0" border="0"><tr><td>{typeimgurl} </td><td>Art: {type}<br>Größe: {size}</td></tr><tr><td colspan="2">Schwierigkeit: {difficulty} von 5.0<br>Gelände: {terrain} von 5.0</td></tr></table>]]></description>
<description><![CDATA['.$t_by.' {username}<br><br><a href="'.$opt['page']['absolute_url'].'viewcache.php?cacheid={cacheid}">'.$t_showdesc.'</a><br>&nbsp;<br><table cellspacing="0" cellpadding="0" border="0"><tr><td>{typeimgurl} </td><td>'.$t_type.' {type}<br>'.$t_size.' {size}</td></tr><tr><td colspan="2">'.$t_difficulty.'<br>'.$t_terrain.'</td></tr></table>]]></description>
<name>{name}{archivedflag}</name>
<LookAt>
<longitude>{lon}</longitude>
@@ -33,7 +33,7 @@ function search_output()
<Point>
<coordinates>{lon},{lat},0</coordinates>
</Point>
<Snippet>D: {difficulty}/T: {terrain} {size} von {username}</Snippet>
<Snippet>D: {difficulty}/T: {terrain} {size} '.$t_by.' {username}</Snippet>
</Placemark>
';
@@ -62,18 +62,7 @@ function search_output()
append_output($kmlDetailHead);
/*
wp
name
username
type
size
lon
lat
icon
*/
$rs = sql_slave('
$rs = sql_slave("
SELECT SQL_BUFFER_RESULT
&searchtmp.`cache_id` `cacheid`,
&searchtmp.`longitude`,
@@ -82,72 +71,29 @@ function search_output()
`caches`.`date_hidden`,
`caches`.`name`,
`caches`.`status`,
`cache_type`.`de` `typedesc`,
`cache_size`.`de` `sizedesc`,
IFNULL(`stt_type`.`text`, `cache_type`.`en`) `typedesc`,
`cache_type`.`kml_name`,
`cache_type`.`icon_large`,
IFNULL(`stt_size`.`text`, `cache_size`.`en`) `sizedesc`,
`caches`.`terrain`,
`caches`.`difficulty`,
`user`.`username`
FROM
&searchtmp,
`caches`,
`cache_type`,
`cache_size`,
`user`
WHERE
&searchtmp.`cache_id`=`caches`.`cache_id` AND
&searchtmp.`type`=`cache_type`.`id` AND
&searchtmp.`size`=`cache_size`.`id` AND
&searchtmp.`user_id`=`user`.`user_id`');
FROM &searchtmp
JOIN `caches` ON &searchtmp.`cache_id`=`caches`.`cache_id`
JOIN `cache_type` ON &searchtmp.`type`=`cache_type`.`id`
JOIN `cache_size` ON &searchtmp.`type`=`cache_size`.`id`
LEFT JOIN `user` ON &searchtmp.`user_id`=`user`.`user_id`
LEFT JOIN `sys_trans_text` `stt_type` ON `stt_type`.`trans_id`=`cache_type`.`trans_id`
LEFT JOIN `sys_trans_text` `stt_size` ON `stt_size`.`trans_id`=`cache_size`.`trans_id`
WHERE `stt_type`.`lang`='&1' and `stt_size`.`lang`='&1'",
$opt['template']['locale']);
while ($r = sql_fetch_array($rs))
{
$thisline = $kmlLine;
$typeimgurl = '<img src="http://www.opencaching.de/resource2/'.$style.'/images/cacheicon/'.$r['icon_large'].'" alt="'.$r['typedesc'].'" title="'.$r['typedesc'].'" />';
// icon suchen
switch ($r['type'])
{
case 2:
$icon = 'tradi';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/'.$style.'/images/cacheicon/traditional.gif" alt="Normaler Cache" title="Normaler Cache" />';
break;
case 3:
$icon = 'multi';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/'.$style.'/images/cacheicon/multi.gif" alt="Multicache" title="Multicache" />';
break;
case 4:
$icon = 'virtual';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/'.$style.'/images/cacheicon/virtual.gif" alt="virtueller Cache" title="virtueller Cache" />';
break;
case 5:
$icon = 'webcam';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/'.$style.'/images/cacheicon/webcam.gif" alt="Webcam Cache" title="Webcam Cache" />';
break;
case 6:
$icon = 'event';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/'.$style.'/images/cacheicon/event.gif" alt="Event Cache" title="Event Cache" />';
break;
case 7:
$icon = 'mystery';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/'.$style.'/images/cacheicon/mystery.gif" alt="Rätselcache" title="Event Cache" />';
break;
case 8:
$icon = 'mathe';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/'.$style.'/images/cacheicon/mathe.gif" alt="Mathe-/Physik-Cache" title="Event Cache" />';
break;
case 9:
$icon = 'moving';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/'.$style.'/images/cacheicon/moving.gif" alt="Moving Cache" title="Event Cache" />';
break;
case 10:
$icon = 'drivein';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/'.$style.'/images/cacheicon/drivein.gif" alt="Drive-In Cache" title="Event Cache" />';
break;
default:
$icon = 'other';
$typeimgurl = '<img src="http://www.opencaching.de/resource2/'.$style.'/images/cacheicon/unknown.gif" alt="unbekannter Cachetyp" title="unbekannter Cachetyp" />';
break;
}
$thisline = mb_ereg_replace('{icon}', $icon, $thisline);
$thisline = mb_ereg_replace('{icon}', $r['kml_name'], $thisline);
$thisline = mb_ereg_replace('{typeimgurl}', $typeimgurl, $thisline);
$lat = sprintf('%01.5f', $r['latitude']);
Oops, something went wrong.

0 comments on commit 99ec29b

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