X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fbbcode.php;h=6a44e19ec446e87bcef9b83f53cab95d4af85299;hb=eba9f15daab5e4c2d246aaa7c3d9a0aacc945f01;hp=73e2d67413210a8ad20a30b9b2636d7edf3617a2;hpb=3212bb3de470a0ca946e34464e9b0747d360a977;p=friendica.git
diff --git a/include/bbcode.php b/include/bbcode.php
index 73e2d67413..6a44e19ec4 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -1,10 +1,38 @@
' . 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 ($plaintext){
+ function ($match) use ($simplehtml, $tryoembed){
$attributes = $match[2];
@@ -72,7 +100,19 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
$image = "";
}
- if ($plaintext)
+ 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);
@@ -83,14 +123,18 @@ 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), "', trim($match[3]));
+ $text .= sprintf('
%s
', trim($match[3]));
+ }
}
return($match[1].$text);
@@ -168,6 +212,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]);
@@ -178,7 +224,7 @@ function bb_cleanup_share($shared, $plaintext, $nolink) {
return($shared[0]);
if ($nolink)
- return(trim($shared[1]));
+ return($shared[1]);
$title = "";
$link = "";
@@ -189,6 +235,9 @@ function bb_cleanup_share($shared, $plaintext, $nolink) {
if (isset($bookmark[1][0]))
$link = $bookmark[1][0];
+ 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 = "";
@@ -245,15 +294,20 @@ function stripcode_br_cb($s) {
return '[code]' . str_replace(' ', '', $s[1]) . '[/code]';
}
+function bb_onelinecode_cb($match) {
+ if (strpos($match[1]," ")===false){
+ return "".$match[1]."";
+ }
+ return "".$match[1]."";
+}
+
function tryoembed($match){
- //$url = ((count($match)==2)?$match[1]:$match[2]);
$url = $match[1];
// Always embed the SSL version
$url = str_replace(array("http://www.youtube.com/", "http://player.vimeo.com/"),
array("https://www.youtube.com/", "https://player.vimeo.com/"), $url);
- //logger("tryoembed: $url");
$o = oembed_fetch_url($url);
@@ -263,7 +317,7 @@ function tryoembed($match){
if ($o->type=="error") return $match[0];
$html = oembed_format_object($o);
- return $html; //oembed_iframe($html,$o->width,$o->height);
+ return $html;
}
@@ -425,7 +479,7 @@ function bb_replace_images($body, $images) {
// We're depending on the property of 'foreach' (specified on the PHP website) that
// it loops over the array starting from the first element and going sequentially
// to the last element
- $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '', $newbody);
+ $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '', $newbody);
$cnt++;
}
@@ -488,8 +542,23 @@ function bb_ShareAttributes($share, $simplehtml) {
$reldate = (($posted) ? " " . relative_date($posted) : '');
}
- $userid = GetProfileUsername($profile,$author, false);
- $userid_compact = GetProfileUsername($profile,$author, true);
+ $data = get_contact_details_by_url($profile);
+
+ if (isset($data["name"]) AND isset($data["addr"]))
+ $userid_compact = $data["name"]." (".$data["addr"].")";
+ else
+ $userid_compact = GetProfileUsername($profile,$author, true);
+
+ if (isset($data["addr"]))
+ $userid = $data["addr"];
+ else
+ $userid = GetProfileUsername($profile,$author, false);
+
+ if (isset($data["name"]))
+ $author = $data["name"];
+
+ if (isset($data["photo"]))
+ $avatar = $data["photo"];
$preshare = trim($share[1]);
@@ -504,9 +573,7 @@ function bb_ShareAttributes($share, $simplehtml) {
$text = $preshare.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').' '.$userid_compact.": ".$share[3];
break;
case 3: // Diaspora
- $headline = '