X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=c2d9326748e8ff61ec696daf95a29b7a1e3fe5dd;hb=072e4146369ae8ec10af961b7e1b25dc491e8f07;hp=44f571450947858598fec51d00619a405536c075;hpb=92156cd8403fa1521ecf3c3f9ed3823c03c73dcd;p=friendica.git diff --git a/include/bbcode.php b/include/bbcode.php index 44f5714509..c2d9326748 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -3,7 +3,7 @@ require_once("include/oembed.php"); // BBcode 2 HTML was written by WAY2WEB.net // extended to work with Mistpark/Friendika - Mike Macgirvin -function bbcode($Text) { +function bbcode($Text,$preserve_nl = false) { // Replace any html brackets with HTML Entities to prevent executing HTML or script // Don't use strip_tags here because it breaks [url] search by replacing & with amp @@ -12,7 +12,10 @@ function bbcode($Text) { $Text = str_replace(">", ">", $Text); // Convert new line chars to html
tags + $Text = nl2br($Text); + if($preserve_nl) + $Text = str_replace(array("\n","\r"), array('',''),$Text); // Set up the parameters for a URL search string $URLSearchString = "^\[\]"; @@ -77,7 +80,7 @@ function bbcode($Text) { // Images // [img]pathtoimage[/img] - $Text = preg_replace("/\[img\](.+?)\[\/img\]/", '', $Text); + $Text = preg_replace("/\[img\](.+?)\[\/img\]/", '' . t('Image/photo') . '', $Text); // html5 video and audio @@ -87,11 +90,15 @@ function bbcode($Text) { // [img=widthxheight]image source[/img] - $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '', $Text); + $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '', $Text); // Youtube extensions $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.+?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text); - $Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", '', $Text); + $Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.+?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text); + + $Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", '
', $Text); + +// $Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", '
', $Text); // oembed tag $Text = oembed_bbcode2html($Text);