X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=nsfw%2Fnsfw.php;h=9f81b29d8333557f669a26dc735a9a23c711616b;hb=7082332c0310bf8d9b656a8f279a30e890803b10;hp=b9240103c2dfdb25abe8eac9efbe386b034da5f9;hpb=c27b1cb66fd0877da0947edfdad1a62dfaf41888;p=friendica-addons.git diff --git a/nsfw/nsfw.php b/nsfw/nsfw.php index b9240103..9f81b29d 100644 --- a/nsfw/nsfw.php +++ b/nsfw/nsfw.php @@ -8,8 +8,7 @@ * */ use Friendica\Core\Hook; -use Friendica\Core\L10n; -use Friendica\Core\PConfig; +use Friendica\DI; function nsfw_install() { @@ -18,14 +17,6 @@ function nsfw_install() Hook::register('addon_settings_post', 'addon/nsfw/nsfw.php', 'nsfw_addon_settings_post'); } -function nsfw_uninstall() -{ - Hook::unregister('prepare_body_content_filter', 'addon/nsfw/nsfw.php', 'nsfw_prepare_body_content_filter'); - Hook::unregister('prepare_body', 'addon/nsfw/nsfw.php', 'nsfw_prepare_body'); - Hook::unregister('addon_settings', 'addon/nsfw/nsfw.php', 'nsfw_addon_settings'); - Hook::unregister('addon_settings_post', 'addon/nsfw/nsfw.php', 'nsfw_addon_settings_post'); -} - // This function isn't perfect and isn't trying to preserve the html structure - it's just a // quick and dirty filter to pull out embedded photo blobs because 'nsfw' seems to come up // inside them quite often. We don't need anything fancy, just pull out the data blob so we can @@ -65,33 +56,33 @@ function nsfw_addon_settings(&$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"; - $enable_checked = (intval(PConfig::get(local_user(), 'nsfw', 'disable')) ? '' : ' checked="checked" '); - $words = PConfig::get(local_user(), 'nsfw', 'words'); + $enable_checked = (intval(DI::pConfig()->get(local_user(), 'nsfw', 'disable')) ? '' : ' checked="checked" '); + $words = DI::pConfig()->get(local_user(), 'nsfw', 'words'); if (!$words) { $words = 'nsfw,'; } $s .= ''; - $s .= '

' . L10n::t('Content Filter (NSFW and more)') . '

'; + $s .= '

' . DI::l10n()->t('Content Filter (NSFW and more)') . '

'; $s .= '
'; $s .= ''; + $s .= '
'; + $s .= '
' . DI::l10n()->t('Use /expression/ to provide regular expressions') . '
'; return; } @@ -102,23 +93,22 @@ function nsfw_addon_settings_post(&$a, &$b) } if (!empty($_POST['nsfw-submit'])) { - PConfig::set(local_user(), 'nsfw', 'words', trim($_POST['nsfw-words'])); + DI::pConfig()->set(local_user(), 'nsfw', 'words', trim($_POST['nsfw-words'])); $enable = (!empty($_POST['nsfw-enable']) ? intval($_POST['nsfw-enable']) : 0); $disable = 1 - $enable; - PConfig::set(local_user(), 'nsfw', 'disable', $disable); - info(L10n::t('NSFW Settings saved.') . EOL); + DI::pConfig()->set(local_user(), 'nsfw', 'disable', $disable); } } function nsfw_prepare_body_content_filter(\Friendica\App $a, &$hook_data) { $words = null; - if (PConfig::get(local_user(), 'nsfw', 'disable')) { + if (DI::pConfig()->get(local_user(), 'nsfw', 'disable')) { return; } if (local_user()) { - $words = PConfig::get(local_user(), 'nsfw', 'words'); + $words = DI::pConfig()->get(local_user(), 'nsfw', 'words'); } if ($words) { @@ -159,9 +149,9 @@ function nsfw_prepare_body_content_filter(\Friendica\App $a, &$hook_data) if ($found) { if ($tag_search) { - $hook_data['filter_reasons'][] = L10n::t('Filtered tag: %s', $word); + $hook_data['filter_reasons'][] = DI::l10n()->t('Filtered tag: %s', $word); } else { - $hook_data['filter_reasons'][] = L10n::t('Filtered word: %s', $word); + $hook_data['filter_reasons'][] = DI::l10n()->t('Filtered word: %s', $word); } } }