X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=randplace%2Frandplace.php;h=886d79d125a58f240d63404ddcee5521367a3daf;hb=65e4726718a10e1d15782d299b348add76377751;hp=ca4d3d797d0783d24a5becefb3f1aabc448a3dcc;hpb=39dd3dffe07efd69fa1ac6d0bd243c7fc0e3a66f;p=friendica-addons.git diff --git a/randplace/randplace.php b/randplace/randplace.php index ca4d3d79..886d79d1 100644 --- a/randplace/randplace.php +++ b/randplace/randplace.php @@ -4,9 +4,9 @@ * Description: Sample Friendica addon. Set a random place when posting. * Version: 1.0 * Author: Mike Macgirvin - * - * - * + * + * + * * * Addons are registered with the system through the admin * panel. @@ -14,13 +14,13 @@ * When registration is detected, the system calls the addon * name_install() function, located in 'addon/name/name.php', * where 'name' is the name of the addon. - * If the addon is removed from the configuration list, the + * If the addon is removed from the configuration list, the * system will call the name_uninstall() function. * */ -use Friendica\Core\Addon; -use Friendica\Core\L10n; -use Friendica\Core\PConfig; +use Friendica\Core\Hook; +use Friendica\Core\Logger; +use Friendica\DI; function randplace_install() { @@ -31,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'); /** * @@ -41,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"); } @@ -58,12 +58,12 @@ function randplace_uninstall() { * */ - 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'); + Hook::unregister('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook'); + Hook::unregister('addon_settings', 'addon/randplace/randplace.php', 'randplace_settings'); + Hook::unregister('addon_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post'); - logger("removed randplace"); + Logger::log("removed randplace"); } @@ -79,7 +79,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; @@ -92,7 +92,7 @@ function randplace_post_hook($a, &$item) { /* Retrieve our personal config setting */ - $active = get_pconfig(local_user(), 'randplace', 'enable'); + $active = DI::pConfig()->get(local_user(), 'randplace', 'enable'); if(! $active) return; @@ -106,7 +106,7 @@ function randplace_post_hook($a, &$item) { * */ - $cities = array(); + $cities = []; $zones = timezone_identifiers_list(); foreach($zones as $zone) { if((strpos($zone,'/')) && (! stristr($zone,'US/')) && (! stristr($zone,'Etc/'))) @@ -137,7 +137,7 @@ function randplace_settings_post($a,$post) { if(! local_user()) return; if($_POST['randplace-submit']) - set_pconfig(local_user(),'randplace','enable',intval($_POST['randplace'])); + DI::pConfig()->set(local_user(),'randplace','enable',intval($_POST['randplace'])); } @@ -157,25 +157,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 = get_pconfig(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 .= '

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

'; + $s .= '

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

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