[nsfw] Fix formatting in nsfw.php
parent
a9312d4140
commit
b9c38e9ac3
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Name: NSFW
|
||||
* Description: Collapse posts with inappropriate content
|
||||
|
@ -17,7 +18,6 @@ function nsfw_install()
|
|||
Addon::registerHook('addon_settings_post', 'addon/nsfw/nsfw.php', 'nsfw_addon_settings_post');
|
||||
}
|
||||
|
||||
|
||||
function nsfw_uninstall()
|
||||
{
|
||||
Addon::unregisterHook('prepare_body', 'addon/nsfw/nsfw.php', 'nsfw_prepare_body');
|
||||
|
@ -48,7 +48,6 @@ function nsfw_extract_photos($body)
|
|||
|
||||
$img_start = strpos($body, 'src="data:');
|
||||
$img_end = (($img_start !== false) ? strpos(substr($body, $img_start), '>') : false);
|
||||
|
||||
}
|
||||
|
||||
if (!$cnt) {
|
||||
|
@ -110,7 +109,7 @@ function nsfw_addon_settings_post(&$a, &$b)
|
|||
}
|
||||
}
|
||||
|
||||
function nsfw_prepare_body(&$a, &$b)
|
||||
function nsfw_prepare_body(Friendica\App $a, &$b)
|
||||
{
|
||||
// Don't do the check when there is a content warning
|
||||
if (!empty($b['item']['content-warning'])) {
|
||||
|
@ -125,17 +124,18 @@ function nsfw_prepare_body(&$a, &$b)
|
|||
if (local_user()) {
|
||||
$words = PConfig::get(local_user(), 'nsfw', 'words');
|
||||
}
|
||||
|
||||
if ($words) {
|
||||
$arr = explode(',', $words);
|
||||
$word_list = explode(',', $words);
|
||||
} else {
|
||||
$arr = ['nsfw'];
|
||||
$word_list = ['nsfw'];
|
||||
}
|
||||
|
||||
$found = false;
|
||||
if (count($arr)) {
|
||||
if (count($word_list)) {
|
||||
$body = $b['item']['title'] . "\n" . nsfw_extract_photos($b['html']);
|
||||
|
||||
foreach ($arr as $word) {
|
||||
foreach ($word_list as $word) {
|
||||
$word = trim($word);
|
||||
if (!strlen($word)) {
|
||||
continue;
|
||||
|
@ -164,6 +164,8 @@ function nsfw_prepare_body(&$a, &$b)
|
|||
|
||||
if ($found) {
|
||||
$rnd = random_string(8);
|
||||
$b['html'] = '<div id="nsfw-wrap-' . $rnd . '" class="fakelink" onclick=openClose(\'nsfw-' . $rnd . '\'); >' . L10n::t('%s - Click to open/close', $word) . '</div><div id="nsfw-' . $rnd . '" style="display: none; " >' . $b['html'] . '</div>';
|
||||
$b['html'] = '<div id="nsfw-wrap-' . $rnd . '" class="fakelink" onclick=openClose(\'nsfw-' . $rnd . '\'); >' .
|
||||
L10n::t('%s - Click to open/close', $word) .
|
||||
'</div><div id="nsfw-' . $rnd . '" style="display: none; " >' . $b['html'] . '</div>';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue