Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing of translation in DB - part 1. #2320

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions editcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use src\Models\GeoCache\GeoCacheCommons;
use src\Models\Pictures\OcPicture;
use src\Models\ApplicationContainer;
use src\Models\GeoCache\WaypointCommons;

require_once(__DIR__.'/lib/common.inc.php');

Expand Down Expand Up @@ -946,17 +947,14 @@ function build_drop_seq($item_row, $selected_seq, $max_drop, $thisid, $drop_type
}

//Add Waypoint
$lang_db = I18n::getLangForDbTranslations('waypoint_type');

$cache_type = $cache_record['type'];
if ($cache_type != GeoCache::TYPE_MOVING) {
tpl_set_var('waypoints_start', '');
tpl_set_var('waypoints_end', '');
$eLang = XDb::xEscape($lang_db);
$wp_rs = XDb::xSql(
"SELECT `wp_id`, `type`, `longitude`, `latitude`, `desc`, `status`, `stage`,
`waypoint_type`.`$eLang` wp_type, waypoint_type.icon wp_icon
FROM `waypoints` INNER JOIN waypoint_type ON (waypoints.type = waypoint_type.id)
"SELECT `wp_id`, `type`, `longitude`, `latitude`, `desc`, `status`, `stage`
FROM `waypoints`
WHERE `cache_id`=? ORDER BY `stage`,`wp_id`", $cache_id);

if (XDb::xNumRows($wp_rs) != 0) {
Expand All @@ -968,16 +966,22 @@ function build_drop_seq($item_row, $selected_seq, $max_drop, $thisid, $drop_type
$waypoints .= '<th align="center" valign="middle" width="30"><b>' . tr('stage_wp') . '</b></th>';
}

$waypoints .= '<th width="32"><b>' . tr('symbol_wp') . '</b></th><th width="32"><b>' . tr('type_wp') . '</b></th><th width="32"><b>' . tr('coordinates_wp') . '</b></th><th><b>' . tr('describe_wp') . '</b></th><th width="22"><b>' . tr('status_wp') . '</b></th><th width="22"><b>' . tr('edit') . '</b></th><th width="22"><b>' . tr('delete') . '</b></th></tr>';
$waypoints .= '<th width="32"><b>' . tr('symbol_wp') . '</b></th>'.
'<th width="32"><b>' . tr('type_wp') . '</b></th>'.
'<th width="32"><b>' . tr('coordinates_wp') . '</b></th>'.
'<th><b>' . tr('describe_wp') . '</b></th>'.
'<th width="22"><b>' . tr('status_wp') . '</b></th>'.
'<th width="22"><b>' . tr('edit') . '</b></th>'.
'<th width="22"><b>' . tr('delete') . '</b></th></tr>';

while($wp_record = XDb::xFetchArray($wp_rs)){
$tmpline1 = $wpline;

$coords_lat = mb_ereg_replace(" ", "&nbsp;", htmlspecialchars(Coordinates::donNotUse_latToDegreeStr($wp_record['latitude']), ENT_COMPAT, 'UTF-8'));
$coords_lon = mb_ereg_replace(" ", "&nbsp;", htmlspecialchars(Coordinates::donNotUse_lonToDegreeStr($wp_record['longitude']), ENT_COMPAT, 'UTF-8'));

$tmpline1 = mb_ereg_replace('{wp_icon}', htmlspecialchars($wp_record['wp_icon'], ENT_COMPAT, 'UTF-8'), $tmpline1);
$tmpline1 = mb_ereg_replace('{type}', htmlspecialchars($wp_record['wp_type'], ENT_COMPAT, 'UTF-8'), $tmpline1);
$tmpline1 = mb_ereg_replace('{wp_icon}',WaypointCommons::getIcon($wp_record['type']), $tmpline1);
$tmpline1 = mb_ereg_replace('{type}', tr(WaypointCommons::typeTranslationKey($wp_record['type'])), $tmpline1);
$tmpline1 = mb_ereg_replace('{lon}', $coords_lon, $tmpline1);
$tmpline1 = mb_ereg_replace('{lat}', $coords_lat, $tmpline1);
$tmpline1 = mb_ereg_replace('{desc}', nl2br($wp_record['desc']), $tmpline1);
Expand Down
6 changes: 3 additions & 3 deletions editwp.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
$remove = 1;
}

$wp_rs = XDb::xSql("SELECT `wp_id`, `cache_id`, `type`, `longitude`, `latitude`, `desc`, `status`, `stage`,
`opensprawdzacz`, `waypoint_type`.`pl` `wp_type`, `waypoint_type`.`icon` `wp_icon`
FROM `waypoints` INNER JOIN waypoint_type ON (waypoints.type = waypoint_type.id) WHERE `wp_id`= ? ", $wp_id);
$wp_rs = XDb::xSql("SELECT `wp_id`, `cache_id`, `type`, `longitude`, `latitude`,
`desc`, `status`, `stage`, `opensprawdzacz`
FROM `waypoints` WHERE `wp_id`= ? ", $wp_id);

if ($wp_record = XDb::xFetchArray($wp_rs)) {
$cache_id = $wp_record['cache_id'];
Expand Down
18 changes: 7 additions & 11 deletions graphs/PieGraphustat.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use src\Libs\JpGraph\JpGraphLoader;
use src\Utils\Database\XDb;
use src\Utils\I18n\I18n;
use src\Models\GeoCache\GeoCache;

require(__DIR__ . '/../lib/common.inc.php');

Expand All @@ -23,40 +24,35 @@
$y = array();
$x = array();

$lang_db = I18n::getLangForDbTranslations('cache_type');

if ($tit == "cc") {
// Ustawic sprawdzanie jezyka w cache_type.pl !!!!
$rsCreateCachesYear = XDb::xSql(
"SELECT COUNT(`caches`.`type`) `count`, `cache_type`.`$lang_db` `type`
FROM `caches` INNER JOIN `cache_type` ON (`caches`.`type`=`cache_type`.`id`)
"SELECT COUNT(`caches`.`type`) `count`, `caches`.`type`
FROM `caches`
WHERE `user_id`= ? AND status <> 4 AND status <>5
GROUP BY `caches`.`type`
ORDER BY `count` DESC", $user_id);

if ($rsCreateCachesYear !== false) {
$xtitle = "";
while ($ry = XDb::xFetchArray($rsCreateCachesYear)) {
$y[] = $ry['count'];
$x[] = $ry['type'];
$x[] = tr(GeoCache::CacheTypeTranslationKey($ry['type']));
}
}
XDb::xFreeResults($rsCreateCachesYear);
}

if ($tit == "cf") {
$rsCachesFindYear = XDb::xSql(
"SELECT COUNT(`caches`.`type`) `count`, `cache_type`.`$lang_db` AS `type`
FROM `cache_logs`, caches INNER JOIN `cache_type` ON (`caches`.`type`=`cache_type`.`id`)
"SELECT COUNT(`caches`.`type`) `count`, `caches`.`type`
FROM `cache_logs`, caches
WHERE cache_logs.`deleted`=0 AND cache_logs.user_id=? AND cache_logs.`type`='1' AND cache_logs.`cache_id` = caches.cache_id
GROUP BY `caches`.`type`
ORDER BY `count` DESC", $user_id);

if ($rsCachesFindYear !== false) {
$xtitle = "";
while ($rfy = XDb::xFetchArray($rsCachesFindYear)) {
$y[] = $rfy['count'];
$x[] = $rfy['type'];
$x[] = tr(GeoCache::CacheTypeTranslationKey($rfy['type']));
}
}
XDb::xFreeResults($rsCachesFindYear);
Expand Down
98 changes: 48 additions & 50 deletions lib/search.gpx.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use src\Utils\I18n\I18n;
use src\Models\OcConfig\OcConfig;
use src\Models\ApplicationContainer;
use src\Models\GeoCache\Waypoint;

global $content, $bUseZip, $dbcSearch, $queryFilter;
require_once (__DIR__.'/common.inc.php');
Expand Down Expand Up @@ -98,23 +99,7 @@ function getPictures($cacheid, $picturescount)
<text>{text}</text>
</log>
';
$gpxWaypoints = '<wpt lat="{wp_lat}" lon="{wp_lon}">
<time>{time}</time>
<name>{waypoint} {wp_stage}</name>
<cmt>{desc}</cmt>
<desc>{wp_type_name}</desc>
<url>' . $absolute_server_URI . 'viewcache.php?wp={waypoint}</url>
<urlname>{waypoint} {wp_stage}</urlname>
<sym>{wp_type}</sym>
<type>Waypoint|{wp_type}</type>
<gsak:wptExtension xmlns:gsak="http://www.gsak.net/xmlv1/5">
<gsak:Parent>{waypoint}</gsak:Parent>
<gsak:Child_ByGSAK>false</gsak:Child_ByGSAK>
<gsak:Child_Flag>false</gsak:Child_Flag>
<gsak:Code>{waypoint} {wp_stage}</gsak:Code>
</gsak:wptExtension>
</wpt>
';


$gpxFoot = '</gpx>';

Expand Down Expand Up @@ -690,45 +675,58 @@ function getPictures($cacheid, $picturescount)

// Waypoints
$waypoints = '';
$rswp = XDb::xSql("SELECT `longitude`, `cache_id`, `latitude`,`desc`,`stage`, `type`, `status`,`waypoint_type`.`pl` `wp_type_name`
FROM `waypoints` INNER JOIN waypoint_type ON (waypoints.type = waypoint_type.id)
WHERE `waypoints`.`cache_id`= ?
ORDER BY `waypoints`.`stage`", $r['cacheid']);

while ($rwp = XDb::xFetchArray($rswp)) {
if ($rwp['status'] == 1) {
$gpxWaypoints = ' <wpt lat="{wp_lat}" lon="{wp_lon}">'. PHP_EOL .
' <time>{time}</time>'. PHP_EOL .
' <name>{waypoint} {wp_stage}</name>'. PHP_EOL .
' <cmt>{desc}</cmt>'. PHP_EOL .
' <desc>{wp_type_name}</desc>'. PHP_EOL .
' <url>' . $absolute_server_URI . 'viewcache.php?wp={waypoint}</url>'. PHP_EOL .
' <urlname>{waypoint} {wp_stage}</urlname>'. PHP_EOL .
' <sym>{wp_type}</sym>'. PHP_EOL .
' <type>Waypoint|{wp_type}</type>'. PHP_EOL .
' <gsak:wptExtension xmlns:gsak="http://www.gsak.net/xmlv1/5">'. PHP_EOL .
' <gsak:Parent>{waypoint}</gsak:Parent>'. PHP_EOL .
' <gsak:Child_ByGSAK>false</gsak:Child_ByGSAK>'. PHP_EOL .
' <gsak:Child_Flag>false</gsak:Child_Flag>'. PHP_EOL .
' <gsak:Code>{waypoint} {wp_stage}</gsak:Code>'. PHP_EOL .
' </gsak:wptExtension>'. PHP_EOL .
' </wpt>'. PHP_EOL;
$cacheWps = Waypoint::GetWaypointsForCacheId($r['cacheid']);
foreach ($cacheWps as $wp) {
if ($wp->getStatus() == Waypoint::STATUS_VISIBLE) {
$thiswp = $gpxWaypoints;
$lat = sprintf('%01.5f', $rwp['latitude']);
$lat = sprintf('%01.5f', $wp->getCoordinates()->getLatitude());
$thiswp = str_replace('{wp_lat}', $lat, $thiswp);
$lon = sprintf('%01.5f', $rwp['longitude']);
$lon = sprintf('%01.5f', $wp->getCoordinates()->getLongitude());
$thiswp = str_replace('{wp_lon}', $lon, $thiswp);
$thiswp = str_replace('{waypoint}', $waypoint, $thiswp);
$thiswp = str_replace('{cacheid}', $rwp['cache_id'], $thiswp);

$thiswp = str_replace('{waypoint}', $r['waypoint'], $thiswp);
$thiswp = str_replace('{cacheid}', $r['cacheid'], $thiswp);
$thiswp = str_replace('{time}', $time, $thiswp);
$thiswp = str_replace('{wp_type_name}', $rwp['wp_type_name'], $thiswp);
if ($rwp['stage'] != 0) {
$thiswp = str_replace('{wp_stage}', " " . tr('stage_wp') . ": " . $rwp['stage'], $thiswp);
$thiswp = str_replace('{wp_type_name}', tr($wp->getTypeTranslationKey()), $thiswp);
if ($wp->getStage() != 0) {
$thiswp = str_replace('{wp_stage}', " " . tr('stage_wp') . ": " . $wp->getStage(), $thiswp);
} else {
$thiswp = str_replace('{wp_stage}', $rwp['wp_type_name'], $thiswp);
}
$thiswp = str_replace('{desc}', cleanup_text($rwp['desc']), $thiswp);
if ($rwp['type'] == 5) {
$thiswp = str_replace('{wp_type}', "Parking Area", $thiswp);
}
if ($rwp['type'] == 1) {
$thiswp = str_replace('{wp_type}', "Flag, Green", $thiswp);
}
if ($rwp['type'] == 2) {
$thiswp = str_replace('{wp_type}', "Flag, Green", $thiswp);
}
if ($rwp['type'] == 3) {
$thiswp = str_replace('{wp_type}', "Flag, Red", $thiswp);
}
if ($rwp['type'] == 4) {
$thiswp = str_replace('{wp_type}', "Circle with X", $thiswp);
$thiswp = str_replace('{wp_stage}', tr($wp->getTypeTranslationKey()), $thiswp);
}
if ($rwp['type'] == 6) {
$thiswp = str_replace('{wp_type}', "Trailhead", $thiswp);
$thiswp = str_replace('{desc}', cleanup_text($wp->getDescription()), $thiswp);
switch ($wp->getType()) {
case Waypoint::TYPE_PARKING:
$thiswp = str_replace('{wp_type}', "Parking Area", $thiswp);
break;
case Waypoint::TYPE_PHYSICAL:
case Waypoint::TYPE_VIRTUAL:
$thiswp = str_replace('{wp_type}', "Flag, Green", $thiswp);
break;
case Waypoint::TYPE_FINAL:
$thiswp = str_replace('{wp_type}', "Flag, Red", $thiswp);
break;
case Waypoint::TYPE_INTERESTING:
$thiswp = str_replace('{wp_type}', "Circle with X", $thiswp);
break;
case Waypoint::TYPE_TRAILHEAD:
$thiswp = str_replace('{wp_type}', "Trailhead", $thiswp);
break;
}
$waypoints .= $thiswp;
}
Expand Down
37 changes: 15 additions & 22 deletions lib/search.gpxgc.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use src\Models\GeoCache\CacheNote;
use src\Models\GeoCache\GeoCacheCommons;
use src\Models\GeoCache\GeoCacheLog;
use src\Models\GeoCache\Waypoint;
use src\Utils\I18n\I18n;
use src\Utils\Text\Validator;
use src\Models\OcConfig\OcConfig;
Expand Down Expand Up @@ -520,34 +521,26 @@

// Waypoints
$waypoints = '';

$rswp = XDb::xSql(
"SELECT `longitude`, `cache_id`, `latitude`,`desc`,`stage`, `type`, `status`,`waypoint_type`." . $language . " `wp_type_name`
FROM `waypoints`
INNER JOIN waypoint_type ON (waypoints.type = waypoint_type.id)
WHERE `waypoints`.`cache_id`=?
ORDER BY `waypoints`.`stage`",
$r['cacheid']);

while ($rwp = XDb::xFetchArray($rswp)) {
if ($rwp['status'] == 1) {
$cacheWps = Waypoint::GetWaypointsForCacheId($r['cacheid']);
foreach ($cacheWps as $wp) {
if ($wp->getStatus() == Waypoint::STATUS_VISIBLE) {
$thiswp = $gpxWaypoints;
$lat = sprintf('%01.5f', $rwp['latitude']);
$lat = sprintf('%01.5f', $wp->getCoordinates()->getLatitude());
$thiswp = str_replace('{wp_lat}', $lat, $thiswp);
$lon = sprintf('%01.5f', $rwp['longitude']);
$lon = sprintf('%01.5f', $wp->getCoordinates()->getLongitude());
$thiswp = str_replace('{wp_lon}', $lon, $thiswp);
$thiswp = str_replace('{waypoint}', $waypoint, $thiswp);
$thiswp = str_replace('{cacheid}', $rwp['cache_id'], $thiswp);
$thiswp = str_replace('{waypoint}', $r['waypoint'], $thiswp);
$thiswp = str_replace('{cacheid}', $r['cacheid'], $thiswp);
$thiswp = str_replace('{time}', $time, $thiswp);
$thiswp = str_replace('{wp_type_name}', cleanup_text($rwp['wp_type_name']), $thiswp);
if ($rwp['stage'] != 0) {
$thiswp = str_replace('{wp_stage}', " " . cleanup_text(tr('stage_wp')) . ": " . $rwp['stage'], $thiswp);
$thiswp = str_replace('{wp_type_name}', cleanup_text(tr($wp->getTypeTranslationKey())), $thiswp);
if ($wp->getStage() != 0) {
$thiswp = str_replace('{wp_stage}', " " . cleanup_text(tr('stage_wp')) . ": " . $wp->getStage(), $thiswp);
} else {
$thiswp = str_replace('{wp_stage}', $rwp['wp_type_name'], $thiswp);
$thiswp = str_replace('{wp_stage}', tr($wp->getTypeTranslationKey()), $thiswp);
}
$thiswp = str_replace('{desc}', xmlentities(cleanup_text($rwp['desc'])), $thiswp);
if (isset($wptType[$rwp['type']]))
$thiswp = str_replace('{wp_type}', $wptType[$rwp['type']], $thiswp);
$thiswp = str_replace('{desc}', xmlentities(cleanup_text($wp->getDescription())), $thiswp);
if (isset($wptType[$wp->getType()]))
$thiswp = str_replace('{wp_type}', $wptType[$wp->getType()], $thiswp);
else
$thiswp = str_replace('{wp_type}', $wptType[0], $thiswp);
$waypoints .= $thiswp;
Expand Down
Loading