X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=228b75d5abbd711dc26afdfce0492ef300ddcfa9;hb=39d8fec290613cac87c2821b9f7b20fa94d319ca;hp=384fd5ebd90a8aa1b156908143cc5e720705858a;hpb=a29842e3019255efd3f91fc01df29f5837d54fa4;p=friendica.git diff --git a/include/bbcode.php b/include/bbcode.php index 384fd5ebd9..228b75d5ab 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -254,12 +254,22 @@ function bb_ShareAttributes($match) { if ($matches[1] != "") $profile = $matches[1]; + $posted = ""; + preg_match("/posted='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $posted = $matches[1]; + + preg_match('/posted="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $posted = $matches[1]; + $reldate = (($posted) ? " " . relative_date($posted) : ''); + $headline = '
'; if ($avatar != "") $headline .= ''; - $headline .= sprintf(t('%s wrote the following post:'), $profile, $author, $link); + $headline .= sprintf(t('%s wrote the following post'.$reldate.':'), $profile, $author, $link); $headline .= "
"; @@ -310,6 +320,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { // remove some newlines before the general conversion $Text = preg_replace("/\s?\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","[share$1]$2[/share]",$Text); + $Text = preg_replace("/\s?\[quote(.*?)\]\s?(.*?)\s?\[\/quote\]\s?/ism","[quote$1]$2[/quote]",$Text); + + $Text = preg_replace("/\n\[code\]/ism", "[code]", $Text); + $Text = preg_replace("/\[\/code\]\n/ism", "[/code]", $Text); // when the content is meant exporting to other systems then remove the avatar picture since this doesn't really look good on these systems if (!$tryoembed) @@ -324,6 +338,16 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $Text = trim($Text); $Text = str_replace("\r\n","\n", $Text); + + // removing multiplicated newlines +// $search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]"); +// $replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]"); +// do { +// $oldtext = $Text; +// $Text = str_replace($search, $replace, $Text); +// } while ($oldtext != $Text); + + $Text = str_replace(array("\r","\n"), array('
','
'), $Text); if($preserve_nl)