X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=buffer%2Fbuffer.php;h=9bbdf21e529850b09f0524494abd1eac4c6d1eb6;hb=e34b227e614c9299326ab3ddabac3befe30da7fe;hp=13b5309d6475a7381e5e1b1b34d219b77395335b;hpb=cfe921ac758d65205ecfb28a1fd04a2b431cc5f0;p=friendica-addons.git
diff --git a/buffer/buffer.php b/buffer/buffer.php
index 13b5309d..9bbdf21e 100644
--- a/buffer/buffer.php
+++ b/buffer/buffer.php
@@ -9,14 +9,12 @@
require 'addon/buffer/bufferapp.php';
use Friendica\App;
-use Friendica\Core\Config;
use Friendica\Core\Hook;
-use Friendica\Core\L10n;
use Friendica\Core\Logger;
-use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
+use Friendica\DI;
use Friendica\Model\ItemContent;
use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
@@ -31,16 +29,6 @@ function buffer_install()
Hook::register('connector_settings_post', 'addon/buffer/buffer.php', 'buffer_settings_post');
}
-function buffer_uninstall()
-{
- Hook::unregister('hook_fork', 'addon/buffer/buffer.php', 'buffer_hook_fork');
- Hook::unregister('post_local', 'addon/buffer/buffer.php', 'buffer_post_local');
- Hook::unregister('notifier_normal', 'addon/buffer/buffer.php', 'buffer_send');
- Hook::unregister('jot_networks', 'addon/buffer/buffer.php', 'buffer_jot_nets');
- Hook::unregister('connector_settings', 'addon/buffer/buffer.php', 'buffer_settings');
- Hook::unregister('connector_settings_post', 'addon/buffer/buffer.php', 'buffer_settings_post');
-}
-
function buffer_module()
{
}
@@ -48,7 +36,7 @@ function buffer_module()
function buffer_content(App $a)
{
if (! local_user()) {
- notice(L10n::t('Permission denied.') . EOL);
+ notice(DI::l10n()->t('Permission denied.') . EOL);
return '';
}
@@ -77,10 +65,10 @@ function buffer_addon_admin(App $a, &$o)
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/buffer/");
$o = Renderer::replaceMacros($t, [
- '$submit' => L10n::t('Save Settings'),
+ '$submit' => DI::l10n()->t('Save Settings'),
// name, label, value, help, [extra values]
- '$client_id' => ['client_id', L10n::t('Client ID'), Config::get('buffer', 'client_id'), ''],
- '$client_secret' => ['client_secret', L10n::t('Client Secret'), Config::get('buffer', 'client_secret'), ''],
+ '$client_id' => ['client_id', DI::l10n()->t('Client ID'), DI::config()->get('buffer', 'client_id'), ''],
+ '$client_secret' => ['client_secret', DI::l10n()->t('Client Secret'), DI::config()->get('buffer', 'client_secret'), ''],
]);
}
@@ -89,16 +77,14 @@ function buffer_addon_admin_post(App $a)
$client_id = (!empty($_POST['client_id']) ? Strings::escapeTags(trim($_POST['client_id'])) : '');
$client_secret = (!empty($_POST['client_secret']) ? Strings::escapeTags(trim($_POST['client_secret'])) : '');
- Config::set('buffer', 'client_id' , $client_id);
- Config::set('buffer', 'client_secret', $client_secret);
-
- info(L10n::t('Settings updated.'). EOL);
+ DI::config()->set('buffer', 'client_id' , $client_id);
+ DI::config()->set('buffer', 'client_secret', $client_secret);
}
function buffer_connect(App $a)
{
if (isset($_REQUEST["error"])) {
- $o = L10n::t('Error when registering buffer connection:')." ".$_REQUEST["error"];
+ $o = DI::l10n()->t('Error when registering buffer connection:')." ".$_REQUEST["error"];
return $o;
}
@@ -106,11 +92,11 @@ function buffer_connect(App $a)
session_start();
// Define the needed keys
- $client_id = Config::get('buffer','client_id');
- $client_secret = Config::get('buffer','client_secret');
+ $client_id = DI::config()->get('buffer','client_id');
+ $client_secret = DI::config()->get('buffer','client_secret');
// The callback URL is the script that gets called after the user authenticates with buffer
- $callback_url = $a->getBaseURL()."/buffer/connect";
+ $callback_url = DI::baseUrl()->get()."/buffer/connect";
$buffer = new BufferApp($client_id, $client_secret, $callback_url);
@@ -118,9 +104,9 @@ function buffer_connect(App $a)
$o = 'Connect to Buffer!';
} else {
Logger::log("buffer_connect: authenticated");
- $o = L10n::t("You are now authenticated to buffer. ");
- $o .= '
' . L10n::t("return to the connector page") . '';
- PConfig::set(local_user(), 'buffer','access_token', $buffer->access_token);
+ $o = DI::l10n()->t("You are now authenticated to buffer. ");
+ $o .= '
' . DI::l10n()->t("return to the connector page") . '';
+ DI::pConfig()->set(local_user(), 'buffer','access_token', $buffer->access_token);
}
return $o;
@@ -132,13 +118,13 @@ function buffer_jot_nets(App $a, array &$jotnets_fields)
return;
}
- if (PConfig::get(local_user(), 'buffer', 'post')) {
+ if (DI::pConfig()->get(local_user(), 'buffer', 'post')) {
$jotnets_fields[] = [
'type' => 'checkbox',
'field' => [
'buffer_enable',
- L10n::t('Post to Buffer'),
- PConfig::get(local_user(), 'buffer', 'post_by_default')
+ DI::l10n()->t('Post to Buffer'),
+ DI::pConfig()->get(local_user(), 'buffer', 'post_by_default')
]
];
}
@@ -152,62 +138,62 @@ function buffer_settings(App $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 variables */
- $enabled = PConfig::get(local_user(),'buffer','post');
+ $enabled = DI::pConfig()->get(local_user(),'buffer','post');
$checked = (($enabled) ? ' checked="checked" ' : '');
$css = (($enabled) ? '' : '-disabled');
- $def_enabled = PConfig::get(local_user(),'buffer','post_by_default');
+ $def_enabled = DI::pConfig()->get(local_user(),'buffer','post_by_default');
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
/* Add some HTML to the existing form */
$s .= '';
- $s .= ''. L10n::t('Buffer Export').'
';
+ $s .= ''. DI::l10n()->t('Buffer Export').'
';
$s .= '';
$s .= '