X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=krynn%2Fkrynn.php;h=88aa84ea206cbbfb439810f7c461e78e945e1927;hb=a423d92649cb0eedf21abeedeb3e6c9eb0ccdbeb;hp=ca2c426d594185ea52068f5f867e54cebc92d683;hpb=639a32fe19fb2b1943f9ac657ff86b658732b10e;p=friendica-addons.git diff --git a/krynn/krynn.php b/krynn/krynn.php old mode 100755 new mode 100644 index ca2c426d..88aa84ea --- a/krynn/krynn.php +++ b/krynn/krynn.php @@ -1,7 +1,7 @@ * Planets Author: Tony Baldwin @@ -9,55 +9,35 @@ * *"My body was my sacrifice... for my magic. This damage is permanent." - Raistlin Majere */ - -use Friendica\Core\PConfig; +use Friendica\Core\Hook; +use Friendica\Core\Logger; +use Friendica\DI; function krynn_install() { /** - * - * Our demo plugin will attach in three places. + * + * Our demo addon will attach in three places. * The first is just prior to storing a local post. * */ - register_hook('post_local', 'addon/krynn/krynn.php', 'krynn_post_hook'); + Hook::register('post_local', 'addon/krynn/krynn.php', 'krynn_post_hook'); /** * - * Then we'll attach into the plugin settings page, and also the + * Then we'll attach into the addon settings page, and also the * settings post hook so that we can create and update * user preferences. * */ - register_hook('plugin_settings', 'addon/krynn/krynn.php', 'krynn_settings'); - register_hook('plugin_settings_post', 'addon/krynn/krynn.php', 'krynn_settings_post'); - - logger("installed krynn"); -} - - -function krynn_uninstall() { - - /** - * - * uninstall unregisters any hooks created with register_hook - * during install. It may also delete configuration settings - * and any other cleanup. - * - */ - - unregister_hook('post_local', 'addon/krynn/krynn.php', 'krynn_post_hook'); - unregister_hook('plugin_settings', 'addon/krynn/krynn.php', 'krynn_settings'); - unregister_hook('plugin_settings_post', 'addon/krynn/krynn.php', 'krynn_settings_post'); + Hook::register('addon_settings', 'addon/krynn/krynn.php', 'krynn_settings'); + Hook::register('addon_settings_post', 'addon/krynn/krynn.php', 'krynn_settings_post'); - - logger("removed krynn"); + Logger::log("installed krynn"); } - - function krynn_post_hook($a, &$item) { /** @@ -65,12 +45,10 @@ function krynn_post_hook($a, &$item) { * An item was posted on the local system. * We are going to look for specific items: * - A status post by a profile owner - * - The profile owner must have allowed our plugin + * - The profile owner must have allowed our addon * */ - logger('krynn invoked'); - if(! local_user()) /* non-zero if this is a logged in user of this system */ return; @@ -82,7 +60,7 @@ function krynn_post_hook($a, &$item) { /* Retrieve our personal config setting */ - $active = PConfig::get(local_user(), 'krynn', 'enable'); + $active = DI::pConfig()->get(local_user(), 'krynn', 'enable'); if(! $active) return; @@ -96,7 +74,7 @@ function krynn_post_hook($a, &$item) { * */ - $krynn = array('Ansalon','Abanasinia','Solace','Haven','Gateway','Qualinost','Ankatavaka','Pax Tharkas','Ergoth','Newsea','Straights of Schallsea','Plains of Dust','Tarsis','Barren Hills','Que Shu','Citadel of Light','Solinari','Hedge Maze','Tower of High Sorcery','Inn of the Last Home','Last Heroes Tomb','Academy of Sorcery','Gods Row','Temple of Majere','Temple of Kiri-Jolith','Temple of Mishakal','Temple of Zeboim','The Trough','Sad Town','Xak Tsaroth','Zhaman','Skullcap','Saifhum','Karthay','Mithas','Kothas','Silver Dragon Mountain','Silvanesti'); + $krynn = ['Ansalon','Abanasinia','Solace','Haven','Gateway','Qualinost','Ankatavaka','Pax Tharkas','Ergoth','Newsea','Straights of Schallsea','Plains of Dust','Tarsis','Barren Hills','Que Shu','Citadel of Light','Solinari','Hedge Maze','Tower of High Sorcery','Inn of the Last Home','Last Heroes Tomb','Academy of Sorcery','Gods Row','Temple of Majere','Temple of Kiri-Jolith','Temple of Mishakal','Temple of Zeboim','The Trough','Sad Town','Xak Tsaroth','Zhaman','Skullcap','Saifhum','Karthay','Mithas','Kothas','Silver Dragon Mountain','Silvanesti']; $planet = array_rand($krynn,1); $item['location'] = $krynn[$planet]; @@ -120,13 +98,13 @@ function krynn_settings_post($a,$post) { if(! local_user()) return; if($_POST['krynn-submit']) - PConfig::set(local_user(),'krynn','enable',intval($_POST['krynn'])); + DI::pConfig()->set(local_user(),'krynn','enable',intval($_POST['krynn'])); } /** * - * Called from the Plugin Setting form. + * Called from the addon Setting form. * Add our own settings info to the page. * */ @@ -140,34 +118,34 @@ function krynn_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(),'krynn','enable'); + $enabled = DI::pConfig()->get(local_user(),'krynn','enable'); $checked = (($enabled) ? ' checked="checked" ' : ''); /* Add some HTML to the existing form */ $s .= ''; - $s .= '

' . t('Krynn') . '

'; + $s .= '

' . DI::l10n()->t('Krynn') . '

'; $s .= '
'; $s .= ''; + $s .= '
'; }