X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=gravatar%2Fgravatar.php;h=894abda6d748c7dace81010926f3084defce3036;hb=a0344101f122248c3069a5dcfa3ebfcb67215d5a;hp=d0d54689965ce08dc2345f2896f032b6550118f5;hpb=c3fdf45b6dff82146a5f0c617d7f33df0cb12267;p=friendica-addons.git diff --git a/gravatar/gravatar.php b/gravatar/gravatar.php index d0d54689..894abda6 100644 --- a/gravatar/gravatar.php +++ b/gravatar/gravatar.php @@ -8,37 +8,27 @@ use Friendica\App; use Friendica\BaseModule; -use Friendica\Core\Addon; -use Friendica\Core\Config; -use Friendica\Core\L10n; +use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Database\DBA; -use Friendica\Util\Security; +use Friendica\DI; +use Friendica\Util\ConfigFileLoader; +use Friendica\Util\Strings; /** * Installs the addon hook */ function gravatar_install() { - Addon::registerHook('load_config', 'addon/gravatar/gravatar.php', 'gravatar_load_config'); - Addon::registerHook('avatar_lookup', 'addon/gravatar/gravatar.php', 'gravatar_lookup'); + Hook::register('load_config', 'addon/gravatar/gravatar.php', 'gravatar_load_config'); + Hook::register('avatar_lookup', 'addon/gravatar/gravatar.php', 'gravatar_lookup'); Logger::log("registered gravatar in avatar_lookup hook"); } -/** - * Removes the addon hook - */ -function gravatar_uninstall() { - Addon::unregisterHook('load_config', 'addon/gravatar/gravatar.php', 'gravatar_load_config'); - Addon::unregisterHook('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.ini.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.') .'