]> git.mxchange.org Git - friendica.git/blobdiff - include/bbcode.php
Bugfix: There were speed problems with inifinite scroll on firefox
[friendica.git] / include / bbcode.php
index 0f8c2df74ebc225c4bb905aa9950e9bfcc5bff25..e63a8d394ec41f6663b3001acd2327ca13b76c10 100644 (file)
@@ -267,9 +267,11 @@ function bb_ShareAttributes($match) {
         preg_match('/posted="(.*?)"/ism', $attributes, $matches);
         if ($matches[1] != "")
                 $posted = $matches[1];
-               $reldate = (($posted) ? " " . relative_date($posted) : '');
 
-        $headline = '<br /><div class="shared_header">';
+       $reldate = (($posted) ? " " . relative_date($posted) : '');
+
+       $headline = '<div class="shared_header">';
+        //$headline = '<br /><div class="shared_header">';
 
        if ($avatar != "")
                $headline .= '<img src="'.$avatar.'" height="32" width="32" >';
@@ -343,11 +345,15 @@ function bb_ShareAttributesSimple2($match) {
 function GetProfileUsername($profile, $username) {
        $friendica = preg_replace("=https?://(.*)/profile/(.*)=ism", "$2@$1", $profile);
        if ($friendica != $profile)
-               return($friendica);
+               return($friendica." (".$username.")");
 
        $diaspora = preg_replace("=https?://(.*)/u/(.*)=ism", "$2@$1", $profile);
        if ($diaspora != $profile)
-               return($diaspora);
+               return($diaspora." (".$username.")");
+
+       $twitter = preg_replace("=https?://twitter.com/(.*)=ism", "$1@twitter.com", $profile);
+       if ($twitter != $profile)
+               return($twitter." (".$username.")");
 
        $StatusnetHost = preg_replace("=https?://(.*)/user/(.*)=ism", "$1", $profile);
        if ($StatusnetHost != $profile) {
@@ -356,7 +362,7 @@ function GetProfileUsername($profile, $username) {
                        $UserData = fetch_url("http://".$StatusnetHost."/api/users/show.json?user_id=".$StatusnetUser);
                        $user = json_decode($UserData);
                        if ($user)
-                               return($user->screen_name."@".$StatusnetHost);
+                               return($user->screen_name."@".$StatusnetHost." (".$username.")");
                }
        }
 
@@ -629,8 +635,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
                $Text = preg_replace_callback("/\[video\](.*?)\[\/video\]/ism", 'tryoembed', $Text);
                $Text = preg_replace_callback("/\[audio\](.*?)\[\/audio\]/ism", 'tryoembed', $Text);
        } else {
-               $Text = preg_replace("/\[video\](.*?)\[\/video\]/", '$1', $Text);
-               $Text = preg_replace("/\[audio\](.*?)\[\/audio\]/", '$1', $Text);
+               $Text = preg_replace("/\[video\](.*?)\[\/video\]/",
+                                       '<a href="$1" target="external-link">$1</a>', $Text);
+               $Text = preg_replace("/\[audio\](.*?)\[\/audio\]/",
+                                       '<a href="$1" target="external-link">$1</a>', $Text);
        }
 
        // html5 video and audio
@@ -655,8 +663,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
        if ($tryoembed)
                $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="' . $a->videowidth . '" height="' . $a->videoheight . '" src="https://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $Text);
        else
-               $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", "https://www.youtube.com/watch?v=$1", $Text);
-
+               $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism",
+                                       '<a href="https://www.youtube.com/watch?v=$1" target="external-link">https://www.youtube.com/watch?v=$1</a>', $Text);
 
        if ($tryoembed) {
                $Text = preg_replace_callback("/\[vimeo\](https?:\/\/player.vimeo.com\/video\/[0-9]+).*?\[\/vimeo\]/ism",'tryoembed',$Text); 
@@ -669,7 +677,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
        if ($tryoembed)
                $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '<iframe width="' . $a->videowidth . '" height="' . $a->videoheight . '" src="https://player.vimeo.com/video/$1" frameborder="0" ></iframe>', $Text);
        else
-               $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", "https://vimeo.com/$1", $Text);
+               $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism",
+                                       '<a href="https://vimeo.com/$1" target="external-link">https://vimeo.com/$1</a>', $Text);
 
 //     $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", '<object width="425" height="350" type="application/x-shockwave-flash" data="http://www.youtube.com/v/$1" ><param name="movie" value="http://www.youtube.com/v/$1"></param><!--[if IE]><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350" /><![endif]--></object>', $Text);