X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=13061958c5f12682deb5bc52f87ea5868f9f5a93;hb=ed8cdc7d8502b03ca9096b4d4a4c5fd9d149d08f;hp=33c0721b08e9cda041b7b151d72d8226368791ea;hpb=b072b8f2840769e7ec6a64a17f9a1174e65bc800;p=friendica.git diff --git a/include/bbcode.php b/include/bbcode.php index 33c0721b08..13061958c5 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -1,77 +1,239 @@ ' . generate_map(str_replace('/',' ',$match[1])) . '', $match[0]); +} +function bb_map_location($match) { + // the extra space in the following line is intentional + return str_replace($match[0],'
' . generate_named_map($match[1]) . '
', $match[0]); +} - if (!strpos($shared[0], "[bookmark")) - $newshare = preg_replace("/\[url\=(.*?)\](.*?)\[\/url\]/ism", '[bookmark=$1]$2[/bookmark]', $newshare, 1); +function bb_attachment($Text, $simplehtml = false, $tryoembed = true) { + $Text = preg_replace_callback("/(.*?)\[attachment(.*?)\](.*?)\[\/attachment\]/ism", + function ($match) use ($simplehtml, $tryoembed){ - preg_match("/\[img\](.*?)\[\/img\]/ism", $newshare, $matches); + $attributes = $match[2]; - if ($matches) { - $newshare = str_replace($matches[0], '', $newshare); - $newshare = "[img]".$matches[1]."[/img]\n".$newshare; - } + $type = ""; + preg_match("/type='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $type = strtolower($matches[1]); + + preg_match('/type="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $type = strtolower($matches[1]); + + if ($type == "") + return($match[0]); + + if (!in_array($type, array("link", "audio", "video"))) + return($match[0]); + + $url = ""; + preg_match("/url='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $url = $matches[1]; + + preg_match('/url="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $url = $matches[1]; + + $title = ""; + preg_match("/title='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $title = $matches[1]; + + preg_match('/title="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $title = $matches[1]; + + //$title = htmlentities($title, ENT_QUOTES, 'UTF-8', false); + $title = bbcode(html_entity_decode($title, ENT_QUOTES, 'UTF-8'), false, false, true); + $title = str_replace(array("[", "]"), array("[", "]"), $title); + + $image = ""; + if ($type != "video") { + preg_match("/image='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $image = $matches[1]; + + preg_match('/image="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $image = $matches[1]; + } + + $preview = ""; + if ($type != "video") { + preg_match("/preview='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $preview = $matches[1]; + + preg_match('/preview="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $preview = $matches[1]; + } + + if (((strpos($match[1], "[img=") !== false) OR (strpos($match[1], "[img]") !== false)) AND ($image != "")) { + $preview = $image; + $image = ""; + } - $search = array("\n\n", "\n ", " \n"); - $replace = array("\n", "\n", "\n"); - do { - $oldtext = $newshare; - $newshare = str_replace($search, $replace, $newshare); - } while ($oldtext != $newshare); + if ($simplehtml == 7) + $text = sprintf('%s', + $url, $title, $title); + elseif (($simplehtml != 4) AND ($simplehtml != 0)) + $text = sprintf('%s
', $url, $title); + else { + $text = sprintf('', $type); + + $bookmark = array(sprintf('[bookmark=%s]%s[/bookmark]', $url, $title), $url, $title); + if ($tryoembed) + $oembed = tryoembed($bookmark); + else + $oembed = $bookmark[0]; + + if (strstr(strtolower($oembed), "