use Friendica\App;
use Friendica\Core\Hook;
+use Friendica\Core\Renderer;
+use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Util\Strings;
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()) {
+ if (!Session::getLocalUser()) {
return;
}
- /* Add our stylesheet to the page so we can make our settings look nice */
- DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/blockem/blockem.css' . '" media="all" />' . "\r\n";
+ $words = DI::pConfig()->get(Session::getLocalUser(), 'blockem', 'words', '');
- $words = DI::pConfig()->get(local_user(), 'blockem', 'words');
-
- if (!$words) {
- $words = '';
- }
-
- $s .= '<span id="settings_blockem_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_blockem_expanded\'); openClose(\'settings_blockem_inflated\');">';
- $s .= '<h3>' . DI::l10n()->t('Blockem') . '</h3>';
- $s .= '</span>';
- $s .= '<div id="settings_blockem_expanded" class="settings-block" style="display: none;">';
- $s .= '<span class="fakelink" onclick="openClose(\'settings_blockem_expanded\'); openClose(\'settings_blockem_inflated\');">';
- $s .= '<h3>' . DI::l10n()->t('Blockem') . '</h3>';
- $s .= '</span>';
-
- $s .= '<div id="blockem-wrapper">';
- $s .= '<div id="blockem-desc">'. DI::l10n()->t("Hides user's content by collapsing posts. Also replaces their avatar with generic image.") . ' </div>';
- $s .= '<label id="blockem-label" for="blockem-words">' . DI::l10n()->t('Comma separated profile URLS:') . ' </label>';
- $s .= '<textarea id="blockem-words" type="text" name="blockem-words" >' . htmlspecialchars($words) . '</textarea>';
- $s .= '</div><div class="clear"></div>';
-
- $s .= '<div class="settings-submit-wrapper" ><input type="submit" id="blockem-submit" name="blockem-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
-
- 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)
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return;
}
if (!empty($_POST['blockem-submit'])) {
- DI::pConfig()->set(local_user(), 'blockem', 'words', trim($_POST['blockem-words']));
+ DI::pConfig()->set(Session::getLocalUser(), 'blockem', 'words', trim($_POST['blockem-words']));
}
}
function blockem_prepare_body_content_filter(App $a, array &$hook_data)
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return;
}
$profiles_string = null;
- if (local_user()) {
- $profiles_string = DI::pConfig()->get(local_user(), 'blockem', 'words');
+ if (Session::getLocalUser()) {
+ $profiles_string = DI::pConfig()->get(Session::getLocalUser(), 'blockem', 'words');
}
if ($profiles_string) {
{
global $blockem_words;
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return;
}
- $words = DI::pConfig()->get(local_user(), 'blockem', 'words');
+ $words = DI::pConfig()->get(Session::getLocalUser(), 'blockem', 'words');
if ($words) {
$blockem_words = explode(',', $words);
{
global $blockem_words;
- if (!local_user() || $b['item']['self']) {
+ if (!Session::getLocalUser() || $b['item']['self']) {
return;
}
}
}
-function blockem_module()
-{
-}
+/**
+ * This is a statement rather than an actual function definition. The simple
+ * existence of this method is checked to figure out if the addon offers a
+ * module.
+ */
+function blockem_module() {}
function blockem_init(App $a)
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return;
}
- $words = DI::pConfig()->get(local_user(), 'blockem', 'words');
+ $words = DI::pConfig()->get(Session::getLocalUser(), 'blockem', 'words');
if (array_key_exists('block', $_GET) && $_GET['block']) {
if (strlen($words)) {
$words = implode(',', $newarr);
}
- DI::pConfig()->set(local_user(), 'blockem', 'words', $words);
+ DI::pConfig()->set(Session::getLocalUser(), 'blockem', 'words', $words);
exit();
}