From: Michael Vogel Date: Fri, 23 Nov 2012 11:15:40 +0000 (+0100) Subject: fbpost: New behaviour when a picture link is converted. New behaviour for repeated... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b3fa9eb34120bc7af6a873901be2875fdd50e446;p=friendica-addons.git fbpost: New behaviour when a picture link is converted. New behaviour for repeated messages. --- diff --git a/fbpost/fbpost.php b/fbpost/fbpost.php index 9bf4a759..0bafd81e 100644 --- a/fbpost/fbpost.php +++ b/fbpost/fbpost.php @@ -554,18 +554,33 @@ function fbpost_post_hook(&$a,&$b) { } // Convert recycle signs + $body = str_replace("\t", " ", $body); // recycle 1 $recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8'); - $body = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', "\n$2:[quote]", $body)."[/quote]"; + $body = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', "\n\t$2:\t", $body); // recycle 2 (Test) $recycle = html_entity_decode("◌ ", ENT_QUOTES, 'UTF-8'); - $body = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', "\n$2:[quote]", $body)."[/quote]"; + $body = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', "\n\t$2:\t", $body); + + $bodyparts = explode("\t", $body); + // Doesn't help with multiple repeats - the problem has to be solved later + if (sizeof($bodyparts) == 3) { + if (trim($bodyparts[0]) == "") + $body = trim($bodyparts[2]); + else if (trim($bodyparts[2]) == "") + $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); // At first convert the text to html $html = bbcode($body, false, false); // 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 $msg = html_entity_decode($msg,ENT_QUOTES,'UTF-8'); // Removing multiple newlines @@ -629,13 +644,19 @@ function fbpost_post_hook(&$a,&$b) { $postvars = array('access_token' => $fb_token); } else { // message, picture, link, name, caption, description, source, place, tags + if(trim($link) != "") + if (@exif_imagetype($link) != 0) { + $image = $link; + $link = ""; + } + $postvars = array( 'access_token' => $fb_token, 'message' => $msg ); - if(trim($image) != "") { + if(trim($image) != "") $postvars['picture'] = $image; - } + if(trim($link) != "") { $postvars['link'] = $link;