]> git.mxchange.org Git - friendica.git/commitdiff
Bookmark links are now looking again like bookmark links
authorMichael Vogel <icarus@dabo.de>
Sat, 28 Nov 2015 06:37:02 +0000 (07:37 +0100)
committerMichael Vogel <icarus@dabo.de>
Sat, 28 Nov 2015 06:37:02 +0000 (07:37 +0100)
include/bbcode.php

index e07b63313a5cb28c607545a14009a9e49e6d770e..98c1f11991208e35ce0bcb4c94aad011dfd77c53 100644 (file)
@@ -99,10 +99,15 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) {
                                $image = "";
                        }
 
-                       if ($simplehtml == 7)
+                       if ($simplehtml == 7) {
+                               $title2 = $title;
+                               // If the link description is similar to the text above then don't add the link description
+                               if (($title != "") AND ((strpos($match[1],$title) !== false) OR
+                                       (similar_text($match[1],$title) / strlen($title)) > 0.9))
+                                       $title2 = $url;
                                $text = sprintf('<a href="%s" title="%s" class="attachment thumbnail" rel="nofollow external">%s</a><br />',
-                                               $url, $title, $title);
-                       elseif (($simplehtml != 4) AND ($simplehtml != 0))
+                                               $url, $title, $title2);
+                       elseif (($simplehtml != 4) AND ($simplehtml != 0))
                                $text = sprintf('<a href="%s" target="_blank">%s</a><br>', $url, $title);
                        else {
                                $text = sprintf('<span class="type-%s">', $type);
@@ -950,11 +955,13 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
        $Text = preg_replace_callback("&\[url=/posts/([^\[\]]*)\](.*)\[\/url\]&Usi", 'bb_DiasporaLinks', $Text);
 
        // if the HTML is used to generate plain text, then don't do this search, but replace all URL of that kind to text
-       if (!$forplaintext)
-               $Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" target="_blank">$2</a>', $Text);
-       else {
-               $Text = preg_replace("(\[url\]([$URLSearchString]*)\[\/url\])ism"," $1 ",$Text);
-               $Text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'bb_RemovePictureLinks', $Text);
+       if ($simplehtml != 7) {
+               if (!$forplaintext)
+                       $Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" target="_blank">$2</a>', $Text);
+               else {
+                       $Text = preg_replace("(\[url\]([$URLSearchString]*)\[\/url\])ism"," $1 ",$Text);
+                       $Text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'bb_RemovePictureLinks', $Text);
+               }
        }
 
        if ($tryoembed)