From a6a95e2d4babc92c5f6551fd3115c65c919c6e96 Mon Sep 17 00:00:00 2001 From: following Date: Tue, 26 Mar 2013 22:45:13 +0100 Subject: [PATCH] translate 'adm1' country names --- htdocs/index.php | 18 ++++++++++++------ htdocs/tops.php | 7 +++++-- htdocs/viewcache.php | 8 +++++--- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index a272e217..25098b59 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -99,19 +99,21 @@ `caches`.`cache_id` `cache_id`, `caches`.`name` `name`, `caches`.`date_hidden`, - `cache_location`.`adm1`, + IFNULL(`sys_trans_text`.`text`,`cache_location`.`adm1`) AS `adm1`, `cache_location`.`adm2`, `cache_location`.`adm3`, `cache_location`.`adm4` FROM `caches` INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id` LEFT JOIN `cache_location` ON `caches`.`cache_id`=`cache_location`.`cache_id` + LEFT JOIN `countries` ON `countries`.`short`=`cache_location`.`code1` + LEFT JOIN `sys_trans_text` ON `sys_trans_text`.`trans_id`=`countries`.`trans_id` AND `sys_trans_text`.`lang`='&2' WHERE `caches`.`country`='&1' AND `caches`.`date_hidden` >= curdate() AND `caches`.`type` = 6 AND `caches`.`status`=1 ORDER BY `date_hidden` ASC LIMIT 0, 10", - $sUserCountry); + $sUserCountry, $opt['template']['locale']); $tpl->assign_rs('events', $rs); sql_free_result($rs); @@ -122,18 +124,20 @@ `caches`.`name` `name`, `caches`.`date_created` `date_created`, `caches`.`type`, - `cache_location`.`adm1`, + IFNULL(`sys_trans_text`.`text`,`cache_location`.`adm1`) AS `adm1`, `cache_location`.`adm2`, `cache_location`.`adm3`, `cache_location`.`adm4` FROM `caches` INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id` LEFT JOIN `cache_location` ON `caches`.`cache_id`=`cache_location`.`cache_id` + LEFT JOIN `countries` ON `countries`.`short`=`cache_location`.`code1` + LEFT JOIN `sys_trans_text` ON `sys_trans_text`.`trans_id`=`countries`.`trans_id` AND `sys_trans_text`.`lang`='&2' WHERE `caches`.`country`='&1' AND `caches`.`type` != 6 AND `caches`.`status` = 1 ORDER BY `caches`.`date_created` DESC LIMIT 0, 10", - $sUserCountry); + $sUserCountry, $opt['template']['locale']); $tpl->assign_rs('newcaches', $rs); sql_free_result($rs); @@ -149,7 +153,7 @@ `caches`.`cache_id` AS `cache_id`, `caches`.`name` AS `name`, `caches`.`type`, - `cache_location`.`adm1`, + IFNULL(`sys_trans_text`.`text`,`cache_location`.`adm1`) AS `adm1`, `cache_location`.`adm2`, `cache_location`.`adm3`, `cache_location`.`adm4` @@ -157,6 +161,8 @@ INNER JOIN `caches` ON `caches`.`cache_id`=`cache_rating`.`cache_id` INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id` LEFT JOIN `cache_location` ON `cache_rating`.`cache_id`=`cache_location`.`cache_id` + LEFT JOIN `countries` ON `countries`.`short`=`cache_location`.`code1` + LEFT JOIN `sys_trans_text` ON `sys_trans_text`.`trans_id`=`countries`.`trans_id` AND `sys_trans_text`.`lang`='&2' WHERE `caches`.`country`='&1' AND `cache_rating`.`rating_date`>DATE_SUB(NOW(), INTERVAL 30 DAY) AND `caches`.`type`!=6 AND @@ -166,7 +172,7 @@ `dLastLog` DESC, `cache_id` DESC LIMIT 0, 10", - $sUserCountry); + $sUserCountry, $opt['template']['locale']); $tpl->assign_rs('topratings', $rs); sql_free_result($rs); diff --git a/htdocs/tops.php b/htdocs/tops.php index 16a6f61b..fad7e2c3 100644 --- a/htdocs/tops.php +++ b/htdocs/tops.php @@ -16,18 +16,21 @@ if (!$tpl->is_cached()) { - $rs = sql("SELECT `cache_location`.`adm1`, `cache_location`.`adm3`, + $rs = sql("SELECT IFNULL(`sys_trans_text`.`text`,`cache_location`.`adm1`) AS `adm1`, + `cache_location`.`adm3`, `rating_tops`.`rating` AS `idx`, `stat_caches`.`toprating` AS `ratings`, `stat_caches`.`found` AS `founds`, `caches`.`name`, `caches`.`wp_oc` AS `wpoc`, `user`.`username`, `user`.`user_id` AS `userid` FROM `rating_tops` INNER JOIN `caches` ON `rating_tops`.`cache_id`=`caches`.`cache_id` INNER JOIN `cache_location` ON `rating_tops`.`cache_id`=`cache_location`.`cache_id` + LEFT JOIN `countries` ON `countries`.`short`=`cache_location`.`code1` + LEFT JOIN `sys_trans_text` ON `sys_trans_text`.`trans_id`=`countries`.`trans_id` AND `sys_trans_text`.`lang`='&1' INNER JOIN `stat_caches` ON `rating_tops`.`cache_id`=`stat_caches`.`cache_id` INNER JOIN `user` ON `caches`.`user_id`=`user`.`user_id` ORDER BY `cache_location`.`adm1` ASC, `cache_location`.`adm3` ASC, `rating_tops`.`rating` DESC, - `caches`.`name` ASC"); + `caches`.`name` ASC", $opt['template']['locale']); $tpl->assign_rs('tops', $rs); sql_free_result($rs); } diff --git a/htdocs/viewcache.php b/htdocs/viewcache.php index 38521e67..c5b6a35a 100644 --- a/htdocs/viewcache.php +++ b/htdocs/viewcache.php @@ -97,7 +97,7 @@ function getChildWaypoints($cacheid) `caches`.`search_time` AS `searchtime`, `caches`.`way_length` AS `waylength`, `caches`.`country` AS `countryCode`, - IFNULL(`ttCountry`.`text`, `countries`.`name`) AS `country`, + IFNULL(`ttCountry`.`text`, `countries`.`name`) AS `country`, `caches`.`logpw` AS `logpw`, `caches`.`date_hidden` AS `datehidden`, `caches`.`wp_oc` AS `wpoc`, @@ -124,7 +124,7 @@ function getChildWaypoints($cacheid) IFNULL(`cache_visits`.`count`, 0) AS `visits`, `user`.`username` AS `username`, IFNULL(`cache_location`.`code1`, '') AS `code1`, - IFNULL(`cache_location`.`adm1`, '') AS `adm1`, + IFNULL(`trans2`.`text`, IFNULL(`cache_location`.`adm1`,'')) AS `adm1`, IFNULL(`cache_location`.`adm2`, '') AS `adm2`, IFNULL(`cache_location`.`adm3`, '') AS `adm3`, IFNULL(`cache_location`.`adm4`, '') AS `adm4` @@ -132,12 +132,14 @@ function getChildWaypoints($cacheid) INNER JOIN `user` ON `caches`.`user_id`=`user`.`user_id` INNER JOIN `cache_desc` ON `caches`.`cache_id`=`cache_desc`.`cache_id` AND `cache_desc`.`language`=PREFERED_LANG(`caches`.`desc_languages`, '&3') INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` + LEFT JOIN `cache_location` ON `caches`.`cache_id` = `cache_location`.`cache_id` LEFT JOIN `countries` ON `caches`.`country`=`countries`.`short` LEFT JOIN `sys_trans` AS `tCountry` ON `countries`.`trans_id`=`tCountry`.`id` AND `countries`.`name`=`tCountry`.`text` LEFT JOIN `sys_trans_text` AS `ttCountry` ON `tCountry`.`id`=`ttCountry`.`trans_id` AND `ttCountry`.`lang`='&2' + LEFT JOIN `countries` `c2` ON `c2`.`short`=`cache_location`.`code1` + LEFT JOIN `sys_trans_text` `trans2` ON `trans2`.`trans_id`=`c2`.`trans_id` AND `trans2`.`lang`='&2' LEFT JOIN `cache_visits` ON `cache_visits`.`cache_id`=`caches`.`cache_id` AND `user_id_ip`='0' LEFT JOIN `stat_caches` ON `caches`.`cache_id`=`stat_caches`.`cache_id` - LEFT JOIN `cache_location` ON `caches`.`cache_id` = `cache_location`.`cache_id` WHERE `caches`.`cache_id`='&1'", $cacheid, $opt['template']['locale'], $sPreferedDescLang, $login->userid); $rCache = sql_fetch_assoc($rs); sql_free_result($rs);