X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=gravatar%2Fgravatar.php;h=894abda6d748c7dace81010926f3084defce3036;hb=a0344101f122248c3069a5dcfa3ebfcb67215d5a;hp=70e81448df8fc7de8288888b9e48876c25f10dc1;hpb=3e202f8ee4edc75f21f47fec86442878d95470f7;p=friendica-addons.git diff --git a/gravatar/gravatar.php b/gravatar/gravatar.php index 70e81448..894abda6 100644 --- a/gravatar/gravatar.php +++ b/gravatar/gravatar.php @@ -8,12 +8,12 @@ use Friendica\App; use Friendica\BaseModule; -use Friendica\Core\Config; use Friendica\Core\Hook; -use Friendica\Core\L10n; use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Database\DBA; +use Friendica\DI; +use Friendica\Util\ConfigFileLoader; use Friendica\Util\Strings; /** @@ -26,19 +26,9 @@ function gravatar_install() { Logger::log("registered gravatar in avatar_lookup hook"); } -/** - * Removes the addon hook - */ -function gravatar_uninstall() { - Hook::unregister('load_config', 'addon/gravatar/gravatar.php', 'gravatar_load_config'); - Hook::unregister('avatar_lookup', 'addon/gravatar/gravatar.php', 'gravatar_lookup'); - - Logger::log("unregistered gravatar in avatar_lookup hook"); -} - -function gravatar_load_config(App $a) +function gravatar_load_config(App $a, ConfigFileLoader $loader) { - $a->loadConfigFile(__DIR__ . '/config/gravatar.config.php'); + $a->getConfigCache()->load($loader->loadAddonConfig('gravatar')); } /** @@ -48,8 +38,8 @@ function gravatar_load_config(App $a) * @param &$b array */ function gravatar_lookup($a, &$b) { - $default_avatar = Config::get('gravatar', 'default_avatar'); - $rating = Config::get('gravatar', 'rating'); + $default_avatar = DI::config()->get('gravatar', 'default_avatar'); + $rating = DI::config()->get('gravatar', 'rating'); // setting default value if nothing configured if(! $default_avatar) @@ -74,8 +64,8 @@ function gravatar_lookup($a, &$b) { function gravatar_addon_admin (&$a, &$o) { $t = Renderer::getMarkupTemplate( "admin.tpl", "addon/gravatar/" ); - $default_avatar = Config::get('gravatar', 'default_avatar'); - $rating = Config::get('gravatar', 'rating'); + $default_avatar = DI::config()->get('gravatar', 'default_avatar'); + $rating = DI::config()->get('gravatar', 'rating'); // set default values for first configuration if(! $default_avatar) @@ -85,11 +75,11 @@ function gravatar_addon_admin (&$a, &$o) { // Available options for the select boxes $default_avatars = [ - 'mm' => L10n::t('generic profile image'), - 'identicon' => L10n::t('random geometric pattern'), - 'monsterid' => L10n::t('monster face'), - 'wavatar' => L10n::t('computer generated face'), - 'retro' => L10n::t('retro arcade style face'), + 'mm' => DI::l10n()->t('generic profile image'), + 'identicon' => DI::l10n()->t('random geometric pattern'), + 'monsterid' => DI::l10n()->t('monster face'), + 'wavatar' => DI::l10n()->t('computer generated face'), + 'retro' => DI::l10n()->t('retro arcade style face'), ]; $ratings = [ 'g' => 'g', @@ -103,15 +93,15 @@ function gravatar_addon_admin (&$a, &$o) { DBA::escape('libravatar') ); if (count($r)) { - $o = '
' .L10n::t('Libravatar addon is installed, too. Please disable Libravatar addon or this Gravatar addon.
The Libravatar addon will fall back to Gravatar if nothing was found at Libravatar.') .'
' .DI::l10n()->t('Libravatar addon is installed, too. Please disable Libravatar addon or this Gravatar addon.
The Libravatar addon will fall back to Gravatar if nothing was found at Libravatar.') .'