From c037a5083ca45738247bb250693f3e8fd08c5424 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 1 Jul 2014 18:38:44 -0700 Subject: optionally allow zrl usage from specific markdown sources --- include/bb2diaspora.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include/bb2diaspora.php') diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 2ac1f43c8..41001d216 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -72,7 +72,7 @@ function bb_tag_preg_replace($pattern, $replace, $name, $s) { // So we'll use that to convert to HTML, then convert the HTML back to bbcode, // and then clean up a few Diaspora specific constructs. -function diaspora2bb($s) { +function diaspora2bb($s,$use_zrl = false) { $s = html_entity_decode($s,ENT_COMPAT,'UTF-8'); @@ -106,7 +106,14 @@ function diaspora2bb($s) { $s = str_replace('♲',html_entity_decode('♲',ENT_QUOTES,'UTF-8'),$s); // Convert everything that looks like a link to a link - $s = preg_replace("/([^\]\=]|^)(https?\:\/\/)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3]$2$3[/url]',$s); + if($use_zrl) { + $s = str_replace(array('[img','/img]'),array('[zmg','/zmg]'),$s); + $s = preg_replace("/([^\]\=]|^)(https?\:\/\/)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[zrl=$2$3]$2$3[/zrl]',$s); + } + else { + $s = preg_replace("/([^\]\=]|^)(https?\:\/\/)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3]$2$3[/url]',$s); + + } //$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3$4]$2$3$4[/url]',$s); $s = bb_tag_preg_replace("/\[url\=?(.*?)\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/url\]/ism",'[youtube]$2[/youtube]','url',$s); -- cgit v1.2.3