]> git.mxchange.org Git - friendica.git/blobdiff - include/bbcode.php
Merge branch 'master', remote-tracking branch 'remotes/upstream/master'
[friendica.git] / include / bbcode.php
index d69cb263f8ecad945c95652f9e320a67fb243537..85d310b75f5ed621164f49dba5e71aa0e96132b4 100644 (file)
@@ -189,8 +189,29 @@ function bbcode($Text,$preserve_nl = false) {
        // Check for [code] text
        $Text = preg_replace("/\[code\](.*?)\[\/code\]/ism","$CodeLayout", $Text);
 
+       // Declare the format for [spoiler] layout
+       $SpoilerLayout = '<blockquote class="spoiler">$1</blockquote>';
+
+       // Check for [spoiler] text
+       // handle nested quotes
+       $endlessloop = 0;
+       while ((strpos($Text, "[/spoiler]") !== false) and (strpos($Text, "[spoiler]") !== false) and (++$endlessloop < 20))
+               $Text = preg_replace("/\[spoiler\](.*?)\[\/spoiler\]/ism","$SpoilerLayout", $Text);
+
+       // Check for [spoiler=Author] text
+
+       $t_wrote = t('$1 wrote:');
+
+       // handle nested quotes
+       $endlessloop = 0;
+       while ((strpos($Text, "[/spoiler]")!== false)  and (strpos($Text, "[spoiler=") !== false) and (++$endlessloop < 20))
+               $Text = preg_replace("/\[spoiler=[\"\']*(.*?)[\"\']*\](.*?)\[\/spoiler\]/ism",
+                                    "<br /><strong class=".'"spoiler"'.">" . $t_wrote . "</strong><blockquote class=".'"spoiler"'.">$2</blockquote>",
+                                    $Text);
+
        // Declare the format for [quote] layout
        $QuoteLayout = '<blockquote>$1</blockquote>';
+
        // Check for [quote] text
        // handle nested quotes
        $endlessloop = 0;
@@ -205,11 +226,12 @@ function bbcode($Text,$preserve_nl = false) {
        $endlessloop = 0;
        while ((strpos($Text, "[/quote]")!== false)  and (strpos($Text, "[quote=") !== false) and (++$endlessloop < 20))
                $Text = preg_replace("/\[quote=[\"\']*(.*?)[\"\']*\](.*?)\[\/quote\]/ism",
-                                    "<blockquote><strong>" . $t_wrote . "</strong> $2</blockquote>",
+                                    "<br /><strong class=".'"author"'.">" . $t_wrote . "</strong><blockquote class=".'"author"'.">$2</blockquote>",
                                     $Text);
 
        // [img=widthxheight]image source[/img]
-       $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="height: $2px; width: $1px;" >', $Text);
+       //$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="height: $2px; width: $1px;" >', $Text);
+       $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="width: $1px;" >', $Text);
 
        // Images
        // [img]pathtoimage[/img]
@@ -276,6 +298,9 @@ function bbcode($Text,$preserve_nl = false) {
        $Text = preg_replace_callback("/\[nobb\](.*?)\[\/nobb\]/ism", 'bb_unspacefy_and_trim',$Text);
        $Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_unspacefy_and_trim',$Text);
 
+
+       $Text = preg_replace('/\[\&amp\;([#a-z0-9]+)\;\]/','&$1;',$Text);
+
        // fix any escaped ampersands that may have been converted into links
        $Text = preg_replace("/\<(.*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism",'<$1$2=$3&$4>',$Text);
        if(strlen($saved_image))