X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=c2ebf35e6308b7464359a8af2b3efe36d13628f7;hb=57c47a8e3660b8b968b36ff7b379f51aa398a684;hp=75aa4fd89f08acd13104e5cbb631a6feebf3ddc7;hpb=faf8afe65cbbed02d1ae7f86bd8b36ec86d1b140;p=friendica.git
diff --git a/include/bbcode.php b/include/bbcode.php
index 75aa4fd89f..c2ebf35e63 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -3,10 +3,10 @@ require_once("include/oembed.php");
require_once('include/event.php');
function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
- $Text = preg_replace_callback("/\[attachment(.*?)\](.*?)\[\/attachment\]/ism",
+ $Text = preg_replace_callback("/(.*?)\[attachment(.*?)\](.*?)\[\/attachment\]/ism",
function ($match) use ($plaintext){
- $attributes = $match[1];
+ $attributes = $match[2];
$type = "";
preg_match("/type='(.*?)'/ism", $attributes, $matches);
@@ -41,7 +41,9 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
if ($matches[1] != "")
$title = $matches[1];
- $title = htmlentities($title, ENT_QUOTES, 'UTF-8', false);
+ //$title = htmlentities($title, ENT_QUOTES, 'UTF-8', false);
+ $title = bbcode(html_entity_decode($title), false, false, true);
+ $title = str_replace(array("[", "]"), array("[", "]"), $title);
$image = "";
if ($type != "video") {
@@ -65,8 +67,13 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
$preview = $matches[1];
}
+ if (((strpos($match[1], "[img=") !== false) OR (strpos($match[1], "[img]") !== false)) AND ($image != "")) {
+ $preview = $image;
+ $image = "";
+ }
+
if ($plaintext)
- $text = sprintf('%s', $url, $title);
+ $text = sprintf('%s
', $url, $title);
else {
$text = sprintf('', $type);
@@ -83,44 +90,15 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
$text .= $oembed;
- $text .= sprintf('%s
', trim($match[2]));
+ $text .= sprintf('
%s', trim($match[3])); } - return($text); + return($match[1].$text); },$Text); return($Text); } -/* function bb_rearrange_link($shared) { - if ($shared[1] != "type-link") - return($shared[0]); - - $newshare = trim($shared[2]); - $newshare = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $newshare); - - if (!strpos($shared[0], "[bookmark")) - $newshare = preg_replace("/\[url\=(.*?)\](.*?)\[\/url\]/ism", '[bookmark=$1]$2[/bookmark]', $newshare, 1); - - preg_match("/\[img\](.*?)\[\/img\]/ism", $newshare, $matches); - - if ($matches) { - $newshare = str_replace($matches[0], '', $newshare); - $newshare = "[img]".$matches[1]."[/img]\n".$newshare; - } - - $search = array("\n\n", "\n ", " \n"); - $replace = array("\n", "\n", "\n"); - do { - $oldtext = $newshare; - $newshare = str_replace($search, $replace, $newshare); - } while ($oldtext != $newshare); - - $newshare = "[class=type-link]".$newshare."[/class]"; - - return($newshare); -} */ - function bb_rearrange_share($shared) { if (!in_array(strtolower($shared[2]), array("type-link", "type-audio", "type-video"))) return($shared[0]); @@ -152,9 +130,9 @@ function bb_rearrange_share($shared) { if ($matches) $description = trim($matches[1]); - $url = htmlentities($url, ENT_QUOTES, 'UTF-8', false); - $title = htmlentities($title, ENT_QUOTES, 'UTF-8', false); - $preview = htmlentities($preview, ENT_QUOTES, 'UTF-8', false); + $url = str_replace(array("[", "]"), array("[", "]"), htmlentities($url, ENT_QUOTES, 'UTF-8', false)); + $title = str_replace(array("[", "]"), array("[", "]"), htmlentities($title, ENT_QUOTES, 'UTF-8', false)); + $preview = str_replace(array("[", "]"), array("[", "]"), htmlentities($preview, ENT_QUOTES, 'UTF-8', false)); $Text = trim($shared[1])."\n[attachment type='".$type."'"; @@ -165,7 +143,7 @@ function bb_rearrange_share($shared) { if ($preview != "") { require_once("include/Photo.php"); $picturedata = get_photo_info($preview); -// echo $preview."*".print_r($picturedata, true)."*"; + if (count($picturedata) > 0) { // if the preview picture is larger than 500 pixels then show it in a larger mode // But only, if the picture isn't higher than large (To prevent huge posts) @@ -211,7 +189,8 @@ function bb_cleanup_share($shared, $plaintext, $nolink) { if (isset($bookmark[1][0])) $link = $bookmark[1][0]; - if (($title != "") AND (strpos($shared[1],$title) !== false)) + if (($title != "") AND ((strpos($shared[1],$title) !== false) OR + (similar_text($shared[1],$title) / strlen($title)) > 0.9)) $title = ""; // if (strpos($shared[1],$link) !== false) @@ -281,8 +260,6 @@ function tryoembed($match){ if (isset($match[2])) $o->title = $match[2]; - //echo "
"; var_dump($match, $url, $o); killme(); - if ($o->type=="error") return $match[0]; $html = oembed_format_object($o); @@ -536,10 +513,14 @@ function bb_ShareAttributes($share, $simplehtml) { if ($text != "") $text .= "
"; - $text .= $headline.''.trim($share[3])."
"; + if (substr(normalise_link($link), 0, 19) != "http://twitter.com/") { + $text .= $headline.''.trim($share[3])."
"; + + if ($link != "") + $text .= '
[l]'; + } else + $text .= '
'.$link.''; - if ($link != "") - $text .= '
[l]'; break; case 4: $headline = '