mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-11 19:08:49 +00:00
Merge pull request #566 from MrPetovan/task/add-content_filter-hook
Add content_filter hook
This commit is contained in:
commit
c4bd245a1a
10 changed files with 119 additions and 112 deletions
|
@ -12,7 +12,7 @@ use Friendica\Core\PConfig;
|
|||
|
||||
function blockem_install()
|
||||
{
|
||||
Addon::registerHook('prepare_body', 'addon/blockem/blockem.php', 'blockem_prepare_body');
|
||||
Addon::registerHook('prepare_body_content_filter', 'addon/blockem/blockem.php', 'blockem_prepare_body_content_filter');
|
||||
Addon::registerHook('display_item', 'addon/blockem/blockem.php', 'blockem_display_item');
|
||||
Addon::registerHook('addon_settings', 'addon/blockem/blockem.php', 'blockem_addon_settings');
|
||||
Addon::registerHook('addon_settings_post', 'addon/blockem/blockem.php', 'blockem_addon_settings_post');
|
||||
|
@ -23,6 +23,7 @@ function blockem_install()
|
|||
|
||||
function blockem_uninstall()
|
||||
{
|
||||
Addon::unregisterHook('prepare_body_content_filter', 'addon/blockem/blockem.php', 'blockem_prepare_body_content_filter');
|
||||
Addon::unregisterHook('prepare_body', 'addon/blockem/blockem.php', 'blockem_prepare_body');
|
||||
Addon::unregisterHook('display_item', 'addon/blockem/blockem.php', 'blockem_display_item');
|
||||
Addon::unregisterHook('addon_settings', 'addon/blockem/blockem.php', 'blockem_addon_settings');
|
||||
|
@ -106,38 +107,33 @@ function blockem_enotify_store(&$a,&$b) {
|
|||
}
|
||||
}
|
||||
|
||||
function blockem_prepare_body(&$a,&$b) {
|
||||
|
||||
if(! local_user())
|
||||
function blockem_prepare_body_content_filter(\Friendica\App $a, &$hook_data)
|
||||
{
|
||||
if (!local_user()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$words = null;
|
||||
if(local_user()) {
|
||||
$words = PConfig::get(local_user(),'blockem','words');
|
||||
$profiles_string = null;
|
||||
if (local_user()) {
|
||||
$profiles_string = PConfig::get(local_user(), 'blockem', 'words');
|
||||
}
|
||||
if($words) {
|
||||
$arr = explode(',',$words);
|
||||
}
|
||||
else {
|
||||
|
||||
if ($profiles_string) {
|
||||
$profiles_array = explode(',', $profiles_string);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
$found = false;
|
||||
if(count($arr)) {
|
||||
foreach($arr as $word) {
|
||||
if(! strlen(trim($word))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(link_compare($b['item']['author-link'],$word)) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
foreach ($profiles_array as $word) {
|
||||
if (link_compare($hook_data['item']['author-link'], trim($word))) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($found) {
|
||||
$rnd = random_string(8);
|
||||
$b['html'] = '<div id="blockem-wrap-' . $rnd . '" class="fakelink" onclick=openClose(\'blockem-' . $rnd . '\'); >' . L10n::t('Hidden content by %s - Click to open/close', $word) . '</div><div id="blockem-' . $rnd . '" style="display: none; " >' . $b['html'] . '</div>';
|
||||
|
||||
if ($found) {
|
||||
$hook_data['filter_reasons'][] = L10n::t('Filtered user: %s', $hook_data['item']['author-name']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-02-09 13:00+0100\n"
|
||||
"POT-Creation-Date: 2018-04-01 11:11-0400\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -17,41 +17,41 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: blockem.php:51 blockem.php:55
|
||||
#: blockem.php:52 blockem.php:56
|
||||
msgid "\"Blockem\""
|
||||
msgstr ""
|
||||
|
||||
#: blockem.php:59
|
||||
#: blockem.php:60
|
||||
msgid ""
|
||||
"Hides user's content by collapsing posts. Also replaces their avatar with "
|
||||
"generic image."
|
||||
msgstr ""
|
||||
|
||||
#: blockem.php:60
|
||||
#: blockem.php:61
|
||||
msgid "Comma separated profile URLS:"
|
||||
msgstr ""
|
||||
|
||||
#: blockem.php:64
|
||||
#: blockem.php:65
|
||||
msgid "Save Settings"
|
||||
msgstr ""
|
||||
|
||||
#: blockem.php:77
|
||||
#: blockem.php:78
|
||||
msgid "BLOCKEM Settings saved."
|
||||
msgstr ""
|
||||
|
||||
#: blockem.php:140
|
||||
#: blockem.php:136
|
||||
#, php-format
|
||||
msgid "Hidden content by %s - Click to open/close"
|
||||
msgid "Filtered user: %s"
|
||||
msgstr ""
|
||||
|
||||
#: blockem.php:193
|
||||
#: blockem.php:189
|
||||
msgid "Unblock Author"
|
||||
msgstr ""
|
||||
|
||||
#: blockem.php:195
|
||||
#: blockem.php:191
|
||||
msgid "Block Author"
|
||||
msgstr ""
|
||||
|
||||
#: blockem.php:227
|
||||
#: blockem.php:223
|
||||
msgid "blockem settings updated"
|
||||
msgstr ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue