X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fplaintext.php;h=e18604334b2041f3c0b5fe6f62f28978ae66fd2f;hb=05a13a99b2c89db5d01e205301888a8a5c90108a;hp=a6738ca93b5bfb2d33aac1bd3342ad63a9dbc2f9;hpb=81bcafe28fa31f4110607473503769a83dc90bf1;p=friendica.git diff --git a/include/plaintext.php b/include/plaintext.php index a6738ca93b..e18604334b 100644 --- a/include/plaintext.php +++ b/include/plaintext.php @@ -1,11 +1,15 @@ 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 @@ -25,14 +29,26 @@ 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]; $URLSearchString = "^\[\]"; - if (preg_match("/\[img\]([$URLSearchString]*)\[\/img\]/ism", $attacheddata, $matches)) - $post["image"] = $matches[1]; + if (preg_match("/\[img\]([$URLSearchString]*)\[\/img\]/ism", $attacheddata, $matches)) { + + $picturedata = get_photo_info($matches[1]); + + if (($picturedata[0] >= 500) AND ($picturedata[0] >= $picturedata[1])) + $post["image"] = $matches[1]; + else + $post["preview"] = $matches[1]; + } if (preg_match("/\[bookmark\=([$URLSearchString]*)\](.*?)\[\/bookmark\]/ism", $attacheddata, $matches)) { $post["url"] = $matches[1]; @@ -101,7 +117,7 @@ function get_attachment_data($body) { $url = $matches[1]; if ($url != "") - $data["url"] = $url; + $data["url"] = html_entity_decode($url, ENT_QUOTES, 'UTF-8'); $title = ""; preg_match("/title='(.*?)'/ism", $attributes, $matches); @@ -112,42 +128,36 @@ 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 = str_replace(array("[", "]"), array("[", "]"), $title); - - if ($title != "") + if ($title != "") { + $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); $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; + $data["image"] = html_entity_decode($image, ENT_QUOTES, 'UTF-8'); $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 (($image == "") AND ($preview != "")) - $data["image"] = $preview; - else - $data["preview"] = $preview; + if ($preview != "") + $data["preview"] = html_entity_decode($preview, ENT_QUOTES, 'UTF-8'); $data["description"] = trim($match[3]); @@ -333,7 +343,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'));