Merge pull request #253 from annando/1504-new-share

Support for new "share_header" function
This commit is contained in:
Tobias Diekershoff 2015-04-06 14:32:24 +02:00
commit 02e952d57d
3 changed files with 34 additions and 10 deletions

View file

@ -9,6 +9,8 @@
define('FROMGPLUS_DEFAULT_POLL_INTERVAL', 30); // given in minutes define('FROMGPLUS_DEFAULT_POLL_INTERVAL', 30); // given in minutes
require_once('mod/share.php');
function fromgplus_install() { function fromgplus_install() {
register_hook('connector_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings'); register_hook('connector_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings');
register_hook('connector_settings_post', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings_post'); register_hook('connector_settings_post', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings_post');
@ -461,10 +463,17 @@ function fromgplus_fetch($a, $uid) {
$post = fromgplus_html2bbcode($item->annotation)."\n"; $post = fromgplus_html2bbcode($item->annotation)."\n";
if (!intval(get_config('system','old_share'))) { if (!intval(get_config('system','old_share'))) {
$post .= "[share author='".str_replace("'", "'",$item->object->actor->displayName).
"' profile='".$item->object->actor->url. if (function_exists("share_header"))
"' avatar='".$item->object->actor->image->url. $post .= share_header($item->object->actor->displayName, $item->object->actor->url,
"' link='".$item->object->url."']"; $item->object->actor->image->url, "",
datetime_convert('UTC','UTC',$item->object->published),$item->object->url);
else
$post .= "[share author='".str_replace("'", "'",$item->object->actor->displayName).
"' profile='".$item->object->actor->url.
"' avatar='".$item->object->actor->image->url.
"' posted='".datetime_convert('UTC','UTC',$item->object->published).
"' link='".$item->object->url."']";
$post .= fromgplus_html2bbcode($item->object->content); $post .= fromgplus_html2bbcode($item->object->content);

View file

@ -68,8 +68,10 @@ function pumpio_registerclient(&$a, $host) {
if ($application_name == "") if ($application_name == "")
$application_name = $a->get_hostname(); $application_name = $a->get_hostname();
$adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
$params["type"] = "client_associate"; $params["type"] = "client_associate";
$params["contacts"] = $a->config['admin_email']; $params["contacts"] = $adminlist[0];
$params["application_type"] = "native"; $params["application_type"] = "native";
$params["application_name"] = $application_name; $params["application_name"] = $application_name;
$params["logo_url"] = $a->get_baseurl()."/images/friendica-256.png"; $params["logo_url"] = $a->get_baseurl()."/images/friendica-256.png";
@ -302,6 +304,7 @@ function pumpio_settings_post(&$a,&$b) {
set_pconfig(local_user(),'pumpio','mirror',false); set_pconfig(local_user(),'pumpio','mirror',false);
set_pconfig(local_user(),'pumpio','post_by_default',false); set_pconfig(local_user(),'pumpio','post_by_default',false);
set_pconfig(local_user(),'pumpio','lastdate', 0); set_pconfig(local_user(),'pumpio','lastdate', 0);
set_pconfig(local_user(),'pumpio','last_id', '');
} else { } else {
// filtering the username if it is filled wrong // filtering the username if it is filled wrong
$user = $_POST['pumpio_user']; $user = $_POST['pumpio_user'];
@ -1233,6 +1236,7 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
$postarray['body'] = "[share author='".$post->object->author->displayName. $postarray['body'] = "[share author='".$post->object->author->displayName.
"' profile='".$post->object->author->url. "' profile='".$post->object->author->url.
"' avatar='".$post->object->author->image->url. "' avatar='".$post->object->author->image->url.
"' posted='".datetime_convert('UTC','UTC',$post->object->created).
"' link='".$post->links->self->href."']".$postarray['body']."[/share]"; "' link='".$post->links->self->href."']".$postarray['body']."[/share]";
} else { } else {
// Let shares look like wall-to-wall posts // Let shares look like wall-to-wall posts

View file

@ -733,6 +733,7 @@ function twitter_fetchtimeline($a, $uid) {
require_once('mod/item.php'); require_once('mod/item.php');
require_once('include/items.php'); require_once('include/items.php');
require_once('mod/share.php');
require_once('library/twitteroauth.php'); require_once('library/twitteroauth.php');
$connection = new TwitterOAuth($ckey,$csecret,$otoken,$osecret); $connection = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
@ -798,11 +799,20 @@ function twitter_fetchtimeline($a, $uid) {
$converted = twitter_expand_entities($a, $_REQUEST['body'], $post->retweeted_status, true, $picture); $converted = twitter_expand_entities($a, $_REQUEST['body'], $post->retweeted_status, true, $picture);
$_REQUEST['body'] = $converted["body"]; $_REQUEST['body'] = $converted["body"];
$_REQUEST['body'] = "[share author='".$post->retweeted_status->user->name. if (function_exists("share_header"))
"' profile='https://twitter.com/".$post->retweeted_status->user->screen_name. $_REQUEST['body'] = share_header($post->retweeted_status->user->name, "https://twitter.com/".$post->retweeted_status->user->screen_name,
"' avatar='".$post->retweeted_status->user->profile_image_url_https. $post->retweeted_status->user->profile_image_url_https, "",
"' link='https://twitter.com/".$post->retweeted_status->user->screen_name."/status/".$post->retweeted_status->id_str."']". datetime_convert('UTC','UTC',$post->retweeted_status->created_at),
$_REQUEST['body']; "https://twitter.com/".$post->retweeted_status->user->screen_name."/status/".$post->retweeted_status->id_str).
$_REQUEST['body'];
else
$_REQUEST['body'] = "[share author='".$post->retweeted_status->user->name.
"' profile='https://twitter.com/".$post->retweeted_status->user->screen_name.
"' avatar='".$post->retweeted_status->user->profile_image_url_https.
"' posted='".datetime_convert('UTC','UTC',$post->retweeted_status->created_at).
"' link='https://twitter.com/".$post->retweeted_status->user->screen_name."/status/".$post->retweeted_status->id_str."']".
$_REQUEST['body'];
$_REQUEST['body'] .= "[/share]"; $_REQUEST['body'] .= "[/share]";
} else { } else {
$_REQUEST["body"] = $post->text; $_REQUEST["body"] = $post->text;
@ -1446,6 +1456,7 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
$postarray['body'] = "[share author='".$post->retweeted_status->user->name. $postarray['body'] = "[share author='".$post->retweeted_status->user->name.
"' profile='https://twitter.com/".$post->retweeted_status->user->screen_name. "' profile='https://twitter.com/".$post->retweeted_status->user->screen_name.
"' avatar='".$post->retweeted_status->user->profile_image_url_https. "' avatar='".$post->retweeted_status->user->profile_image_url_https.
"' posted='".datetime_convert('UTC','UTC',$post->retweeted_status->created_at).
"' link='https://twitter.com/".$post->retweeted_status->user->screen_name."/status/".$post->retweeted_status->id_str."']". "' link='https://twitter.com/".$post->retweeted_status->user->screen_name."/status/".$post->retweeted_status->id_str."']".
$postarray['body']; $postarray['body'];
$postarray['body'] .= "[/share]"; $postarray['body'] .= "[/share]";