Skip to content
Permalink
Browse files

reasonable language preferences for cachedesc download; fixes #852

  • Loading branch information...
following5 committed Sep 20, 2015
1 parent 7ce3d91 commit fab2d7fa2597a725a9822f7b09cd129a5f06525c
@@ -184,7 +184,7 @@ function search_output()
`cache_location`.`adm2` `state`, `caches`.`wp_oc` `waypoint`, `caches`.`date_hidden` `date_hidden`, `caches`.`name` `name`,
`caches`.`country` `country`, `countries`.`name` AS `country_name`, `caches`.`terrain` `terrain`, `caches`.`difficulty` `difficulty`, `caches`.`desc_languages` `desc_languages`,
`caches`.`size` `size`, `caches`.`type` `type`, `caches`.`status` `status`, `user`.`username` `username`, `caches`.`user_id` `userid`, `user`.`data_license`,
`cache_desc`.`desc` `desc`, `cache_desc`.`short_desc` `short_desc`, `cache_desc`.`hint` `hint`,
`cache_desc`.`desc` `desc`, `cache_desc`.`short_desc` `short_desc`, `cache_desc`.`hint` `hint`, `cache_desc`.`language` AS `desc_language`,
IFNULL(`stat_cache_logs`.`found`, 0) AS `found`
FROM &searchtmp
INNER JOIN `caches` ON &searchtmp.`cache_id`=`caches`.`cache_id`
@@ -196,6 +196,9 @@ function search_output()
while ($r = sql_fetch_array($rs))
{
if (strlen($r['desc_languages']) > 2)
$r = get_locale_desc($r);
$thisline = $gpxLine;
$lat = sprintf('%01.5f', $r['latitude']);
@@ -153,4 +153,44 @@ function search_text2sort($str, $gns_syntax=false)
return $str;
}
// select the preferable description language for the cache in $rCache
// and replace the desc texts in $rCache by the prefered description's data;
// see http://redmine.opencaching.de/issues/852
function get_locale_desc($rCache)
{
global $opt;
$desclangs = ','.$rCache['desc_languages'].',';
$desclang = $rCache['desc_language'];
if (strpos($desclangs, ','.$opt['template']['locale'].',') !== false)
$desclang = $opt['template']['locale'];
elseif (strpos($desclangs, ','.$opt['template']['default']['locale'].',') !== false)
$desclang = $opt['template']['default']['locale'];
elseif (strpos($desclangs, ','.$opt['template']['default']['fallback_locale'].',') !== false)
$desclang = $opt['template']['default']['fallback_locale'];
elseif (strpos($desclangs, ',EN,') !== false)
$desclang = 'EN';
if ($desclang != $rCache['desc_language'])
{
$rs = sql("
SELECT `desc`, `short_desc`, `hint`
FROM `cache_desc`
WHERE `cache_id`='&1' AND `language`='&2'",
$rCache['cacheid'], $desclang);
if ($r = sql_fetch_assoc($rs))
{
$rCache['desc'] = $r['desc'];
$rCache['short_desc'] = $r['short_desc'];
$rCache['hint'] = $r['hint'];
}
sql_free_result($rs);
}
return $rCache;
}
?>
@@ -68,6 +68,9 @@ function search_output()
while ($r = sql_fetch_array($rs))
{
if (strlen($r['desc_languages']) > 2)
$r = get_locale_desc($r);
$thisline = $txtLine;
$lat = sprintf('%01.5f', $r['latitude']);
@@ -114,6 +114,9 @@ function search_output()
while ($r = sql_fetch_array($rs))
{
if (strlen($r['desc_languages']) > 2)
$r = get_locale_desc($r);
$thisline = $xmlLine;
$lat = sprintf('%01.5f', $r['latitude']);
@@ -46,6 +46,7 @@
<p>Korrigiert (Bugfixes):</p>
<ul>
<li>sinnvolle Textkonvertierung beim Umschalten zwischen Text- und HTML-Editor (<a href="http://redmine.opencaching.de/issues/236">#236</a>)</li>
<li>GPX- und TXT-Download liefert Cachebeschreibungen möglichst in der gewählten Sprache (<a href="http://redmine.opencaching.de/issues/852">#852</a>)</li>
<li>HTML-Code in Logbenachrichtigungen beseitigt</li>
<li>&bdquo;An GPS-Gerät senden&ldquo; auf www.opencaching.it, www.opencachingspain.es und www.opencaching.fr repariert.</li>
</ul>
@@ -32,6 +32,7 @@
<p>Fixed:</p>
<ul>
<li>reasonable text conversions when switching between text and HTML editor (<a href="http://redmine.opencaching.de/issues/236">#236</a>)</li>
<li>GPX and TXT download will return cache descriptions preferably in the selected language (<a href="http://redmine.opencaching.de/issues/852">#852</a>)</li>
<li>removed HTML code from log notifications</li>
<li>Fixed &bdquo;Send to GPS devices&ldquo; at www.opencaching.it, www.opencachingspain.es and www.opencaching.fr.</li>
</ul>

0 comments on commit fab2d7f

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