X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=geonames%2Fgeonames.php;h=8ea183db0d3cea238226894bd460343fa259aec0;hb=2d3c2b4ee9d6e9df1b09ae5c4e4df1d37fa51365;hp=c052cef6bea1187db9e080e19ee5601b976f8197;hpb=5c6108b3cc29151fb33185afe4ada805bc84a9ef;p=friendica-addons.git diff --git a/geonames/geonames.php b/geonames/geonames.php index c052cef6..8ea183db 100644 --- a/geonames/geonames.php +++ b/geonames/geonames.php @@ -7,14 +7,11 @@ */ use Friendica\App; -use Friendica\Core\Config; use Friendica\Core\Hook; -use Friendica\Core\L10n; use Friendica\Core\Logger; -use Friendica\Core\PConfig; use Friendica\Core\Renderer; +use Friendica\DI; use Friendica\Util\ConfigFileLoader; -use Friendica\Util\Network; use Friendica\Util\XML; function geonames_install() @@ -49,7 +46,7 @@ function geonames_post_hook(App $a, array &$item) * - The profile owner must have allowed our addon */ - Logger::log('geonames invoked'); + Logger::notice('geonames invoked'); if (!local_user()) { /* non-zero if this is a logged in user of this system */ return; @@ -65,8 +62,8 @@ function geonames_post_hook(App $a, array &$item) /* Retrieve our personal config setting */ - $geo_account = Config::get('geonames', 'username'); - $active = PConfig::get(local_user(), 'geonames', 'enable'); + $geo_account = DI::config()->get('geonames', 'username'); + $active = DI::pConfig()->get(local_user(), 'geonames', 'enable'); if (!$geo_account || !$active) { return; @@ -80,7 +77,7 @@ function geonames_post_hook(App $a, array &$item) /* OK, we're allowed to do our stuff. */ - $s = Network::fetchUrl('http://api.geonames.org/findNearbyPlaceName?lat=' . $coords[0] . '&lng=' . $coords[1] . '&username=' . $geo_account); + $s = DI::httpClient()->fetch('http://api.geonames.org/findNearbyPlaceName?lat=' . $coords[0] . '&lng=' . $coords[1] . '&username=' . $geo_account); if (!$s) { return; @@ -109,9 +106,7 @@ function geonames_addon_settings_post(App $a, array $post) return; } - PConfig::set(local_user(), 'geonames', 'enable', intval($_POST['geonames-enable'])); - - info(L10n::t('Geonames settings updated.')); + DI::pConfig()->set(local_user(), 'geonames', 'enable', intval($_POST['geonames-enable'])); } /** @@ -128,7 +123,7 @@ function geonames_addon_settings(App $a, &$s) return; } - $geo_account = Config::get('geonames', 'username'); + $geo_account = DI::config()->get('geonames', 'username'); if (!$geo_account) { return; @@ -136,16 +131,16 @@ function geonames_addon_settings(App $a, &$s) /* Add our stylesheet to the page so we can make our settings look nice */ $stylesheetPath = __DIR__ . '/geonames.css'; - $a->registerStylesheet($stylesheetPath); + DI::page()->registerStylesheet($stylesheetPath); /* Get the current state of our config variable */ - $enabled = intval(PConfig::get(local_user(), 'geonames', 'enable')); + $enabled = intval(DI::pConfig()->get(local_user(), 'geonames', 'enable')); - $t = Renderer::getMarkupTemplate('settings.tpl', __DIR__); + $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/geonames/'); $s .= Renderer::replaceMacros($t, [ - '$title' => L10n::t('Geonames Settings'), - '$description' => L10n::t('Replace numerical coordinates by the nearest populated location name in your posts.'), - '$enable' => ['geonames-enable', L10n::t('Enable Geonames Addon'), $enabled], - '$submit' => L10n::t('Save Settings') + '$title' => DI::l10n()->t('Geonames Settings'), + '$description' => DI::l10n()->t('Replace numerical coordinates by the nearest populated location name in your posts.'), + '$enable' => ['geonames-enable', DI::l10n()->t('Enable Geonames Addon'), $enabled], + '$submit' => DI::l10n()->t('Save Settings') ]); }