Merge remote-tracking branch 'upstream/develop' into media
[friendica-addons.git/.git] / planets / planets.php
index 48ba576..9fed418 100644 (file)
@@ -7,9 +7,8 @@
  * Author: Tony Baldwin <https://free-haven.org/profile/tony>
  */
 use Friendica\Core\Hook;
-use Friendica\Core\L10n;
 use Friendica\Core\Logger;
-use Friendica\Core\PConfig;
+use Friendica\DI;
 
 function planets_install() {
 
@@ -36,27 +35,6 @@ function planets_install() {
        Logger::log("installed planets");
 }
 
-
-function planets_uninstall() {
-
-       /**
-        *
-        * uninstall unregisters any hooks created with register_hook
-        * during install. It may also delete configuration settings
-        * and any other cleanup.
-        *
-        */
-
-       Hook::unregister('post_local',    'addon/planets/planets.php', 'planets_post_hook');
-       Hook::unregister('addon_settings', 'addon/planets/planets.php', 'planets_settings');
-       Hook::unregister('addon_settings_post', 'addon/planets/planets.php', 'planets_settings_post');
-
-
-       Logger::log("removed planets");
-}
-
-
-
 function planets_post_hook($a, &$item) {
 
        /**
@@ -81,7 +59,7 @@ function planets_post_hook($a, &$item) {
 
        /* Retrieve our personal config setting */
 
-       $active = PConfig::get(local_user(), 'planets', 'enable');
+       $active = DI::pConfig()->get(local_user(), 'planets', 'enable');
 
        if(! $active)
                return;
@@ -119,7 +97,7 @@ function planets_settings_post($a,$post) {
        if(! local_user())
                return;
        if($_POST['planets-submit'])
-               PConfig::set(local_user(),'planets','enable',intval($_POST['planets']));
+               DI::pConfig()->set(local_user(),'planets','enable',intval($_POST['planets']));
 }
 
 
@@ -139,33 +117,33 @@ function planets_settings(&$a,&$s) {
 
        /* Add our stylesheet to the page so we can make our settings look nice */
 
-       $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->getBaseURL() . '/addon/planets/planets.css' . '" media="all" />' . "\r\n";
+       DI::page()['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . DI::baseUrl()->get() . '/addon/planets/planets.css' . '" media="all" />' . "\r\n";
 
        /* Get the current state of our config variable */
 
-       $enabled = PConfig::get(local_user(),'planets','enable');
+       $enabled = DI::pConfig()->get(local_user(),'planets','enable');
 
        $checked = (($enabled) ? ' checked="checked" ' : '');
 
        /* Add some HTML to the existing form */
 
     $s .= '<span id="settings_planets_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_planets_expanded\'); openClose(\'settings_planets_inflated\');">';
-       $s .= '<h3>' . L10n::t('Planets') . '</h3>';
+       $s .= '<h3>' . DI::l10n()->t('Planets') . '</h3>';
        $s .= '</span>';
        $s .= '<div id="settings_planets_expanded" class="settings-block" style="display: none;">';
        $s .= '<span class="fakelink" onclick="openClose(\'settings_planets_expanded\'); openClose(\'settings_planets_inflated\');">';
-       $s .= '<h3>' . L10n::t('Planets') . '</h3>';
+       $s .= '<h3>' . DI::l10n()->t('Planets') . '</h3>';
        $s .= '</span>';
 
     $s .= '<div class="settings-block">';
-       $s .= '<h3>' . L10n::t('Planets Settings') . '</h3>';
+       $s .= '<h3>' . DI::l10n()->t('Planets Settings') . '</h3>';
        $s .= '<div id="planets-enable-wrapper">';
-       $s .= '<label id="planets-enable-label" for="planets-checkbox">' . L10n::t('Enable Planets Addon') . '</label>';
+       $s .= '<label id="planets-enable-label" for="planets-checkbox">' . DI::l10n()->t('Enable Planets Addon') . '</label>';
        $s .= '<input id="planets-checkbox" type="checkbox" name="planets" value="1" ' . $checked . '/>';
        $s .= '</div><div class="clear"></div></div>';
 
        /* provide a submit button */
 
-       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="planets-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';
+       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="planets-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
 
 }