X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=openstreetmap%2Fopenstreetmap.php;h=168d3d2ff4bb71b5dc507d9045cad2f32ab256ac;hb=14c09c1bbba1324bd03f58d6af123ba53b29070c;hp=1d219c3a6e115c519d1fcaba4282812617c7f990;hpb=141007764b66aca2e11dbe27dbbdbd97c3489ef0;p=friendica-addons.git
diff --git a/openstreetmap/openstreetmap.php b/openstreetmap/openstreetmap.php
index 1d219c3a..168d3d2f 100644
--- a/openstreetmap/openstreetmap.php
+++ b/openstreetmap/openstreetmap.php
@@ -9,15 +9,12 @@
*
*/
-use Friendica\DI;
-use Friendica\Core\Cache;
-use Friendica\Core\Config;
+use Friendica\Core\Cache\Duration;
use Friendica\Core\Hook;
-use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
+use Friendica\DI;
use Friendica\Util\ConfigFileLoader;
-use Friendica\Util\Network;
use Friendica\Util\Strings;
const OSM_TMS = 'https://www.openstreetmap.org';
@@ -37,18 +34,6 @@ function openstreetmap_install()
Logger::log("installed openstreetmap");
}
-function openstreetmap_uninstall()
-{
- Hook::unregister('load_config', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_load_config');
- Hook::unregister('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
- Hook::unregister('generate_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_map');
- Hook::unregister('generate_named_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_named_map');
- Hook::unregister('Map::getCoordinates', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_get_coordinates');
- Hook::unregister('page_header', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_alterheader');
-
- Logger::log("removed openstreetmap");
-}
-
function openstreetmap_load_config(\Friendica\App $a, ConfigFileLoader $loader)
{
$a->getConfigCache()->load($loader->loadAddonConfig('openstreetmap'));
@@ -57,7 +42,7 @@ function openstreetmap_load_config(\Friendica\App $a, ConfigFileLoader $loader)
function openstreetmap_alterheader($a, &$navHtml)
{
$addScriptTag = '' . "\r\n";
- $a->page['htmlhead'] .= $addScriptTag;
+ DI::page()['htmlhead'] .= $addScriptTag;
}
/**
@@ -83,10 +68,10 @@ function openstreetmap_location($a, &$item)
* ?mlat=lat&mlon=lon for markers.
*/
- $tmsserver = Config::get('openstreetmap', 'tmsserver', OSM_TMS);
- $nomserver = Config::get('openstreetmap', 'nomserver', OSM_NOM);
- $zoom = Config::get('openstreetmap', 'zoom', OSM_ZOOM);
- $marker = Config::get('openstreetmap', 'marker', OSM_MARKER);
+ $tmsserver = DI::config()->get('openstreetmap', 'tmsserver', OSM_TMS);
+ $nomserver = DI::config()->get('openstreetmap', 'nomserver', OSM_NOM);
+ $zoom = DI::config()->get('openstreetmap', 'zoom', OSM_ZOOM);
+ $marker = DI::config()->get('openstreetmap', 'marker', OSM_MARKER);
// This is needed since we stored an empty string in the config in previous versions
if (empty($nomserver)) {
@@ -121,7 +106,7 @@ function openstreetmap_location($a, &$item)
function openstreetmap_get_coordinates($a, &$b)
{
- $nomserver = Config::get('openstreetmap', 'nomserver', OSM_NOM);
+ $nomserver = DI::config()->get('openstreetmap', 'nomserver', OSM_NOM);
// This is needed since we stored an empty string in the config in previous versions
if (empty($nomserver)) {
@@ -131,13 +116,13 @@ function openstreetmap_get_coordinates($a, &$b)
$args = '?q=' . urlencode($b['location']) . '&format=json';
$cachekey = "openstreetmap:" . $b['location'];
- $j = Cache::get($cachekey);
+ $j = DI::cache()->get($cachekey);
if (is_null($j)) {
- $curlResult = Network::curl($nomserver . $args);
+ $curlResult = DI::httpRequest()->get($nomserver . $args);
if ($curlResult->isSuccess()) {
$j = json_decode($curlResult->getBody(), true);
- Cache::set($cachekey, $j, Cache::MONTH);
+ DI::cache()->set($cachekey, $j, Duration::MONTH);
}
}
@@ -158,14 +143,14 @@ function openstreetmap_generate_named_map(&$a, &$b)
function openstreetmap_generate_map(&$a, &$b)
{
- $tmsserver = Config::get('openstreetmap', 'tmsserver', OSM_TMS);
+ $tmsserver = DI::config()->get('openstreetmap', 'tmsserver', OSM_TMS);
if (strpos(DI::baseUrl()->get(true), 'https:') !== false) {
$tmsserver = str_replace('http:','https:',$tmsserver);
}
- $zoom = Config::get('openstreetmap', 'zoom', OSM_ZOOM);
- $marker = Config::get('openstreetmap', 'marker', OSM_MARKER);
+ $zoom = DI::config()->get('openstreetmap', 'zoom', OSM_ZOOM);
+ $marker = DI::config()->get('openstreetmap', 'marker', OSM_MARKER);
$lat = $b['lat']; // round($b['lat'], 5);
$lon = $b['lon']; // round($b['lon'], 5);
@@ -179,7 +164,7 @@ function openstreetmap_generate_map(&$a, &$b)
$cardlink .= '?mlat=' . $lat . '&mlon=' . $lon;
}
- $cardlink .= '#map=' . $zoom . '/' . $lat . '/' . $lon . '">' . ($b['location'] ? Strings::escapeHtml($b['location']) : L10n::t('View Larger')) . '';
+ $cardlink .= '#map=' . $zoom . '/' . $lat . '/' . $lon . '">' . ($b['location'] ? Strings::escapeHtml($b['location']) : DI::l10n()->t('View Larger')) . '';
if (empty($b['mode'])) {
$b['html'] = '