fbpost: Improvement in the detection of emtpy quoted areas.

pull/85/head
Michael Vogel 2012-12-03 23:42:14 +01:00
parent 9ef83ffdb4
commit ccac72ee0b
1 changed files with 9 additions and 3 deletions

View File

@ -565,13 +565,15 @@ function fbpost_post_hook(&$a,&$b) {
$bodyparts = explode("\t", $body); $bodyparts = explode("\t", $body);
// Doesn't help with multiple repeats - the problem has to be solved later // Doesn't help with multiple repeats - the problem has to be solved later
if (sizeof($bodyparts) == 3) { if (sizeof($bodyparts) == 3) {
$html = bbcode($bodyparts[2], false, false);
$test = trim(html2plain($html, 0, true));
if (trim($bodyparts[0]) == "") if (trim($bodyparts[0]) == "")
$body = trim($bodyparts[2]); $body = trim($bodyparts[2]);
else if (trim($bodyparts[2]) == "") else if (trim($test) == "")
$body = trim($bodyparts[0]); $body = trim($bodyparts[0]);
else else
$body = trim($bodyparts[0])."\n\n".trim($bodyparts[1])."[quote]".trim($bodyparts[2])."[/quote]"; $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 } else
$body = str_replace("\t", "", $body); $body = str_replace("\t", "", $body);
@ -580,7 +582,11 @@ function fbpost_post_hook(&$a,&$b) {
// Then convert it to plain text // Then convert it to plain text
$msg = trim($b['title']." \n\n".html2plain($html, 0, true)); $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'); $msg = html_entity_decode($msg,ENT_QUOTES,'UTF-8');
// Removing multiple newlines // Removing multiple newlines