X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=8545b2ff8253c9b29c9b71d87b8003a383623e3b;hb=6ff5c23d50095e5407bf69f8a4ec2220c5d2d408;hp=5395548f51b90279c6497bc2fcdec0c50893a87b;hpb=3c6bfe603310812a2f922287f58d01fb4ef30cf3;p=friendica.git diff --git a/include/bbcode.php b/include/bbcode.php index 5395548f51..8545b2ff82 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -1,12 +1,40 @@ ' . generate_map(str_replace('/',' ',$match[1])) . '', $match[0]); +} +function bb_map_location($match) { + // the extra space in the following line is intentional + return str_replace($match[0],'
' . generate_named_map($match[1]) . '
', $match[0]); +} + +function bb_attachment($Text, $simplehtml = false, $tryoembed = true) { + $Text = preg_replace_callback("/(.*?)\[attachment(.*?)\](.*?)\[\/attachment\]/ism", + function ($match) use ($simplehtml, $tryoembed){ + + $attributes = $match[2]; $type = ""; preg_match("/type='(.*?)'/ism", $attributes, $matches); @@ -41,7 +69,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, ENT_QUOTES, 'UTF-8'), false, false, true); + $title = str_replace(array("[", "]"), array("[", "]"), $title); $image = ""; if ($type != "video") { @@ -65,7 +95,24 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) { $preview = $matches[1]; } - if ($plaintext) + if (((strpos($match[1], "[img=") !== false) OR (strpos($match[1], "[img]") !== false)) AND ($image != "")) { + $preview = $image; + $image = ""; + } + + if ($simplehtml == 7) { + $title2 = $title; + + $test1 = trim(html_entity_decode($match[1],ENT_QUOTES,'UTF-8')); + $test2 = trim(html_entity_decode($title,ENT_QUOTES,'UTF-8')); + + // If the link description is similar to the text above then don't add the link description + if (($title != "") AND ((strpos($test1,$test2) !== false) OR + (similar_text($test1,$test2) / strlen($title)) > 0.9)) + $title2 = $url; + $text = sprintf('%s
', + $url, $title, $title2); + } elseif (($simplehtml != 4) AND ($simplehtml != 0)) $text = sprintf('%s
', $url, $title); else { $text = sprintf('', $type); @@ -76,17 +123,21 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) { else $oembed = $bookmark[0]; - if (($image != "") AND !strstr(strtolower($oembed), "
', $url, $image, $title); - elseif (($preview != "") AND !strstr(strtolower($oembed), "
', $url, $preview, $title); + if (strstr(strtolower($oembed), "