From 8d7d46ae7a4a2ff049491f1c4b053fc55e8f0e13 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 14 Jul 2012 19:54:27 +0200 Subject: [PATCH] Bugfix: multiple linefeeds were generated when items where written in the editor. The existing fix didn't really work --- include/bbcode.php | 3 +++ include/items.php | 25 +++++++++++++++++++++++++ include/text.php | 1 + 3 files changed, 29 insertions(+) diff --git a/include/bbcode.php b/include/bbcode.php index 4aac33f11..a90be5de7 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -369,6 +369,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { // oembed tag $Text = oembed_bbcode2html($Text); + // Avoid triple linefeeds through oembed + $Text = str_replace("


", "

", $Text); + // If we found an event earlier, strip out all the event code and replace with a reformatted version. // Replace the event-start section with the entire formatted event. The other bbcode is stripped. // Summary (e.g. title) is required, earlier revisions only required description (in addition to diff --git a/include/items.php b/include/items.php index 724e0ac0f..fff9e5fcf 100755 --- a/include/items.php +++ b/include/items.php @@ -786,6 +786,31 @@ function get_atom_elements($feed,$item) { $res['target'] .= '' . "\n"; } + // This is some experimental stuff. By now retweets are shown with "RT:" + // But: There is data so that the message could be shown similar to native retweets + // There is some better way to parse this array - but it didn't worked for me. + $child = $item->feed->data["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["feed"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["entry"][0]["child"]["http://activitystrea.ms/spec/1.0/"][object][0]["child"]; + if (is_array($child)) { + $message = $child["http://activitystrea.ms/spec/1.0/"]["object"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["content"][0]["data"]; + $author = $child[SIMPLEPIE_NAMESPACE_ATOM_10]["author"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10]; + $uri = $author["uri"][0]["data"]; + $name = $author["name"][0]["data"]; + $avatar = @array_shift($author["link"][2]["attribs"]); + $avatar = $avatar["href"]; + + if (($name != "") and ($uri != "") and ($avatar != "") and ($message != "")) { + $res["owner-name"] = $res["author-name"]; + $res["owner-link"] = $res["author-link"]; + $res["owner-avatar"] = $res["author-avatar"]; + + $res["author-name"] = $name; + $res["author-link"] = $uri; + $res["author-avatar"] = $avatar; + + $res["body"] = html2bbcode($message); + } + } + $arr = array('feed' => $feed, 'item' => $item, 'result' => $res); call_hooks('parse_atom', $arr); diff --git a/include/text.php b/include/text.php index 409d40d59..c3558c641 100644 --- a/include/text.php +++ b/include/text.php @@ -1537,6 +1537,7 @@ function undo_post_tagging($s) { function fix_mce_lf($s) { $s = str_replace("\r\n","\n",$s); + $s = str_replace("\n\n","\n",$s); return $s; }