X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=ef791d9e7cfa3024926852211f7f5e020f7f0556;hb=26eceaacbe883b7ece20c0cfb5c724c8ba1a7d99;hp=25d60647f32f2c8ea96ca0170eb91ff22fc49bdf;hpb=7af5c3c560257322d6a32489f0c1edbff51762eb;p=friendica.git
diff --git a/include/bbcode.php b/include/bbcode.php
index 25d60647f3..ef791d9e7c 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, ENT_QUOTES, 'UTF-8'), 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]); @@ -190,6 +168,8 @@ function bb_remove_share_information($Text, $plaintext = false, $nolink = false) } function bb_cleanup_share($shared, $plaintext, $nolink) { + $shared[1] = trim($shared[1]); + if (!in_array($shared[2], array("type-link", "type-video"))) return($shared[0]); @@ -200,7 +180,7 @@ function bb_cleanup_share($shared, $plaintext, $nolink) { return($shared[0]); if ($nolink) - return(trim($shared[1])); + return($shared[1]); $title = ""; $link = ""; @@ -211,7 +191,11 @@ 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 (($shared[1] != "") AND (strpos($title, $shared[1]) !== false)) + $shared[1] = $title; + + 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) @@ -525,19 +509,21 @@ function bb_ShareAttributes($share, $simplehtml) { $text = $preshare.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').' '.$userid_compact.":
'.trim($share[3])."
'.trim($share[3])."