X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=c2ebf35e6308b7464359a8af2b3efe36d13628f7;hb=57c47a8e3660b8b968b36ff7b379f51aa398a684;hp=017673423b50aaa7080cfb1a75a3da890207f070;hpb=b4e8ec2806e41dff138d4f28d2c13ee9d08807cc;p=friendica.git
diff --git a/include/bbcode.php b/include/bbcode.php
index 017673423b..c2ebf35e63 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -3,10 +3,10 @@ require_once("include/oembed.php");
require_once('include/event.php');
function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
- $Text = preg_replace_callback("/\[attachment(.*?)\](.*?)\[\/attachment\]/ism",
+ $Text = preg_replace_callback("/(.*?)\[attachment(.*?)\](.*?)\[\/attachment\]/ism",
function ($match) use ($plaintext){
- $attributes = $match[1];
+ $attributes = $match[2];
$type = "";
preg_match("/type='(.*?)'/ism", $attributes, $matches);
@@ -41,7 +41,9 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
if ($matches[1] != "")
$title = $matches[1];
- $title = htmlentities($title, ENT_QUOTES, 'UTF-8', false);
+ //$title = htmlentities($title, ENT_QUOTES, 'UTF-8', false);
+ $title = bbcode(html_entity_decode($title), false, false, true);
+ $title = str_replace(array("[", "]"), array("[", "]"), $title);
$image = "";
if ($type != "video") {
@@ -65,8 +67,13 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
$preview = $matches[1];
}
+ if (((strpos($match[1], "[img=") !== false) OR (strpos($match[1], "[img]") !== false)) AND ($image != "")) {
+ $preview = $image;
+ $image = "";
+ }
+
if ($plaintext)
- $text = sprintf('%s', $url, $title);
+ $text = sprintf('%s
', $url, $title);
else {
$text = sprintf('', $type);
@@ -83,44 +90,15 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
$text .= $oembed;
- $text .= sprintf('%s
', trim($match[2]));
+ $text .= sprintf('
%s', trim($match[3])); } - return($text); + return($match[1].$text); },$Text); return($Text); } -/* function bb_rearrange_link($shared) { - if ($shared[1] != "type-link") - return($shared[0]); - - $newshare = trim($shared[2]); - $newshare = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $newshare); - - if (!strpos($shared[0], "[bookmark")) - $newshare = preg_replace("/\[url\=(.*?)\](.*?)\[\/url\]/ism", '[bookmark=$1]$2[/bookmark]', $newshare, 1); - - preg_match("/\[img\](.*?)\[\/img\]/ism", $newshare, $matches); - - if ($matches) { - $newshare = str_replace($matches[0], '', $newshare); - $newshare = "[img]".$matches[1]."[/img]\n".$newshare; - } - - $search = array("\n\n", "\n ", " \n"); - $replace = array("\n", "\n", "\n"); - do { - $oldtext = $newshare; - $newshare = str_replace($search, $replace, $newshare); - } while ($oldtext != $newshare); - - $newshare = "[class=type-link]".$newshare."[/class]"; - - return($newshare); -} */ - function bb_rearrange_share($shared) { if (!in_array(strtolower($shared[2]), array("type-link", "type-audio", "type-video"))) return($shared[0]); @@ -211,7 +189,8 @@ function bb_cleanup_share($shared, $plaintext, $nolink) { if (isset($bookmark[1][0])) $link = $bookmark[1][0]; - if (($title != "") AND (strpos($shared[1],$title) !== false)) + if (($title != "") AND ((strpos($shared[1],$title) !== false) OR + (similar_text($shared[1],$title) / strlen($title)) > 0.9)) $title = ""; // if (strpos($shared[1],$link) !== false) @@ -534,10 +513,14 @@ function bb_ShareAttributes($share, $simplehtml) { if ($text != "") $text .= "
'.trim($share[3])."
'.trim($share[3])."