Продолжаю борьбу с леньтяями и пофигистами.
Часто в цитатах присутствуют пустые строки в начале или в конце. Я сделал так, что они удаляются при помещении нового сообщения в БД и при показе старых сообщений.
Код: Выделить всё
--- includes/bbcode.php (revision 304)
+++ includes/bbcode.php (revision 306)
@@ -158,12 +158,12 @@
$text = bbencode_second_pass_code($text, $uid, $bbcode_tpl);
// [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff.
- $text = str_replace("[quote:$uid]", $bbcode_tpl['quote_open'], $text);
- $text = str_replace("[/quote:$uid]", $bbcode_tpl['quote_close'], $text);
+ $text = preg_replace("/\[quote:$uid\](\n|\r|\s)*/s", $bbcode_tpl['quote_open'], $text);
+ $text = preg_replace("/(\n|\r|\s)*\[\/quote:$uid\]/s", $bbcode_tpl['quote_close'], $text);
// New one liner to deal with opening quotes with usernames...
// replaces the two line version that I had here before..
- $text = preg_replace("/\[quote:$uid=\"(.*?)\"\]/si", $bbcode_tpl['quote_username_open'], $text);
+ $text = preg_replace("/\[quote:$uid=\"(.*?)\"\](\n|\r|\s)*/s", $bbcode_tpl['quote_username_open'], $text);
// [list] and [list=x] for (un)ordered lists.
// unordered lists
@@ -264,6 +264,8 @@
$text = preg_replace("#\[tex\](.*?)\[/tex\]#si", "[tex:$uid]\\1[/tex:$uid]", $text);
// [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff.
+ $text = preg_replace("/\[quote(.*?)\](\n|\r|\s)*/s", '[quote\1]', $text);
+ $text = preg_replace("/(\n|\r|\s)*\[\/quote\]/s", '[/quote]', $text);
$text = bbencode_first_pass_pda($text, $uid, '[quote]', '[/quote]', '', false, '');
$text = bbencode_first_pass_pda($text, $uid, '/\[quote=\\\\"(.*?)\\\\"\]/is', '[/quote]', '', false, '', "[quote:$uid=\\\"\\1\\\"]");