X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbb2diaspora.php;h=d367b6716678ede92306685a5dba102d27c8ee2d;hb=64d0616762efcff413a335f2fdde4d8219d44895;hp=0e001df3508a5682d4fafbb643fe0bb2b488d08f;hpb=95b4bc55bf54c3dffdb714b8a1d8f38cc78355aa;p=friendica.git diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php old mode 100644 new mode 100755 index 0e001df350..d367b67166 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -19,6 +19,8 @@ function diaspora2bb($s) { $s = Markdown($s); $s = html2bbcode($s); // $s = str_replace('*','*',$s); + + $s = preg_replace("/\[url\=?(.*?)\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/url\]/ism",'[youtube]$2[/youtube]',$s); $s = preg_replace("/\[url\=https?:\/\/www.youtube.com\/watch\?v\=(.*?)\].*?\[\/url\]/ism",'[youtube]$1[/youtube]',$s); $s = preg_replace("/\[url\=?(.*?)\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/url\]/ism",'[vimeo]$2[/vimeo]',$s); @@ -27,6 +29,12 @@ function diaspora2bb($s) { // remove duplicate adjacent code tags $s = preg_replace("/(\[code\])+(.*?)(\[\/code\])+/ism","[code]$2[/code]", $s); $s = scale_diaspora_images($s); + + // we seem to get a lot of text smushed together with links from Diaspora. + + $s = preg_replace('/[^ ]\[url\=(.*?)\]/',' [url=$1]' ,$s); + $s = preg_replace('/\[\/url\][^ ]/','[/url] ',$s); + return $s; } @@ -94,6 +102,13 @@ function bb2diaspora($Text,$preserve_nl = false) { // [img]pathtoimage[/img] + // the following was added on 10-January-2012 due to an inability of Diaspora's + // new javascript markdown processor to handle links with images as the link "text" + // It is not optimal and may be removed if this ability is restored in the future + + $Text = preg_replace("/\[url\=([$URLSearchString]*)\]\[img\](.*?)\[\/img\]\[\/url\]/ism", + '![' . t('image/photo') . '](' . '$2' . ')' . "\n" . '[' . t('link') . '](' . '$1' . ')', $Text); + $Text = preg_replace("/\[bookmark\]([$URLSearchString]*)\[\/bookmark\]/ism", '[$1]($1)', $Text); $Text = preg_replace("/\[bookmark\=([$URLSearchString]*)\](.*?)\[\/bookmark\]/ism", '[$2]($1)', $Text); @@ -101,7 +116,9 @@ function bb2diaspora($Text,$preserve_nl = false) { $Text = preg_replace("/\#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[#$2]($1)', $Text); $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[$2]($1)', $Text); + $Text = preg_replace("/\[img\](.*?)\[\/img\]/", '![' . t('image/photo') . '](' . '$1' . ')', $Text); + $Text = preg_replace("/\[img\=(.*?)\](.*?)\[\/img\]/", '![' . t('image/photo') . '](' . '$2' . ')', $Text); // Perform MAIL Search $Text = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '[$1](mailto:$1)', $Text); @@ -228,7 +245,7 @@ function format_event_diaspora($ev) { $bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM - $o = 'Friendika event notification:' . "\n"; + $o = 'Friendica event notification:' . "\n"; $o .= '**' . bb2diaspora($ev['desc']) . '**' . "\n";