X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=blockem%2Fblockem.php;h=79e04c8b539e9d7618cfd1950d382e86a471b294;hb=d30487304973670d5e99e8346eb2ce8dbc6aeb30;hp=1880b9be44e5029bcc36a7da1e20c78746177bc8;hpb=147ac6b774d4210f2e2cb7db88edded97e22a128;p=friendica-addons.git
diff --git a/blockem/blockem.php b/blockem/blockem.php
index 1880b9be..79e04c8b 100644
--- a/blockem/blockem.php
+++ b/blockem/blockem.php
@@ -9,9 +9,12 @@
use Friendica\App;
use Friendica\Core\Hook;
+use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Util\Strings;
+global $blockem_words;
+
function blockem_install()
{
Hook::register('prepare_body_content_filter', 'addon/blockem/blockem.php', 'blockem_prepare_body_content_filter');
@@ -23,39 +26,25 @@ function blockem_install()
Hook::register('enotify_store' , 'addon/blockem/blockem.php', 'blockem_enotify_store');
}
-function blockem_addon_settings (App $a, &$s)
+function blockem_addon_settings(App $a, array &$data)
{
if (!local_user()) {
return;
}
- /* Add our stylesheet to the page so we can make our settings look nice */
- DI::page()['htmlhead'] .= '' . "\r\n";
-
- $words = DI::pConfig()->get(local_user(), 'blockem', 'words');
-
- if (!$words) {
- $words = '';
- }
-
- $s .= '';
- $s .= '' . DI::l10n()->t('Blockem') . '
';
- $s .= '';
- $s .= '
';
- $s .= '
';
- $s .= '' . DI::l10n()->t('Blockem') . '
';
- $s .= '';
-
- $s .= '
';
- $s .= '
'. DI::l10n()->t("Hides user's content by collapsing posts. Also replaces their avatar with generic image.") . '
';
- $s .= '
';
- $s .= '
';
- $s .= '
';
-
- $s .= '
';
+ $words = DI::pConfig()->get(local_user(), 'blockem', 'words', '');
- return;
+ $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/blockem/');
+ $html = Renderer::replaceMacros($t, [
+ '$info' => DI::l10n()->t("Hides user's content by collapsing posts. Also replaces their avatar with generic image."),
+ '$words' => ['blockem-words', DI::l10n()->t('Comma separated profile URLS:'), $words],
+ ]);
+ $data = [
+ 'addon' => 'blockem',
+ 'title' => DI::l10n()->t('Blockem'),
+ 'html' => $html,
+ ];
}
function blockem_addon_settings_post(App $a, array &$b)
@@ -141,6 +130,8 @@ function blockem_display_item(App $a, array &$b = null)
function blockem_conversation_start(App $a, array &$b)
{
+ global $blockem_words;
+
if (!local_user()) {
return;
}
@@ -148,7 +139,7 @@ function blockem_conversation_start(App $a, array &$b)
$words = DI::pConfig()->get(local_user(), 'blockem', 'words');
if ($words) {
- $a->data['blockem'] = explode(',', $words);
+ $blockem_words = explode(',', $words);
}
DI::page()['htmlhead'] .= <<< EOT
@@ -171,6 +162,8 @@ EOT;
function blockem_item_photo_menu(App $a, array &$b)
{
+ global $blockem_words;
+
if (!local_user() || $b['item']['self']) {
return;
}
@@ -178,8 +171,8 @@ function blockem_item_photo_menu(App $a, array &$b)
$blocked = false;
$author = $b['item']['author-link'];
- if (!empty($a->data['blockem'])) {
- foreach($a->data['blockem'] as $bloke) {
+ if (!empty($blockem_words)) {
+ foreach($blockem_words as $bloke) {
if (Strings::compareLink($bloke,$author)) {
$blocked = true;
break;