aboutsummaryrefslogtreecommitdiffstats
path: root/include/bb2diaspora.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-07-01 18:38:44 -0700
committerfriendica <info@friendica.com>2014-07-01 18:38:44 -0700
commitc037a5083ca45738247bb250693f3e8fd08c5424 (patch)
tree77cb5de90e01ac3a7760f6100a2812e2b2d18b31 /include/bb2diaspora.php
parentfc69220b94efb39169e401b31e70904ac3294255 (diff)
downloadvolse-hubzilla-c037a5083ca45738247bb250693f3e8fd08c5424.tar.gz
volse-hubzilla-c037a5083ca45738247bb250693f3e8fd08c5424.tar.bz2
volse-hubzilla-c037a5083ca45738247bb250693f3e8fd08c5424.zip
optionally allow zrl usage from specific markdown sources
Diffstat (limited to 'include/bb2diaspora.php')
-rw-r--r--include/bb2diaspora.php11
1 files changed, 9 insertions, 2 deletions
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('&#x2672;',html_entity_decode('&#x2672;',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);