X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=3caf2a6b179ebf916dc8ac7dea5e2e349d10b10c;hb=21769d7390a0bcfb5c74e53c05867ab52a54448b;hp=f1eb47bd3ddf57a0d46e99fc305c63474a443c1a;hpb=f9f284ba708c7f135931f87a922e7716a3dabb85;p=friendica.git diff --git a/include/bbcode.php b/include/bbcode.php index f1eb47bd3d..3caf2a6b17 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -1,26 +1,37 @@ ", ">", $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 = " a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'"; + $URLSearchString = "^\[\]"; // Set up the parameters for a MAIL search string - $MAILSearchString = $URLSearchString . " a-zA-Z0-9\.@"; + $MAILSearchString = $URLSearchString; // Perform URL Search - $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '$1', $Text); - $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.+?)\[/url\])", '$2', $Text); + + + $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%\$\!\+\,]+)/", ' $2', $Text); + + $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '$1', $Text); + $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.+?)\[/url\])", '$2', $Text); //$Text = preg_replace("(\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[/url\])", '$2', $Text); + // Perform MAIL Search $Text = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '$1', $Text); $Text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.+?)\[\/mail\]/", '$2', $Text); @@ -41,10 +52,10 @@ function bbcode($Text) { $Text = preg_replace("(\[o\](.+?)\[\/o\])is",'$1',$Text); // Check for colored text - $Text = preg_replace("(\[color=(.+?)\](.+?)\[\/color\])is","$2",$Text); + $Text = preg_replace("(\[color=(.+?)\](.+?)\[\/color\])is","$2",$Text); // Check for sized text - $Text = preg_replace("(\[size=(.+?)\](.+?)\[\/size\])is","$2",$Text); + $Text = preg_replace("(\[size=(.+?)\](.+?)\[\/size\])is","$2",$Text); // Check for list text $Text = preg_replace("/\[list\](.+?)\[\/list\]/is", '' ,$Text); @@ -69,14 +80,34 @@ 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 + + $Text = preg_replace("/\[video\](.+?)\[\/video\]/", '', $Text); + + $Text = preg_replace("/\[audio\](.+?)\[\/audio\]/", '', $Text); + // [img=widthxheight]image source[/img] - $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '', $Text); - - // Youtube extensions - $Text = preg_replace("/\[youtube\]http:\/\/www.youtube.com\/watch\?v\=(.+?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text); - $Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", '', $Text); + $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '', $Text); + + if (get_pconfig(local_user(), 'oembed', 'use_for_youtube' )==1){ + // use oembed for youtube links + $Text = preg_replace("/\[youtube\]/",'[embed]',$Text); + $Text = preg_replace("/\[\/youtube\]/",'[/embed]',$Text); + } else { + // Youtube extensions + $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.+?)\[\/youtube\]/",'[youtube]$1[/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); + + call_hooks('bbcode',$Text); return $Text; }