X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=8545b2ff8253c9b29c9b71d87b8003a383623e3b;hb=6ff5c23d50095e5407bf69f8a4ec2220c5d2d408;hp=9a3563527ae4bc9eb8d11143391bf5497358e859;hpb=b7a50a24c74184e1d068b457bf1099ea9c2ed405;p=friendica.git
diff --git a/include/bbcode.php b/include/bbcode.php
index 9a3563527a..8545b2ff82 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];
@@ -42,7 +70,7 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
$title = $matches[1];
//$title = htmlentities($title, ENT_QUOTES, 'UTF-8', false);
- $title = bbcode(html_entity_decode($title), false, false, true);
+ $title = bbcode(html_entity_decode($title, ENT_QUOTES, 'UTF-8'), false, false, true);
$title = str_replace(array("[", "]"), array("[", "]"), $title);
$image = "";
@@ -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,25 +294,33 @@ 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);
+ if (!is_object($o))
+ return $match[0];
+
if (isset($match[2]))
$o->title = $match[2];
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 +482,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 +545,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 +576,7 @@ function bb_ShareAttributes($share, $simplehtml) {
$text = $preshare.html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').' '.$userid_compact.": ".$share[3];
break;
case 3: // Diaspora
- $headline = '