X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fplaintext.php;h=92ba8a27564bc9f0b182f6f96a92239528b3314f;hb=39ce0231589b7fffeb501c50d23eb52ca601ebed;hp=a4f6b6bf6825d037a132d44762e212458d37468e;hpb=999ef7f6793f790aefdf8a40e1b0c5cb30b9be7e;p=friendica.git diff --git a/include/plaintext.php b/include/plaintext.php index a4f6b6bf68..92ba8a2756 100644 --- a/include/plaintext.php +++ b/include/plaintext.php @@ -8,7 +8,8 @@ require_once("include/Photo.php"); * @param string $body Message body * @return array * 'type' -> Message type ("link", "video", "photo") - * 'text' -> Text outside of the shared message + * 'text' -> Text before the shared message + * 'after' -> Text after the shared message * 'image' -> Preview image of the message * 'url' -> Url to the attached message * 'title' -> Title of the attachment @@ -28,7 +29,12 @@ function get_old_attachment_data($body) { $post["type"] = substr($data[1], 5); - $post["text"] = trim(str_replace($data[0], "", $body)); + $pos = strpos($body, $data[0]); + if ($pos > 0) { + $post["text"] = trim(substr($body, 0, $pos)); + $post["after"] = trim(substr($body, $pos + strlen($data[0]))); + } else + $post["text"] = trim(str_replace($data[0], "", $body)); $attacheddata = $data[2]; @@ -110,6 +116,8 @@ function get_attachment_data($body) { if ($matches[1] != "") $url = $matches[1]; + $url = html_entity_decode($url, ENT_QUOTES, 'UTF-8'); + if ($url != "") $data["url"] = $url; @@ -122,37 +130,32 @@ function get_attachment_data($body) { if ($matches[1] != "") $title = $matches[1]; - //$title = htmlentities($title, ENT_QUOTES, 'UTF-8', false); $title = bbcode(html_entity_decode($title, ENT_QUOTES, 'UTF-8'), false, false, true); + $title = html_entity_decode($title, ENT_QUOTES, 'UTF-8'); $title = str_replace(array("[", "]"), array("[", "]"), $title); - if ($title != "") $data["title"] = $title; $image = ""; - if ($type != "video") { - preg_match("/image='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") - $image = $matches[1]; - - preg_match('/image="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $image = $matches[1]; - } + preg_match("/image='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $image = $matches[1]; + + preg_match('/image="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $image = $matches[1]; if ($image != "") $data["image"] = $image; $preview = ""; - if ($type != "video") { - preg_match("/preview='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") - $preview = $matches[1]; - - preg_match('/preview="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $preview = $matches[1]; - } + preg_match("/preview='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $preview = $matches[1]; + + preg_match('/preview="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $preview = $matches[1]; if ($preview != "") $data["preview"] = $preview; @@ -341,7 +344,7 @@ function plaintext($a, $b, $limit = 0, $includedlinks = false, $htmlmode = 2, $t } } - $html = bbcode($post["text"], false, false, $htmlmode); + $html = bbcode($post["text"].$post["after"], false, false, $htmlmode); $msg = html2plain($html, 0, true); $msg = trim(html_entity_decode($msg,ENT_QUOTES,'UTF-8'));