]> git.mxchange.org Git - friendica-addons.git/commitdiff
Preparations for shared posts
authorMichael Vogel <icarus@dabo.de>
Mon, 17 Dec 2012 02:04:13 +0000 (03:04 +0100)
committerMichael Vogel <icarus@dabo.de>
Mon, 17 Dec 2012 02:04:13 +0000 (03:04 +0100)
fbpost/fbpost.php
fromgplus/fromgplus.php
statusnet/statusnet.php
twitter/twitter.php

index 76c5f67265626d8086f7dae2da027c6ae34d798f..dd8de039de7fea3b8eda276d9c093092ec223e02 100644 (file)
@@ -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 .= '<div class="profile-jot-net"><input type="checkbox" name="facebook_enable"' . $selected . ' value="1" /> ' 
-                       . t('Post to Facebook') . '</div>';     
+                       . t('Post to Facebook') . '</div>';
        }
 }
 
+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 = '<div class="shared_header">';
+
+        $headline .= sprintf(t('%s:'), $author);
+
+        $headline .= "</div>";
+
+        $text = "<br />".$headline."</strong><blockquote>".$match[2]."</blockquote>";
+
+        return($text);
+}
+
 
 /**
  * @param App $a
@@ -562,6 +586,9 @@ function fbpost_post_hook(&$a,&$b) {
                                $recycle = html_entity_decode("&#x25CC; ", 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) {
index d1fac25b078a9cd670f948fdadfa1d28332b12ed..cc4cbb17b097cbc50bb1ed4f83c188f68abc40e5 100644 (file)
@@ -331,11 +331,19 @@ function fromgplus_fetch($a, $uid) {
                                        //$post .= html2bbcode("&#x267B;");
                                        //$post .= fromgplus_html2bbcode("&#x25CC;");
                                        $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
index 09d01c4f4e4e1fadbd4befe3c9b0b9a7a96a6b25..d7d490fdd3e3aa70235c0f3724e06954fc1c267b 100755 (executable)
@@ -435,6 +435,9 @@ function statusnet_shortenmsg($b, $max_char) {
        $recycle = html_entity_decode("&#x25CC; ", 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 . '"');
                     }
index 6a93d9f15303c059c6928d0e14b0b193285afc60..ee3bd0fbda5467dcc85897f8e327a5bc9ff905c1 100755 (executable)
@@ -294,6 +294,9 @@ function twitter_shortenmsg($b) {
        $recycle = html_entity_decode("&#x25CC; ", 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);