X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=numfriends%2Fnumfriends.php;h=247c7dc7593e98aa9fa66e4ba42c12e12b7cd55c;hb=29cf1539a7c614d9b39e2f9a99cce64a2992d984;hp=2f48a0d7d369926412f381b7b9854a8f5ad5594c;hpb=dfa4cfc7cde6c6f755beae5818fe3eee99724c5c;p=friendica-addons.git diff --git a/numfriends/numfriends.php b/numfriends/numfriends.php old mode 100755 new mode 100644 index 2f48a0d7..247c7dc7 --- a/numfriends/numfriends.php +++ b/numfriends/numfriends.php @@ -4,15 +4,15 @@ * Description: Change number of contacts shown of profile sidebar * Version: 1.0 * Author: Mike Macgirvin - * - * */ - +use Friendica\Core\Addon; +use Friendica\Core\L10n; +use Friendica\Core\PConfig; function numfriends_install() { - register_hook('plugin_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings'); - register_hook('plugin_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post'); + Addon::registerHook('addon_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings'); + Addon::registerHook('addon_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post'); logger("installed numfriends"); } @@ -20,15 +20,13 @@ function numfriends_install() { function numfriends_uninstall() { - unregister_hook('plugin_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings'); - unregister_hook('plugin_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post'); + Addon::unregisterHook('addon_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings'); + Addon::unregisterHook('addon_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post'); logger("removed numfriends"); } - - /** * * Callback from the settings post function. @@ -37,29 +35,26 @@ function numfriends_uninstall() { * and if so set our configuration setting for this person. * */ - function numfriends_settings_post($a,$post) { if(! local_user() || (! x($_POST,'numfriends-submit'))) return; - set_pconfig(local_user(),'system','display_friend_count',intval($_POST['numfriends'])); - info( t('Numfriends settings updated.') . EOL); + PConfig::set(local_user(),'system','display_friend_count',intval($_POST['numfriends'])); + info( L10n::t('Numfriends settings updated.') . EOL); } /** * - * Called from the Plugin Setting form. + * Called from the Addon Setting form. * Add our own settings info to the page. * */ - - - -function numfriends_settings(&$a,&$s) { - - if(! local_user()) +function numfriends_settings(&$a, &$s) +{ + if (! local_user()) { return; + } /* Add our stylesheet to the page so we can make our settings look nice */ @@ -67,21 +62,18 @@ function numfriends_settings(&$a,&$s) { /* Get the current state of our config variable */ - $numfriends = get_pconfig(local_user(),'system','display_friend_count'); - if($numfriends === false) - $numfriends = 24; + $numfriends = PConfig::get(local_user(), 'system', 'display_friend_count', 24); /* Add some HTML to the existing form */ $s .= '
'; - $s .= '

' . t('Numfriends Settings') . '

'; + $s .= '

' . L10n::t('Numfriends Settings') . '

'; $s .= '
'; - $s .= ''; + $s .= ''; $s .= ''; $s .= '
'; /* provide a submit button */ - $s .= '
'; - + $s .= '
'; }