Merge remote-tracking branch 'upstream/master' into code-upgrade

Conflicts:
	htdocs/coordinates.php
	htdocs/lib2/logic/coordinate.class.php
This commit is contained in:
Markus Birth 2015-01-22 01:11:18 +01:00
commit 7379bf60b5
6 changed files with 44 additions and 0 deletions

View File

@ -110,6 +110,9 @@
$opt['lib']['garmin']['url'] = 'http://local.opencaching.de/';
$opt['lib']['garmin']['redirect'] = $opt['lib']['garmin']['url'] . 'garmin.php?redirect=1&cacheid={cacheid}';
// developer.what3words.com API Key
$opt['lib']['w3w']['apikey'] = 'YOURAPIKEY';
// other settings
$opt['page']['showdonations'] = true;
$opt['page']['showsocialmedia'] = true;

View File

@ -581,6 +581,9 @@
// (e.g. domain called without www. prefix) - must match domain of $opt['lib']['garmin']['url']
$opt['lib']['garmin']['redirect'] = 'http://www.site.org/garmin.php?redirect=1&cacheid={cacheid}';
// developer.what3words.com API key
$opt['lib']['w3w']['apikey'] = 'YOURAPIKEY';
// Google Maps API key
// http://code.google.com/intl/de/apis/maps/signup.html
$opt['lib']['google']['mapkey'] = array();

View File

@ -141,6 +141,9 @@
$opt['lib']['garmin']['key'] = '00112233445566778899AABBCCDDEEFF00';
$opt['lib']['garmin']['url'] = 'http://www.site.org/';
// developer.what3words.com API Key
$opt['lib']['w3w']['apikey'] = 'YOURAPIKEY';
$opt['logic']['node']['id'] = 4;
// Google Maps API key

View File

@ -33,6 +33,8 @@ $tpl->assign('coordRD', $coord->getRD());
$tpl->assign('showRD', ($coord->nLat >= 45 && $coord->nLat <= 57 && $coord->nLon >= 0 && $coord->nLon <= 15));
$tpl->assign('coordQTH', $coord->getQTH());
$tpl->assign('coordSwissGrid', $coord->getSwissGrid());
$tpl->assign('coordW3Wde', $coord->getW3W('de'));
$tpl->assign('coordW3Wen', $coord->getW3W('en'));
// wp gesetzt?
$wp = isset($_REQUEST['wp']) ? $_REQUEST['wp'] : '';

View File

@ -607,4 +607,29 @@ class Coordinate
return $lon;
}
public function getW3W($language = "de")
{
$params = array(
'key' => $GLOBALS['container']->get('ocde.config')->get('ocde.what3words.apikey'),
'position' => sprintf('%f,%f', $this->nLat, $this->nLon),
'lang' => $language,
);
$params_str = http_build_query($params);
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => "Content-Type: application/x-www-form-urlencoded\r\n" .
"Content-Length: " . strlen($params_str) . "\r\n",
'content' => $params_str,
),
));
$result = file_get_contents('http://api.what3words.com/position', false, $context);
if ($result === false) {
return false;
}
$json = json_decode($result, true);
return implode('.', $json['words']);
}
}

View File

@ -45,3 +45,11 @@
{$coordRD|escape}</p>
</div>
{/if}
<div style="margin-top:4px;">
<p style="color: 5890a8"><b>what3words</b> <small>(deutsch)</small><br />
<a href="http://w3w.co/{$coordW3Wde|escape}">{$coordW3Wde|escape}</a></p>
</div>
<div style="margin-top:4px;">
<p style="color: 5890a8"><b>what3words</b> <small>(english)</small><br />
<a href="http://w3w.co/{$coordW3Wen|escape}">{$coordW3Wen|escape}</a></p>
</div>