]> git.mxchange.org Git - friendica.git/blobdiff - include/bbcode.php
Merge pull request #2479 from annando/1604-vier-login
[friendica.git] / include / bbcode.php
index 820a307cb695c06ff02f6c42503c8c677c129fea..70cd22d5f9c0eaa960c3aad0ac18a8f8e8f7a8e6 100644 (file)
@@ -4,6 +4,7 @@ require_once('include/event.php');
 require_once('include/map.php');
 require_once('mod/proxy.php');
 require_once('include/Contact.php');
+require_once('include/plaintext.php');
 
 function bb_PictureCacheExt($matches) {
        if (strpos($matches[3], "data:image/") === 0)
@@ -37,6 +38,11 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) {
        if (!$data)
                return $Text;
 
+       if (isset($data["title"])) {
+               $data["title"] = strip_tags($data["title"]);
+               $data["title"] = str_replace(array("http://", "https://"), "", $data["title"]);
+       }
+
        if (((strpos($data["text"], "[img=") !== false) OR (strpos($data["text"], "[img]") !== false)) AND ($data["image"] != "")) {
                $data["preview"] = $data["image"];
                $data["image"] = "";
@@ -73,9 +79,13 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) {
                        elseif (($data["preview"] != "") AND !strstr(strtolower($oembed), "<img "))
                                $text .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br />', $data["url"], proxy_url($data["preview"]), $data["title"]);
 
-                       $text .= $oembed;
+                       if (($data["type"] == "photo") AND ($data["url"] != "") AND ($data["image"] != ""))
+                               $text .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a>', $data["url"], proxy_url($data["image"]), $data["title"]);
+                       else
+                               $text .= $oembed;
 
-                       $text .= sprintf('<blockquote>%s</blockquote></span>', trim($data["description"]));
+                       if (trim($data["description"]) != "")
+                               $text .= sprintf('<blockquote>%s</blockquote></span>', trim($data["description"]));
                }
        }
        return $data["text"].$text.$data["after"];
@@ -89,17 +99,17 @@ function bb_remove_share_information($Text, $plaintext = false, $nolink = false)
                return $Text;
 
        if ($nolink)
-               return $data["text"];
+               return $data["text"].$data["after"];
 
        if ($plaintext)
                $data["title"] = $data["url"];
 
        if (($data["text"] == "") AND ($data["title"] != "") AND ($data["url"] == ""))
-               return $data["title"];
+               return $data["title"].$data["after"];
 
        // If the link already is included in the post, don't add it again
        if (($data["url"] != "") AND strpos($data["text"], $data["url"]))
-               return $data["text"];
+               return $data["text"].$data["after"];
 
        $text = $data["text"];
 
@@ -108,7 +118,7 @@ function bb_remove_share_information($Text, $plaintext = false, $nolink = false)
        elseif (($link != ""))
                $text .= "\n".$data["url"];
 
-       return $text;
+       return $text.$data["after"];
 }
 
 function bb_cleanstyle($st) {