]> git.mxchange.org Git - friendica.git/blobdiff - include/bbcode.php
Merge remote-tracking branch 'upstream/master'
[friendica.git] / include / bbcode.php
index a7cfa079d1c38d3072a56a3a01fa62c15388d35c..613c2b7db06eec5787d51d893f7d57a66c144ad4 100644 (file)
@@ -254,12 +254,22 @@ function bb_ShareAttributes($match) {
         if ($matches[1] != "")
                 $profile = $matches[1];
 
+        $posted = "";
+        preg_match("/posted='(.*?)'/ism", $attributes, $matches);
+        if ($matches[1] != "")
+                $posted = $matches[1];
+
+        preg_match('/posted="(.*?)"/ism', $attributes, $matches);
+        if ($matches[1] != "")
+                $posted = $matches[1];
+               $reldate = (($posted) ? " " . relative_date($posted) : ''); 
+
         $headline = '<div class="shared_header">';
 
        if ($avatar != "")
                $headline .= '<img src="'.$avatar.'" height="32" width="32" >';
 
-       $headline .= sprintf(t('<span><a href="%s" target="external-link">%s</a> wrote the following <a href="%s" target="external-link">post</a>:</span>'), $profile, $author, $link);
+       $headline .= sprintf(t('<span><a href="%s" target="external-link">%s</a> wrote the following <a href="%s" target="external-link">post</a>'.$reldate.':</span>'), $profile, $author, $link);
 
         $headline .= "</div>";
 
@@ -312,6 +322,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
        $Text = preg_replace("/\s?\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","[share$1]$2[/share]",$Text);
        $Text = preg_replace("/\s?\[quote(.*?)\]\s?(.*?)\s?\[\/quote\]\s?/ism","[quote$1]$2[/quote]",$Text);
 
+       $Text = preg_replace("/\n\[code\]/ism", "[code]", $Text);
+       $Text = preg_replace("/\[\/code\]\n/ism", "[/code]", $Text);
+
        // when the content is meant exporting to other systems then remove the avatar picture since this doesn't really look good on these systems
        if (!$tryoembed)
                $Text = preg_replace("/\[share(.*?)avatar\s?=\s?'.*?'\s?(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","\n[share$1$2]$3[/share]",$Text);
@@ -327,12 +340,13 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
        $Text = str_replace("\r\n","\n", $Text);
 
        // removing multiplicated newlines
-       $search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]");
-       $replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]");
-       do {
-               $oldtext = $Text;
-               $Text = str_replace($search, $replace, $Text);
-       } while ($oldtext != $Text);
+//     $search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]");
+//     $replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]");
+//     do {
+//             $oldtext = $Text;
+//             $Text = str_replace($search, $replace, $Text);
+//     } while ($oldtext != $Text);
+
 
        $Text = str_replace(array("\r","\n"), array('<br />','<br />'), $Text);