X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=62f56558fb6871a233b3122886821a65420e7190;hb=3a9a9e6a1c07c253bfbe6d437d1311497e947086;hp=b2c278013d1e01650231235efef2218406467aa4;hpb=1c47ec35b8092f0d046c6a42c0147c794be9f9ca;p=friendica.git diff --git a/include/bbcode.php b/include/bbcode.php index b2c278013d..62f56558fb 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -38,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"] = ""; @@ -94,26 +99,32 @@ function bb_remove_share_information($Text, $plaintext = false, $nolink = false) return $Text; if ($nolink) - return $data["text"]; + return $data["text"].$data["after"]; - if ($plaintext) + $title = htmlentities($data["title"], ENT_QUOTES, 'UTF-8', false); + $text = htmlentities($data["text"], ENT_QUOTES, 'UTF-8', false); + if ($plaintext OR (($title != "") AND strstr($text, $title))) $data["title"] = $data["url"]; + elseif (($text != "") AND strstr($title, $text)) { + $data["text"] = $data["title"]; + $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"]; if (($data["url"] != "") AND ($data["title"] != "")) $text .= "\n[url=".$data["url"]."]".$data["title"]."[/url]"; - elseif (($link != "")) + elseif (($data["url"] != "")) $text .= "\n".$data["url"]; - return $text; + return $text."\n".$data["after"]; } function bb_cleanstyle($st) { @@ -385,18 +396,17 @@ function bb_ShareAttributes($share, $simplehtml) { $itemcache = get_itemcachepath(); - // relative dates only make sense when they aren't cached - if ($itemcache == "") { - preg_match("/posted='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") - $posted = $matches[1]; + preg_match("/posted='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $posted = $matches[1]; - preg_match('/posted="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $posted = $matches[1]; + preg_match('/posted="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $posted = $matches[1]; + // relative dates only make sense when they aren't cached + if ($itemcache == "") $reldate = (($posted) ? " " . relative_date($posted) : ''); - } $data = get_contact_details_by_url($profile); @@ -478,13 +488,20 @@ function bb_ShareAttributes($share, $simplehtml) { $text .= "

".$link; break; default: - $headline = trim($share[1]).'
'; - if ($avatar != "") - $headline .= ''; - - $headline .= sprintf(t('%s wrote the following post'.$reldate.':'), $profile, $author, $link); - $headline .= "
"; - $text = $headline.'
'.trim($share[3])."
"; + $text = trim($share[1])."\n"; + + $tpl = get_markup_template('shared_content.tpl'); + $text .= replace_macros($tpl, + array( + '$profile' => $profile, + '$avatar' => $avatar, + '$author' => $author, + '$link' => $link, + '$posted' => $posted, + '$reldate' => $reldate, + '$content' => trim($share[3]) + ) + ); break; } return($text); @@ -798,7 +815,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $Text = preg_replace("/([@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $Text); - + elseif (!$simplehtml) + $Text = preg_replace("/([@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", + '$1$3', + $Text); // Bookmarks in red - will be converted to bookmarks in friendica $Text = preg_replace("/#\^\[url\]([$URLSearchString]*)\[\/url\]/ism", '[bookmark=$1]$1[/bookmark]', $Text); @@ -840,6 +860,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal if ($tryoembed) $Text = preg_replace_callback("/\[url\]([$URLSearchString]*)\[\/url\]/ism",'tryoembed',$Text); + $Text = preg_replace("/([#])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", + '$1$3', $Text); + $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '$1', $Text); $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$2', $Text); //$Text = preg_replace("/\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[\/url\]/ism", '$2', $Text);