]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Text/Plaintext.php
Merge pull request #12381 from annando/issue-11875
[friendica.git] / src / Content / Text / Plaintext.php
index 5c8629f62c88d0713c77696e8247383f520ec0ec..af8e9c00fe1b6f9eb716970c7c837d1a231a11f7 100644 (file)
@@ -27,6 +27,7 @@ use Friendica\Util\Network;
 
 class Plaintext
 {
+       // Assumed length of an URL when shortened via the network's own url shortener (e.g. Twitter)
        const URL_LENGTH = 23;
 
        /**
@@ -113,9 +114,8 @@ class Plaintext
         * @return array Same array structure than \Friendica\Content\Text\BBCode::getAttachedData
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @see   \Friendica\Content\Text\BBCode::getAttachedData
-        *
         */
-       public static function getPost($item, $limit = 0, $includedlinks = false, $htmlmode = BBCode::API, $target_network = '')
+       public static function getPost(array $item, int $limit = 0, bool $includedlinks = false, int $htmlmode = BBCode::MASTODON_API, string $target_network = '')
        {
                // Remove hashtags
                $URLSearchString = '^\[\]';
@@ -303,7 +303,7 @@ class Plaintext
                                $limit += mb_strlen(trim($word)) - self::URL_LENGTH;
                        }
 
-                       if ((mb_strlen($part . $word) > $limit - 8) && (mb_strlen($part . $word . $message) > $limit)) {
+                       if ((mb_strlen($part . $word) > $limit - 8) && ($parts || (mb_strlen($part . $word . $message) > $limit))) {
                                $parts[] = trim($part);
                                $part    = '';
                                $limit   = $baselimit;