]> git.mxchange.org Git - friendica-addons.git/commitdiff
fbpost: Improvement in the detection of emtpy quoted areas.
authorMichael Vogel <icarus@dabo.de>
Mon, 3 Dec 2012 22:42:14 +0000 (23:42 +0100)
committerMichael Vogel <icarus@dabo.de>
Mon, 3 Dec 2012 22:42:14 +0000 (23:42 +0100)
fbpost/fbpost.php

index 0bafd81ea0ef116c7f29fa8bbef7e6cd50c55148..76c5f67265626d8086f7dae2da027c6ae34d798f 100644 (file)
@@ -565,13 +565,15 @@ function fbpost_post_hook(&$a,&$b) {
                                $bodyparts = explode("\t", $body);
                                // Doesn't help with multiple repeats - the problem has to be solved later
                                if (sizeof($bodyparts) == 3) {
+                                       $html = bbcode($bodyparts[2], false, false);
+                                       $test = trim(html2plain($html, 0, true));
+
                                        if (trim($bodyparts[0]) == "")
                                                $body = trim($bodyparts[2]);
-                                       else if (trim($bodyparts[2]) == "")
+                                       else if (trim($test) == "")
                                                $body = trim($bodyparts[0]);
                                        else
                                                $body = trim($bodyparts[0])."\n\n".trim($bodyparts[1])."[quote]".trim($bodyparts[2])."[/quote]";
-                                               //$body = trim(str_replace(array(":\t", "\t"), array(":[quote]", ""), $body))."[/quote]";
                                } else
                                        $body = str_replace("\t", "", $body);
 
@@ -580,7 +582,11 @@ function fbpost_post_hook(&$a,&$b) {
 
                                // Then convert it to plain text
                                $msg = trim($b['title']." \n\n".html2plain($html, 0, true));
-                               $msg = str_replace("\n«", "«", $msg); // Quickfix - the original problem lies in the html2plain conversion
+
+                               // Removing useless spaces
+                               if (substr($msg, -2) == "«")
+                                       $msg = trim(substr($msg, 0, -2))."«";
+
                                $msg = html_entity_decode($msg,ENT_QUOTES,'UTF-8');
 
                                // Removing multiple newlines