Merge branch 'master' of github.com:annando/friendica-addons

This commit is contained in:
Michael 2012-06-18 08:48:33 +02:00
commit 182951f4ee
6 changed files with 33 additions and 25 deletions

View file

@ -941,7 +941,7 @@ function facebook_post_hook(&$a,&$b) {
if($fb_token && ($toplevel || $b['private'] || $reply)) { if($fb_token && ($toplevel || $b['private'] || $reply)) {
logger('facebook: able to post'); logger('facebook: able to post');
require_once('library/facebook.php'); require_once('library/facebook.php');
require_once('include/bbcode.php'); require_once('include/bbcode.php');
$msg = $b['body']; $msg = $b['body'];
@ -1016,7 +1016,7 @@ function facebook_post_hook(&$a,&$b) {
} }
// At first convert the text to html // At first convert the text to html
$html = bbcode($body); $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));
@ -1133,8 +1133,8 @@ function facebook_post_hook(&$a,&$b) {
} else { } else {
// if its only a message and a subject and the message is larger than 500 characters then post it as note // if its only a message and a subject and the message is larger than 500 characters then post it as note
$postvars = array( $postvars = array(
'access_token' => $fb_token, 'access_token' => $fb_token,
'message' => bbcode($b['body']), 'message' => bbcode($b['body'], false, false),
'subject' => $b['title'], 'subject' => $b['title'],
); );
$url = 'https://graph.facebook.com/me/notes'; $url = 'https://graph.facebook.com/me/notes';

View file

@ -167,16 +167,21 @@ function libertree_send(&$a,&$b) {
} }
} }
if(count($tag_arr)) if(count($tag_arr))
$tags = implode(',',$tag_arr); $tags = implode(',',$tag_arr);
$title = $b['title'];
$body = $b['body'];
if(strlen($title))
$body = "[b]".html_entity_decode($title)."[/b]\n\n".$body;
$params = array( $params = array(
'text' => bb2diaspora($b['body']) 'text' => bb2diaspora($body)
// 'token' => $ltree_api_token // 'token' => $ltree_api_token
); );
$result = post_url($ltree_blog,$params); $result = post_url($ltree_blog,$params);
logger('libertree: ' . $result); logger('libertree: ' . $result);
} }
} }

View file

@ -426,15 +426,15 @@ function statusnet_post_hook(&$a,&$b) {
if($ckey && $csecret && $otoken && $osecret) { if($ckey && $csecret && $otoken && $osecret) {
require_once('include/bbcode.php'); require_once('include/bbcode.php');
$dent = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret); $dent = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret);
$max_char = $dent->get_maxlength(); // max. length for a dent $max_char = $dent->get_maxlength(); // max. length for a dent
// we will only work with up to two times the length of the dent // we will only work with up to two times the length of the dent
// we can later send to StatusNet. This way we can "gain" some // we can later send to StatusNet. This way we can "gain" some
// information during shortening of potential links but do not // information during shortening of potential links but do not
// shorten all the links in a 200000 character long essay. // shorten all the links in a 200000 character long essay.
if (! $b['title']=='') { if (! $b['title']=='') {
$tmp = $b['title'] . ' : '. $b['body']; $tmp = $b['title'].": \n".$b['body'];
// $tmp = substr($tmp, 0, 4*$max_char); // $tmp = substr($tmp, 0, 4*$max_char);
} else { } else {
$tmp = $b['body']; // substr($b['body'], 0, 3*$max_char); $tmp = $b['body']; // substr($b['body'], 0, 3*$max_char);
@ -476,7 +476,7 @@ function statusnet_post_hook(&$a,&$b) {
} }
// ok, all the links we want to send out are save, now strip // ok, all the links we want to send out are save, now strip
// away the remaining bbcode // away the remaining bbcode
$msg = strip_tags(bbcode($tmp)); $msg = strip_tags(bbcode($tmp, false, false));
// quotes not working - let's try this // quotes not working - let's try this
$msg = html_entity_decode($msg); $msg = html_entity_decode($msg);
if (( strlen($msg) > $max_char) && $max_char > 0) { if (( strlen($msg) > $max_char) && $max_char > 0) {

View file

@ -170,12 +170,13 @@ function tumblr_send(&$a,&$b) {
$link = ""; $link = "";
$video = false; $video = false;
$title = trim($b['title']);
// Checking for a bookmark // Checking for a bookmark
if(preg_match("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/is",$b['body'],$matches)) { if(preg_match("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/is",$b['body'],$matches)) {
$link = $matches[1]; $link = $matches[1];
if ($b['title'] == '') if ($title == '')
$b['title'] = html_entity_decode($matches[2],ENT_QUOTES,'UTF-8'); $title = html_entity_decode($matches[2],ENT_QUOTES,'UTF-8');
$body = $b['body']; $body = $b['body'];
// splitting the text in two parts: // splitting the text in two parts:
@ -201,20 +202,20 @@ function tumblr_send(&$a,&$b) {
if (($link != '') and $video) { if (($link != '') and $video) {
$params['type'] = "video"; $params['type'] = "video";
$params['embed'] = $link; $params['embed'] = $link;
if ($b['title'] != '') if ($title != '')
$params['caption'] = '<h1><a href="'.$link.'">'.$b['title']. $params['caption'] = '<h1><a href="'.$link.'">'.$title.
"</a></h1><p>".bbcode($body)."</p>"; "</a></h1><p>".bbcode($body)."</p>";
else else
$params['caption'] = bbcode($body); $params['caption'] = bbcode($body);
} else if (($link != '') and !$video) { } else if (($link != '') and !$video) {
$params['type'] = "link"; $params['type'] = "link";
$params['name'] = $b['title']; $params['name'] = $title;
$params['url'] = $link; $params['url'] = $link;
//$params['description'] = bbcode($body); //$params['description'] = bbcode($body);
$params['description'] = bbcode($b["body"]); $params['description'] = bbcode($b["body"]);
} else { } else {
$params['type'] = "regular"; $params['type'] = "regular";
$params['title'] = $b['title']; $params['title'] = $title;
$params['body'] = bbcode($b['body']); $params['body'] = bbcode($b['body']);
} }

View file

@ -290,7 +290,7 @@ function twitter_post_hook(&$a,&$b) {
logger('twitter: we have customer key and oauth stuff, going to send.', LOGGER_DEBUG); logger('twitter: we have customer key and oauth stuff, going to send.', LOGGER_DEBUG);
require_once('library/twitteroauth.php'); require_once('library/twitteroauth.php');
require_once('include/bbcode.php'); require_once('include/bbcode.php');
$tweet = new TwitterOAuth($ckey,$csecret,$otoken,$osecret); $tweet = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
// in theory max char is 140 but T. uses t.co to make links // in theory max char is 140 but T. uses t.co to make links
// longer so we give them 10 characters extra // longer so we give them 10 characters extra
@ -341,7 +341,7 @@ function twitter_post_hook(&$a,&$b) {
} }
// ok, all the links we want to send out are save, now strip // ok, all the links we want to send out are save, now strip
// away the remaining bbcode // away the remaining bbcode
$msg = strip_tags(bbcode($tmp)); $msg = strip_tags(bbcode($tmp, false, false));
// quotes not working - let's try this // quotes not working - let's try this
$msg = html_entity_decode($msg); $msg = html_entity_decode($msg);
if (( strlen($msg) > $max_char) && $max_char > 0) { if (( strlen($msg) > $max_char) && $max_char > 0) {

View file

@ -179,24 +179,26 @@ function wppost_send(&$a,&$b) {
require_once('include/bbcode.php'); require_once('include/bbcode.php');
require_once('include/html2plain.php'); require_once('include/html2plain.php');
$wptitle = trim($b['title']);
// If the title is empty then try to guess // If the title is empty then try to guess
if ($b['title'] == '') { if ($wptitle == '') {
// Take the description from the bookmark // Take the description from the bookmark
if(preg_match("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/is",$b['body'],$matches)) if(preg_match("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/is",$b['body'],$matches))
$b['title'] = $matches[2]; $wptitle = $matches[2];
// If no bookmark is found then take the first line // If no bookmark is found then take the first line
if ($b['title'] == '') { if ($wptitle == '') {
$title = html2plain(bbcode($b['body']), 0, true); $title = html2plain(bbcode($b['body']), 0, true);
$pos = strpos($title, "\n"); $pos = strpos($title, "\n");
if (($pos == 0) or ($pos > 60)) if (($pos == 0) or ($pos > 60))
$pos = 60; $pos = 60;
$b['title'] = substr($title, 0, $pos); $wptitle = substr($title, 0, $pos);
} }
} }
$title = '<title>' . (($b['title']) ? $b['title'] : t('Post from Friendica')) . '</title>'; $title = '<title>' . (($wptitle) ? $wptitle : t('Post from Friendica')) . '</title>';
$post = $title . bbcode($b['body']); $post = $title . bbcode($b['body']);
$wp_backlink = intval(get_pconfig($b['uid'],'wppost','backlink')); $wp_backlink = intval(get_pconfig($b['uid'],'wppost','backlink'));