X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=a6ffc39c18744c4dd999d994766aede3ae4c1841;hb=c4d3ab68785122ff070c65a444aaa0833b746b2b;hp=fd380edc997582e21810fc8f03b01e07f827b9b2;hpb=291906de5f3074407253241e5ccbb5af633e0c22;p=friendica.git diff --git a/include/bbcode.php b/include/bbcode.php index fd380edc99..a6ffc39c18 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -1,139 +1,164 @@ ' . generate_map(str_replace('/',' ',$match[1])) . '', $match[0]); + return str_replace($match[0], '
' . Map::byCoordinates(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]); + return str_replace($match[0], '
' . Map::byLocation($match[1]) . '
', $match[0]); } -function bb_attachment($Text, $simplehtml = false, $tryoembed = true) { - - $data = get_attachment_data($Text); - if (!$data) - return $Text; +/** + * Processes [attachment] tags + * + * Note: Can produce a [bookmark] tag in the returned string + * + * @brief Processes [attachment] tags + * @param string $return + * @param bool|int $simplehtml + * @param bool $tryoembed + * @return string + */ +function bb_attachment($return, $simplehtml = false, $tryoembed = true) +{ + $data = get_attachment_data($return); + if (!$data) { + return $return; + } if (isset($data["title"])) { $data["title"] = strip_tags($data["title"]); - $data["title"] = str_replace(array("http://", "https://"), "", $data["title"]); + $data["title"] = str_replace(["http://", "https://"], "", $data["title"]); } - if (((strpos($data["text"], "[img=") !== false) OR (strpos($data["text"], "[img]") !== false)) AND ($data["image"] != "")) { + if (((strpos($data["text"], "[img=") !== false) || (strpos($data["text"], "[img]") !== false) || Config::get('system', 'always_show_preview')) && ($data["image"] != "")) { $data["preview"] = $data["image"]; $data["image"] = ""; } + $return = ''; if ($simplehtml == 7) { - $title2 = $data["title"]; - - $test1 = trim(html_entity_decode($data["text"],ENT_QUOTES,'UTF-8')); - $test2 = trim(html_entity_decode($data["title"],ENT_QUOTES,'UTF-8')); - - // If the link description is similar to the text above then don't add the link description - if (($data["title"] != "") AND ((strpos($test1,$test2) !== false) OR - (similar_text($test1,$test2) / strlen($data["title"])) > 0.9)) - $title2 = $data["url"]; - $text = sprintf('%s
', - $data["url"], $data["title"], $title2); - } elseif (($simplehtml != 4) AND ($simplehtml != 0)) - $text = sprintf('%s
', $data["url"], $data["title"]); - else { - $text = sprintf('', $data["type"]); - - $bookmark = array(sprintf('[bookmark=%s]%s[/bookmark]', $data["url"], $data["title"]), $data["url"], $data["title"]); - if ($tryoembed) - $oembed = tryoembed($bookmark); - else - $oembed = $bookmark[0]; - - if (strstr(strtolower($oembed), "