X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=randplace%2Frandplace.php;h=3576fef85c17aceb3b419eac1cd3fe97e0c210fc;hb=54436370f22d200c7dc4eee2e745738a7dd2eec1;hp=96e549a67470af2831313d147dbd9884eac6d8d8;hpb=c6e5bc3429c9c610895ba826d841cddd8c0f378b;p=friendica-addons.git diff --git a/randplace/randplace.php b/randplace/randplace.php index 96e549a6..3576fef8 100644 --- a/randplace/randplace.php +++ b/randplace/randplace.php @@ -18,8 +18,9 @@ * system will call the name_uninstall() function. * */ -use Friendica\Core\Addon; -use Friendica\Core\PConfig; +use Friendica\Core\Hook; +use Friendica\Core\Logger; +use Friendica\DI; function randplace_install() { @@ -30,7 +31,7 @@ function randplace_install() { * */ - Addon::registerHook('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook'); + Hook::register('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook'); /** * @@ -40,10 +41,10 @@ function randplace_install() { * */ - Addon::registerHook('addon_settings', 'addon/randplace/randplace.php', 'randplace_settings'); - Addon::registerHook('addon_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post'); + Hook::register('addon_settings', 'addon/randplace/randplace.php', 'randplace_settings'); + Hook::register('addon_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post'); - logger("installed randplace"); + Logger::log("installed randplace"); } @@ -51,18 +52,13 @@ function randplace_uninstall() { /** * - * uninstall unregisters any hooks created with register_hook - * during install. It may also delete configuration settings - * and any other cleanup. + * This function should undo anything that was done in name_install() + * + * Except hooks, they are all unregistered automatically and don't need to be unregistered manually. * */ - Addon::unregisterHook('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook'); - Addon::unregisterHook('addon_settings', 'addon/randplace/randplace.php', 'randplace_settings'); - Addon::unregisterHook('addon_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post'); - - - logger("removed randplace"); + Logger::log("removed randplace"); } @@ -78,7 +74,7 @@ function randplace_post_hook($a, &$item) { * */ - logger('randplace invoked'); + Logger::log('randplace invoked'); if(! local_user()) /* non-zero if this is a logged in user of this system */ return; @@ -91,7 +87,7 @@ function randplace_post_hook($a, &$item) { /* Retrieve our personal config setting */ - $active = PConfig::get(local_user(), 'randplace', 'enable'); + $active = DI::pConfig()->get(local_user(), 'randplace', 'enable'); if(! $active) return; @@ -136,7 +132,7 @@ function randplace_settings_post($a,$post) { if(! local_user()) return; if($_POST['randplace-submit']) - PConfig::set(local_user(),'randplace','enable',intval($_POST['randplace'])); + DI::pConfig()->set(local_user(),'randplace','enable',intval($_POST['randplace'])); } @@ -156,25 +152,25 @@ function randplace_settings(&$a,&$s) { /* Add our stylesheet to the page so we can make our settings look nice */ - $a->page['htmlhead'] .= '' . "\r\n"; + DI::page()['htmlhead'] .= '' . "\r\n"; /* Get the current state of our config variable */ - $enabled = PConfig::get(local_user(),'randplace','enable'); + $enabled = DI::pConfig()->get(local_user(),'randplace','enable'); $checked = (($enabled) ? ' checked="checked" ' : ''); /* Add some HTML to the existing form */ $s .= '
'; - $s .= '

' . t('Randplace Settings') . '

'; + $s .= '

' . DI::l10n()->t('Randplace Settings') . '

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