From 0267222fb4a993aefde5c34a70941fe85d6c9eef Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 17 Dec 2012 03:04:13 +0100 Subject: [PATCH] Preparations for shared posts --- fbpost/fbpost.php | 29 ++++++++++++++++++++++++++++- fromgplus/fromgplus.php | 8 ++++++++ statusnet/statusnet.php | 5 ++++- twitter/twitter.php | 3 +++ 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/fbpost/fbpost.php b/fbpost/fbpost.php index 76c5f672..dd8de039 100644 --- a/fbpost/fbpost.php +++ b/fbpost/fbpost.php @@ -345,10 +345,34 @@ function fbpost_jot_nets(&$a,&$b) { $fb_defpost = get_pconfig(local_user(),'facebook','post_by_default'); $selected = ((intval($fb_defpost) == 1) ? ' checked="checked" ' : ''); $b .= '
' - . t('Post to Facebook') . '
'; + . t('Post to Facebook') . ''; } } +function fbpost_ShareAttributes($match) { + + $attributes = $match[1]; + + $author = ""; + preg_match("/author='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $author = $matches[1]; + + preg_match('/author="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $author = $matches[1]; + + $headline = '
'; + + $headline .= sprintf(t('%s:'), $author); + + $headline .= "
"; + + $text = "
".$headline."
".$match[2]."
"; + + return($text); +} + /** * @param App $a @@ -562,6 +586,9 @@ function fbpost_post_hook(&$a,&$b) { $recycle = html_entity_decode("◌ ", ENT_QUOTES, 'UTF-8'); $body = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', "\n\t$2:\t", $body); + // share element + $body = preg_replace_callback("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]/ism","fbpost_ShareAttributes", $body); + $bodyparts = explode("\t", $body); // Doesn't help with multiple repeats - the problem has to be solved later if (sizeof($bodyparts) == 3) { diff --git a/fromgplus/fromgplus.php b/fromgplus/fromgplus.php index d1fac25b..cc4cbb17 100644 --- a/fromgplus/fromgplus.php +++ b/fromgplus/fromgplus.php @@ -331,11 +331,19 @@ function fromgplus_fetch($a, $uid) { //$post .= html2bbcode("♻"); //$post .= fromgplus_html2bbcode("◌"); $post .= " [url=".$item->object->actor->url."]".$item->object->actor->displayName."[/url] \n"; + + /*$post .= "[share author='".$item->object->actor->displayName. + "' profile='".$item->object->actor->url. + "' avatar='".$item->object->actor->image->url. + "' link='".$item->object->url."']\n";*/ + $post .= fromgplus_html2bbcode($item->object->content); if (is_array($item->object->attachments)) $post .= "\n".trim(fromgplus_handleattachments($item)); + //$post .= "[/share]"; + if (isset($item->address)) $location = $item->address; else diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 09d01c4f..d7d490fd 100755 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -435,6 +435,9 @@ function statusnet_shortenmsg($b, $max_char) { $recycle = html_entity_decode("◌ ", ENT_QUOTES, 'UTF-8'); $body = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', "\n", $body); + // remove the share element + $body = preg_replace("/\[share(.*?)\](.*?)\[\/share\]/ism","\n\n$2\n\n",$body); + // At first convert the text to html $html = bbcode($body, false, false); @@ -632,7 +635,7 @@ function statusnet_post_hook(&$a,&$b) { //$result = $dent->post('statuses/update', array('status' => $msg)); $result = $dent->post('statuses/update', $postdata); logger('statusnet_post send, result: ' . print_r($result, true). - "\nmessage: ".$msg, LOGGER_DEBUG."\nOriginal post: ".print_r($b)."\nPost Data: ".print_r($postdata)); + "\nmessage: ".$msg, LOGGER_DEBUG."\nOriginal post: ".print_r($b, true)."\nPost Data: ".print_r($postdata, true)); if ($result->error) { logger('Send to StatusNet failed: "' . $result->error . '"'); } diff --git a/twitter/twitter.php b/twitter/twitter.php index 6a93d9f1..ee3bd0fb 100755 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -294,6 +294,9 @@ function twitter_shortenmsg($b) { $recycle = html_entity_decode("◌ ", ENT_QUOTES, 'UTF-8'); $body = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', "\n", $body); + // remove the share element + $body = preg_replace("/\[share(.*?)\](.*?)\[\/share\]/ism","\n\n$2\n\n",$body); + // At first convert the text to html $html = bbcode($body, false, false); -- 2.39.5