]> git.mxchange.org Git - friendica-addons.git/blobdiff - langfilter/langfilter.php
Merge pull request 'CLD2: Use ISO-639-1 for the language detection' (#1433) from...
[friendica-addons.git] / langfilter / langfilter.php
index 31efad3b6168d6501a1769178fa6880bc0437ffc..e5efa8fbc6e972cf263eee35c07b1984f65783db 100644 (file)
@@ -31,7 +31,7 @@ function langfilter_install()
  * 3rd parse a SMARTY3 template, replacing some translateable strings for the form
  */
 
-function langfilter_addon_settings(App $a, array &$data)
+function langfilter_addon_settings(array &$data)
 {
        if (!DI::userSession()->getLocalUserId()) {
                return;
@@ -67,7 +67,7 @@ function langfilter_addon_settings(App $a, array &$data)
  * 3rd save the settings to the DB for later usage
  */
 
-function langfilter_addon_settings_post(App $a, array &$b)
+function langfilter_addon_settings_post(array &$b)
 {
        if (!DI::userSession()->getLocalUserId()) {
                return;
@@ -98,7 +98,7 @@ function langfilter_addon_settings_post(App $a, array &$b)
  *     expand it again.
  */
 
-function langfilter_prepare_body_content_filter(App $a, &$hook_data)
+function langfilter_prepare_body_content_filter(&$hook_data)
 {
        $logged_user = DI::userSession()->getLocalUserId();
        if (!$logged_user) {
@@ -107,7 +107,7 @@ function langfilter_prepare_body_content_filter(App $a, &$hook_data)
 
        // Never filter own messages
        // TODO: find a better way to extract this
-       $logged_user_profile = DI::baseUrl()->get() . '/profile/' . $a->getLoggedInUserNickname();
+       $logged_user_profile = DI::baseUrl() . '/profile/' . DI::userSession()->getLocalUserNickname();
        if ($logged_user_profile == $hook_data['item']['author-link']) {
                return;
        }
@@ -122,7 +122,7 @@ function langfilter_prepare_body_content_filter(App $a, &$hook_data)
        $naked_body = strip_tags(
                $hook_data['item']['rendered-html']
                ??''?: // Equivalent of !empty()
-               BBCode::convert($hook_data['item']['body'], false, BBCode::ACTIVITYPUB, true)
+               BBCode::convertForUriId($hook_data['item']['uri-id'], $hook_data['item']['body'], BBCode::ACTIVITYPUB)
        );
 
        $naked_body = preg_replace('#\s+#', ' ', trim($naked_body));
@@ -163,7 +163,7 @@ function langfilter_prepare_body_content_filter(App $a, &$hook_data)
                        return;
                }
 
-               $lang = $iso639->languageByCode1($iso2);
+               $lang = $iso639->languageByCode1(substr($iso2, 0, 2));
        } else {
                $opts = $hook_data['item']['postopts'];
                if (!$opts) {