mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-22 22:23:44 +00:00
fbpost: New behaviour when a picture link is converted. New behaviour for repeated messages.
This commit is contained in:
parent
23ca42a056
commit
b3fa9eb341
1 changed files with 25 additions and 4 deletions
|
@ -554,18 +554,33 @@ function fbpost_post_hook(&$a,&$b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert recycle signs
|
// Convert recycle signs
|
||||||
|
$body = str_replace("\t", " ", $body);
|
||||||
// recycle 1
|
// recycle 1
|
||||||
$recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
|
$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 2 (Test)
|
||||||
$recycle = html_entity_decode("◌ ", ENT_QUOTES, 'UTF-8');
|
$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
|
// At first convert the text to html
|
||||||
$html = bbcode($body, false, false);
|
$html = bbcode($body, false, false);
|
||||||
|
|
||||||
// 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
|
||||||
$msg = html_entity_decode($msg,ENT_QUOTES,'UTF-8');
|
$msg = html_entity_decode($msg,ENT_QUOTES,'UTF-8');
|
||||||
|
|
||||||
// Removing multiple newlines
|
// Removing multiple newlines
|
||||||
|
@ -629,13 +644,19 @@ function fbpost_post_hook(&$a,&$b) {
|
||||||
$postvars = array('access_token' => $fb_token);
|
$postvars = array('access_token' => $fb_token);
|
||||||
} else {
|
} else {
|
||||||
// message, picture, link, name, caption, description, source, place, tags
|
// message, picture, link, name, caption, description, source, place, tags
|
||||||
|
if(trim($link) != "")
|
||||||
|
if (@exif_imagetype($link) != 0) {
|
||||||
|
$image = $link;
|
||||||
|
$link = "";
|
||||||
|
}
|
||||||
|
|
||||||
$postvars = array(
|
$postvars = array(
|
||||||
'access_token' => $fb_token,
|
'access_token' => $fb_token,
|
||||||
'message' => $msg
|
'message' => $msg
|
||||||
);
|
);
|
||||||
if(trim($image) != "") {
|
if(trim($image) != "")
|
||||||
$postvars['picture'] = $image;
|
$postvars['picture'] = $image;
|
||||||
}
|
|
||||||
if(trim($link) != "") {
|
if(trim($link) != "") {
|
||||||
$postvars['link'] = $link;
|
$postvars['link'] = $link;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue