X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=gravatar%2Fgravatar.php;h=894abda6d748c7dace81010926f3084defce3036;hb=a0344101f122248c3069a5dcfa3ebfcb67215d5a;hp=00d8e5b322a8cb609471f42378b9daa19247229c;hpb=76a9630d40e258e36d289d74a7bd28a0af9f6f15;p=friendica-addons.git diff --git a/gravatar/gravatar.php b/gravatar/gravatar.php index 00d8e5b3..894abda6 100644 --- a/gravatar/gravatar.php +++ b/gravatar/gravatar.php @@ -7,34 +7,28 @@ */ use Friendica\App; -use Friendica\Core\Addon; -use Friendica\Core\Config; -use Friendica\Core\L10n; +use Friendica\BaseModule; +use Friendica\Core\Hook; +use Friendica\Core\Logger; +use Friendica\Core\Renderer; use Friendica\Database\DBA; +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("registered gravatar in avatar_lookup hook"); + 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("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')); } /** @@ -44,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) @@ -68,10 +62,10 @@ function gravatar_lookup($a, &$b) { * Display admin settings for this addon */ function gravatar_addon_admin (&$a, &$o) { - $t = get_markup_template( "admin.tpl", "addon/gravatar/" ); + $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) @@ -81,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', @@ -99,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.') .'