]> git.mxchange.org Git - friendica-addons.git/blobdiff - fromgplus/fromgplus.php
Merge pull request #151 from tazmandevil/master
[friendica-addons.git] / fromgplus / fromgplus.php
index 5d0e86c3d92f00a3d5db725ad12ad3a9f270b99b..9fc13c5ec97e8bad1946831d7cf9a5514d938ae7 100644 (file)
@@ -109,6 +109,7 @@ function fromgplus_post($a, $uid, $source, $body, $location) {
        $_SESSION['authenticated'] = true;
        $_SESSION['uid'] = $uid;
 
+       unset($_REQUEST);
        $_REQUEST['type'] = 'wall';
        $_REQUEST['api_source'] = true;
 
@@ -123,11 +124,16 @@ function fromgplus_post($a, $uid, $source, $body, $location) {
        $_REQUEST['body'] = $body;
        $_REQUEST['location'] = $location;
 
-        logger('fromgplus: posting for user '.$uid);
+       if (($_REQUEST['title'] == "") AND ($_REQUEST['body'] == "")) {
+               logger('fromgplus: empty post for user '.$uid." ".print_r($_REQUEST, true));
+               return;
+       }
 
        require_once('mod/item.php');
        //print_r($_REQUEST);
+        logger('fromgplus: posting for user '.$uid." ".print_r($_REQUEST, true));
        item_post($a);
+        logger('fromgplus: done for user '.$uid);
 }
 
 function fromgplus_html2bbcode($html) {
@@ -212,6 +218,14 @@ function fromgplus_cleanupgoogleproxy($fullImage, $image) {
        return($cleaned);
 }
 
+function fromgplus_cleantext($text) {
+       $text = strip_tags($text);
+       $text = html_entity_decode($text);
+       $text = trim($text);
+       $text = str_replace(array("\n", "\r", " "), array("", "", ""), $text);
+       return($text);
+}
+
 function fromgplus_handleattachments($item, $displaytext) {
        $post = "";
        $quote = "";
@@ -233,9 +247,11 @@ function fromgplus_handleattachments($item, $displaytext) {
                                $post .= "\n\n[bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]\n";
 
                                $images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
-                               if ($images["preview"] != "")
-                                       $post .= "\n[url=".$images["full"]."][img]".$images["preview"]."[/img][/url]\n";
-                               elseif ($images["full"] != "")
+                               //if ($images["preview"] != "")
+                               //      $post .= "\n[url=".$images["full"]."][img]".$images["preview"]."[/img][/url]\n";
+                               //elseif ($images["full"] != "")
+                               //      $post .= "\n[img]".$images["full"]."[/img]\n";
+                               if ($images["full"] != "")
                                        $post .= "\n[img]".$images["full"]."[/img]\n";
 
                                //$post .= "[quote]".trim(fromgplus_html2bbcode($attachment->content))."[/quote]";
@@ -251,7 +267,7 @@ function fromgplus_handleattachments($item, $displaytext) {
                                elseif ($images["full"] != "")
                                        $post .= "\n[img]".$images["full"]."[/img]\n";
 
-                               if (($attachment->displayName != "") AND ($attachment->displayName != $displaytext))
+                               if (($attachment->displayName != "") AND (fromgplus_cleantext($attachment->displayName) != fromgplus_cleantext($displaytext)))
                                        $post .= fromgplus_html2bbcode($attachment->displayName)."\n";
                                break;