From 4cae5249d4e037459838c16ba3d81aa99a2bc52c Mon Sep 17 00:00:00 2001 From: zottel Date: Wed, 30 Oct 2013 22:29:25 +0100 Subject: Allow setting of title in rpost tag with [rpost=title]body[/rpost] --- include/bbcode.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include/bbcode.php') diff --git a/include/bbcode.php b/include/bbcode.php index de8a34b80..48e13b06f 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -179,7 +179,11 @@ function bb_ShareAttributesSimple($match) { } function rpost_callback($match) { - return str_replace($match[0],get_rpost_path(get_app()->get_observer()) . '&body=' . urlencode($match[1]),$match[0]); + if (count($match) == 3) { + return str_replace($match[0],get_rpost_path(get_app()->get_observer()) . '&title=' . urlencode($match[1]) . '&body=' . urlencode($match[2]),$match[0]); + } else { + return str_replace($match[0],get_rpost_path(get_app()->get_observer()) . '&body=' . urlencode($match[1]),$match[0]); + } } @@ -230,6 +234,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $Text = preg_replace("/\[observer\=1\](.*?)\[\/observer\]/ism", '$1', $Text); $Text = preg_replace("/\[observer\=0\].*?\[\/observer\]/ism", '', $Text); $Text = preg_replace_callback("/\[rpost\](.*?)\[\/rpost\]/ism", 'rpost_callback', $Text); + $Text = preg_replace_callback("/\[rpost\=(.*?)\](.*?)\[\/rpost\]/ism", 'rpost_callback', $Text); } else { $Text = preg_replace("/\[observer\=1\].*?\[\/observer\]/ism", '', $Text); $Text = preg_replace("/\[observer\=0\](.*?)\[\/observer\]/ism", '$1', $Text); -- cgit v1.2.3 From 09d5fa6a64e9cf7d3e0cf182dbdd492546db198b Mon Sep 17 00:00:00 2001 From: zottel Date: Thu, 31 Oct 2013 00:08:32 +0100 Subject: Use only one regex for title matching in rpost tag --- include/bbcode.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'include/bbcode.php') diff --git a/include/bbcode.php b/include/bbcode.php index 48e13b06f..9ca8e3f03 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -179,10 +179,10 @@ function bb_ShareAttributesSimple($match) { } function rpost_callback($match) { - if (count($match) == 3) { - return str_replace($match[0],get_rpost_path(get_app()->get_observer()) . '&title=' . urlencode($match[1]) . '&body=' . urlencode($match[2]),$match[0]); + if ($match[2]) { + return str_replace($match[0],get_rpost_path(get_app()->get_observer()) . '&title=' . urlencode($match[2]) . '&body=' . urlencode($match[3]),$match[0]); } else { - return str_replace($match[0],get_rpost_path(get_app()->get_observer()) . '&body=' . urlencode($match[1]),$match[0]); + return str_replace($match[0],get_rpost_path(get_app()->get_observer()) . '&body=' . urlencode($match[3]),$match[0]); } } @@ -233,12 +233,11 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { if ($observer) { $Text = preg_replace("/\[observer\=1\](.*?)\[\/observer\]/ism", '$1', $Text); $Text = preg_replace("/\[observer\=0\].*?\[\/observer\]/ism", '', $Text); - $Text = preg_replace_callback("/\[rpost\](.*?)\[\/rpost\]/ism", 'rpost_callback', $Text); - $Text = preg_replace_callback("/\[rpost\=(.*?)\](.*?)\[\/rpost\]/ism", 'rpost_callback', $Text); + $Text = preg_replace_callback("/\[rpost(=(.*?))?\](.*?)\[\/rpost\]/ism", 'rpost_callback', $Text); } else { $Text = preg_replace("/\[observer\=1\].*?\[\/observer\]/ism", '', $Text); $Text = preg_replace("/\[observer\=0\](.*?)\[\/observer\]/ism", '$1', $Text); - $Text = preg_replace("/\[rpost\](.*?)\[\/rpost\]/ism", '', $Text); + $Text = preg_replace("/\[rpost(=.*?)?\](.*?)\[\/rpost\]/ism", '', $Text); } } -- cgit v1.2.3