]> git.mxchange.org Git - friendica.git/commitdiff
Quotes with author are now having an "open/close" link
authorMichael Vogel <icarus@dabo.de>
Sat, 17 Mar 2012 11:15:59 +0000 (12:15 +0100)
committerMichael Vogel <icarus@dabo.de>
Sat, 17 Mar 2012 11:15:59 +0000 (12:15 +0100)
include/bbcode.php
include/text.php

index 9fce895b8d1cf56494b671211a6599edd17c0294..9befbd0f7963a390a2c76776e3989d3aa803b12f 100644 (file)
@@ -198,6 +198,17 @@ function bbcode($Text,$preserve_nl = false) {
        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>';
 
@@ -215,7 +226,7 @@ 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]
index bcd567a15411a3490880c1ce77fd3b1647514c75..0497719498a5d0fafd6668263a2b1fe13442806d 100644 (file)
@@ -968,12 +968,23 @@ function prepare_body($item,$attach = false) {
 
                $pos = strpos($s, $spoilersearch);
                $rnd = random_string(8);
-               $spoilerreplace = '<span id="spoiler-wrap-'.$rnd.'" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'spoiler-'.$rnd.'\');">'.sprintf(t('Click to open/close')).'</span>'.
+               $spoilerreplace = '<br /> <span id="spoiler-wrap-'.$rnd.'" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'spoiler-'.$rnd.'\');">'.sprintf(t('Click to open/close')).'</span>'.
                                        '<blockquote class="spoiler" id="spoiler-'.$rnd.'" style="display: none;">';
-               //$s = str_replace($spoilersearch, $spoilerreplace, $s);
                $s = substr($s, 0, $pos).$spoilerreplace.substr($s, $pos+strlen($spoilersearch));
        }
 
+       // Look for quote with author
+       $authorsearch = '<blockquote class="author">';
+
+       while ((strpos($s, $authorsearch) !== false)) {
+
+               $pos = strpos($s, $authorsearch);
+               $rnd = random_string(8);
+               $authorreplace = '<br /> <span id="author-wrap-'.$rnd.'" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'author-'.$rnd.'\');">'.sprintf(t('Click to open/close')).'</span>'.
+                                       '<blockquote class="author" id="author-'.$rnd.'" style="display: block;">';
+               $s = substr($s, 0, $pos).$authorreplace.substr($s, $pos+strlen($authorsearch));
+       }
+
        $prep_arr = array('item' => $item, 'html' => $s);
        call_hooks('prepare_body_final', $prep_arr);