]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Text/BBCode.php
Merge pull request #8647 from annando/annando/issue8619
[friendica.git] / src / Content / Text / BBCode.php
index 84930cccc01fccbe178e3ad4961ae55bed3c8c25..508a325ca1bb2516db9557b268a0dda07059b107 100644 (file)
@@ -1724,7 +1724,15 @@ class BBCode
 
                // Replace non graphical smilies for external posts
                if (!$nosmile && !$for_plaintext) {
-                       $text = Smilies::replace($text);
+                       $oldtext = $text;
+                       $text = Smilies::replace($text);                        
+                       if (DI::config()->get('system', 'big_emojis') && ($simple_html != self::DIASPORA) && ($oldtext != $text)) {
+                               $conv = html_entity_decode(str_replace([' ', "\n", "\r"], '', $text));
+                               // Emojis are always 4 byte Unicode characters
+                               if (strlen($conv) / mb_strlen($conv) == 4) {
+                                       $text = '<span style="font-size: xx-large; line-height: initial;">' . $text . '</span>';
+                               }
+                       }
                }
 
                if (!$for_plaintext) {
@@ -1801,12 +1809,16 @@ class BBCode
                 * - #[url=<anything>]<term>[/url]
                 * - [url=<anything>]#<term>[/url]
                 */
-               $text = preg_replace_callback("/(?:#\[url\=[^\[\]]*\]|\[url\=[^\[\]]*\]#)(.*?)\[\/url\]/ism", function($matches) {
-                       return '#<a href="'
-                               . DI::baseUrl() . '/search?tag=' . rawurlencode($matches[1])
-                               . '" class="tag" rel="tag" title="' . XML::escape($matches[1]) . '">'
-                               . XML::escape($matches[1])
-                               . '</a>';
+               $text = preg_replace_callback("/(?:#\[url\=[^\[\]]*\]|\[url\=[^\[\]]*\]#)(.*?)\[\/url\]/ism", function($matches) use ($simple_html) {
+                       if ($simple_html == BBCode::ACTIVITYPUB) {
+                               return '<a href="' . DI::baseUrl() . '/search?tag=' . rawurlencode($matches[1])
+                                       . '" data-tag="' . XML::escape($matches[1]) . '" rel="tag ugc">#'
+                                       . XML::escape($matches[1]) . '</a>';
+                       } else {
+                               return '#<a href="' . DI::baseUrl() . '/search?tag=' . rawurlencode($matches[1])
+                                       . '" class="tag" rel="tag" title="' . XML::escape($matches[1]) . '">'
+                                       . XML::escape($matches[1]) . '</a>';
+                       }
                }, $text);
 
                // We need no target="_blank" rel="noopener noreferrer" for local links
@@ -2035,7 +2047,7 @@ class BBCode
 
                // Convert it to HTML - don't try oembed
                if ($for_diaspora) {
-                       $text = self::convert($text, false, 3);
+                       $text = self::convert($text, false, self::DIASPORA);
 
                        // Add all tags that maybe were removed
                        if (preg_match_all("/#\[url\=([$url_search_string]*)\](.*?)\[\/url\]/ism", $original_text, $tags)) {
@@ -2049,7 +2061,7 @@ class BBCode
                                $text = $text . " " . $tagline;
                        }
                } else {
-                       $text = self::convert($text, false, 4);
+                       $text = self::convert($text, false, self::CONNECTORS);
                }
 
                // If a link is followed by a quote then there should be a newline before it