]> git.mxchange.org Git - friendica-addons.git/blobdiff - fromgplus/fromgplus.php
Merge pull request #194 from annando/master
[friendica-addons.git] / fromgplus / fromgplus.php
index ecdf7656942c77208b4a9d054cfa0e9b28b4281c..d2b496baf8312dd5b1bf1d038c2581c36bb0576c 100644 (file)
@@ -30,15 +30,20 @@ function fromgplus_addon_settings(&$a,&$s) {
        if(! local_user())
                return;
 
+       // If "gpluspost" is installed as well, then the settings are displayed there
+       $result = q("SELECT `installed` FROM `addon` WHERE `name` = 'gpluspost' AND `installed`");
+       if (count($result) > 0)
+               return;
+
        $enable_checked = (intval(get_pconfig(local_user(),'fromgplus','enable')) ? ' checked="checked"' : '');
        $account = get_pconfig(local_user(),'fromgplus','account');
 
        $s .= '<span id="settings_fromgplus_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_fromgplus_expanded\'); openClose(\'settings_fromgplus_inflated\');">';
-       $s .= '<h3>' . t('Google+ Mirroring').'</h3>';
+       $s .= '<img class="connector" src="images/googleplus.png" /><h3 class="connector">'. t('Google+ Mirror').'</h3>';
        $s .= '</span>';
        $s .= '<div id="settings_fromgplus_expanded" class="settings-block" style="display: none;">';
        $s .= '<span class="fakelink" onclick="openClose(\'settings_fromgplus_expanded\'); openClose(\'settings_fromgplus_inflated\');">';
-       $s .= '<h3>' . t('Google+ Mirroring').'</h3>';
+       $s .= '<img class="connector" src="images/googleplus.png" /><h3 class="connector">'. t('Google+ Mirror').'</h3>';
        $s .= '</span>';
 
        $s .= '<div id="fromgplus-wrapper">';
@@ -238,7 +243,7 @@ function fromgplus_cleantext($text) {
        $trash = html_entity_decode("&#xFEFF;", ENT_QUOTES, 'UTF-8');
 
        $text = strip_tags($text);
-       $text = html_entity_decode($text);
+       $text = html_entity_decode($text, ENT_QUOTES);
        $text = trim($text);
        $text = str_replace(array("\n", "\r", " ", $trash), array("", "", "", ""), $text);
        return($text);
@@ -252,28 +257,16 @@ function fromgplus_handleattachments($item, $displaytext) {
        foreach ($item->object->attachments as $attachment) {
                switch($attachment->objectType) {
                        case "video":
-                               $post .= "\n\n[bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]\n";
-
-                               /*$images = cleanupgoogleproxy($attachment->fullImage, $attachment->image);
-                               if ($images["preview"] != "")
-                                       $post .= "\n[url=".$images["full"]."][img]".$images["preview"]."[/img][/url]\n";
-                               elseif ($images["full"] != "")
-                                       $post .= "\n[img]".$images["full"]."[/img]\n";*/
-
+                               $post .= "\n[class=type-video][bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]\n[/class]";
                                break;
 
                        case "article":
-                               $post .= "\n\n[class=type-link][bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]\n";
+                               $post .= "\n[class=type-link][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"] != "")
-                               //      $post .= "\n[img]".$images["full"]."[/img]\n";
                                if ($images["full"] != "")
                                        $post .= "\n[img]".$images["full"]."[/img]";
 
-                               //$post .= "[quote]".trim(fromgplus_html2bbcode($attachment->content))."[/quote]";
                                $quote = trim(fromgplus_html2bbcode($attachment->content));
                                if ($quote != "")
                                        $quote = "\n[quote]".$quote."[/quote]";
@@ -304,13 +297,23 @@ function fromgplus_handleattachments($item, $displaytext) {
                                break;
 
                        case "album":
-                               foreach($attachment->thumbnails as $thumb) {
-                                       $preview = "/w".$thumb->image->width."-h".$thumb->image->height."/";
-                                       $preview2 = "/w".$thumb->image->width."-h".$thumb->image->height."-p/";
-                                       $image = str_replace(array($preview, $preview2), array("/", "/"), $thumb->image->url);
+                               $post .= "\n[class=type-link][bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]";
+
+                               $thumb = $attachment->thumbnails[0];
+                               $post .= "\n[img]".$thumb->image->url."[/img]";
 
-                                       $post .= "\n[url=".$thumb->url."][img]".$image."[/img][/url]\n";
-                               }
+                               $quote = trim(fromgplus_html2bbcode($thumb->description));
+                               if ($quote != "")
+                                       $quote = "\n[quote]".$quote."[/quote]";
+
+                               //foreach($attachment->thumbnails as $thumb) {
+                               //      $preview = "/w".$thumb->image->width."-h".$thumb->image->height."/";
+                               //      $preview2 = "/w".$thumb->image->width."-h".$thumb->image->height."-p/";
+                               //      $image = str_replace(array($preview, $preview2), array("/", "/"), $thumb->image->url);
+
+                               //      $post .= "\n[url=".$thumb->url."][img]".$image."[/img][/url]\n";
+                               //}
+                               $quote .= "[/class]";
                                break;
                        case "audio":
                                $post .= "\n\n[bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]\n";
@@ -333,6 +336,7 @@ function fromgplus_fetch($a, $uid) {
 
        $result = fetch_url("https://www.googleapis.com/plus/v1/people/".$account."/activities/public?alt=json&pp=1&key=".$key."&maxResults=".$maxfetch);
        //$result = file_get_contents("google.txt");
+       //$result = file_get_contents("addon/fromgplus/album.txt");
        //file_put_contents("google.txt", $result);
 
        $activities = json_decode($result);