]> git.mxchange.org Git - friendica.git/blobdiff - include/bbcode.php
API: Show shared messages as repeated messages, improvements with nick names
[friendica.git] / include / bbcode.php
index ff0d32772b8f942b4d0b9e5aa6c17b4057483088..b5936aea4820a37ac4b3a527db7116e3149acd2a 100644 (file)
@@ -378,7 +378,7 @@ function GetProfileUsername($profile, $username) {
        // BBcode 2 HTML was written by WAY2WEB.net
        // extended to work with Mistpark/Friendica - Mike Macgirvin
 
-function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = false) {
+function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = false, $forplaintext = false) {
 
        $stamp1 = microtime(true);
 
@@ -462,8 +462,11 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
 
 
        // Perform URL Search
-
-       $Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" target="external-link">$2</a>', $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="external-link">$2</a>', $Text);
+       else
+               $Text = preg_replace("(\[url\](.*?)\[\/url\])ism","$1",$Text);
 
        if ($tryoembed)
                $Text = preg_replace_callback("/\[bookmark\=([^\]]*)\].*?\[\/bookmark\]/ism",'tryoembed',$Text);