From f5db142d93906d9fd33ddcd75dfa56ec90ce3b9e Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 17 Mar 2012 12:15:59 +0100 Subject: [PATCH] Quotes with author are now having an "open/close" link --- include/bbcode.php | 13 ++++++++++++- include/text.php | 15 +++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index 9fce895b8d..9befbd0f79 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -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", + "
" . $t_wrote . "
$2
", + $Text); + // Declare the format for [quote] layout $QuoteLayout = '
$1
'; @@ -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", - "
" . $t_wrote . " $2
", + "
" . $t_wrote . "
$2
", $Text); // [img=widthxheight]image source[/img] diff --git a/include/text.php b/include/text.php index bcd567a154..0497719498 100644 --- a/include/text.php +++ b/include/text.php @@ -968,12 +968,23 @@ function prepare_body($item,$attach = false) { $pos = strpos($s, $spoilersearch); $rnd = random_string(8); - $spoilerreplace = ''.sprintf(t('Click to open/close')).''. + $spoilerreplace = '
'.sprintf(t('Click to open/close')).''. '