X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=8545b2ff8253c9b29c9b71d87b8003a383623e3b;hb=6ff5c23d50095e5407bf69f8a4ec2220c5d2d408;hp=b68a7c5b188ec74c7e181fd9056a2f8e76084fe5;hpb=771d0c4bfab68a13c57b3ada3649d5eead0550fd;p=friendica.git diff --git a/include/bbcode.php b/include/bbcode.php index b68a7c5b18..8545b2ff82 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -3,6 +3,7 @@ require_once("include/oembed.php"); require_once('include/event.php'); require_once('include/map.php'); require_once('mod/proxy.php'); +require_once('include/Contact.php'); function bb_PictureCacheExt($matches) { if (strpos($matches[3], "data:image/") === 0) @@ -310,6 +311,9 @@ function tryoembed($match){ $o = oembed_fetch_url($url); + if (!is_object($o)) + return $match[0]; + if (isset($match[2])) $o->title = $match[2]; @@ -541,8 +545,23 @@ function bb_ShareAttributes($share, $simplehtml) { $reldate = (($posted) ? " " . relative_date($posted) : ''); } - $userid = GetProfileUsername($profile,$author, false); - $userid_compact = GetProfileUsername($profile,$author, true); + $data = get_contact_details_by_url($profile); + + if (isset($data["name"]) AND isset($data["addr"])) + $userid_compact = $data["name"]." (".$data["addr"].")"; + else + $userid_compact = GetProfileUsername($profile,$author, true); + + if (isset($data["addr"])) + $userid = $data["addr"]; + else + $userid = GetProfileUsername($profile,$author, false); + + if (isset($data["name"])) + $author = $data["name"]; + + if (isset($data["photo"])) + $avatar = $data["photo"]; $preshare = trim($share[1]); @@ -842,6 +861,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $Text = preg_replace_callback("/\[nobb\](.*?)\[\/nobb\]/ism", 'bb_spacefy',$Text); $Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_spacefy',$Text); + // Remove the abstract element. It is a non visible element. + $Text = remove_abstract($Text); // Move all spaces out of the tags $Text = preg_replace("/\[(\w*)\](\s*)/ism", '$2[$1]', $Text); @@ -1284,4 +1305,43 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal return trim($Text); } + +/** + * @brief Removes the "abstract" element from the text + * + * @param string $text The text with BBCode + * @return string The same text - but without "abstract" element + */ +function remove_abstract($text) { + $text = preg_replace("/[\s|\n]*\[abstract\].*?\[\/abstract\][\s|\n]*/ism", '', $text); + $text = preg_replace("/[\s|\n]*\[abstract=.*?\].*?\[\/abstract][\s|\n]*/ism", '', $text); + + return $text; +} + +/** + * @brief Returns the value of the "abstract" element + * + * @param string $text The text that maybe contains the element + * @param string $addon The addon for which the abstract is meant for + * @return string The abstract + */ +function fetch_abstract($text, $addon = "") { + $abstract = ""; + $abstracts = array(); + $addon = strtolower($addon); + + if (preg_match_all("/\[abstract=(.*?)\](.*?)\[\/abstract\]/ism",$text, $results, PREG_SET_ORDER)) + foreach ($results AS $result) + $abstracts[strtolower($result[1])] = $result[2]; + + if (isset($abstracts[$addon])) + $abstract = $abstracts[$addon]; + + if ($abstract == "") + if (preg_match("/\[abstract\](.*?)\[\/abstract\]/ism",$text, $result)) + $abstract = $result[1]; + + return $abstract; +} ?>