]> git.mxchange.org Git - friendica-addons.git/blobdiff - randplace/randplace.php
diaspora addon added HU translation THX Balázs Úr
[friendica-addons.git] / randplace / randplace.php
index ffc3237c3d007f129d907e0256df9a423fe7d079..3576fef85c17aceb3b419eac1cd3fe97e0c210fc 100644 (file)
@@ -19,9 +19,8 @@
  *
  */
 use Friendica\Core\Hook;
-use Friendica\Core\L10n;
 use Friendica\Core\Logger;
-use Friendica\Core\PConfig;
+use Friendica\DI;
 
 function randplace_install() {
 
@@ -53,17 +52,12 @@ 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.
         *
         */
 
-       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::log("removed randplace");
 }
 
@@ -93,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;
@@ -138,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']));
 }
 
 
@@ -158,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'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->getBaseURL() . '/addon/randplace/randplace.css' . '" media="all" />' . "\r\n";
+       DI::page()['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . DI::baseUrl()->get() . '/addon/randplace/randplace.css' . '" media="all" />' . "\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 .= '<div class="settings-block">';
-       $s .= '<h3>' . L10n::t('Randplace Settings') . '</h3>';
+       $s .= '<h3>' . DI::l10n()->t('Randplace Settings') . '</h3>';
        $s .= '<div id="randplace-enable-wrapper">';
-       $s .= '<label id="randplace-enable-label" for="randplace-checkbox">' . L10n::t('Enable Randplace Addon') . '</label>';
+       $s .= '<label id="randplace-enable-label" for="randplace-checkbox">' . DI::l10n()->t('Enable Randplace Addon') . '</label>';
        $s .= '<input id="randplace-checkbox" type="checkbox" name="randplace" value="1" ' . $checked . '/>';
        $s .= '</div><div class="clear"></div>';
 
        /* provide a submit button */
 
-       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="randplace-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';
+       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="randplace-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
 
 }