X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=fromgplus%2Ffromgplus.php;h=5c7e1e2877f7d1db6b56c8fac7935994f0a05a31;hb=f7a444bbbdb005816f77d2c34b7a4978697c7367;hp=a6d3d84ff05d7fe9da6f7660a9afc0581b06e49b;hpb=6509bdcb99c78534080741a8de9ae41e87139cd1;p=friendica-addons.git
diff --git a/fromgplus/fromgplus.php b/fromgplus/fromgplus.php
index a6d3d84f..5c7e1e28 100644
--- a/fromgplus/fromgplus.php
+++ b/fromgplus/fromgplus.php
@@ -30,11 +30,22 @@ 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 .= '
';
- $s .= '
' . t('Google+ Import Settings').'
';
+ $s .= '
';
+ $s .= '![](images/googleplus.png)
'. t('Google+ Mirror').'
';
+ $s .= '';
+ $s .= '
';
+ $s .= '
';
+ $s .= '![](images/googleplus.png)
'. t('Google+ Mirror').'
';
+ $s .= '';
+
$s .= '
';
$s .= '';
@@ -45,7 +56,7 @@ function fromgplus_addon_settings(&$a,&$s) {
$s .= '
';
$s .= '
';
+class="settings-submit" value="' . t('Save Settings') . '" />
';
$s .= '
';
return;
@@ -60,6 +71,10 @@ function fromgplus_addon_settings_post(&$a,&$b) {
set_pconfig(local_user(),'fromgplus','account',trim($_POST['fromgplus-account']));
$enable = ((x($_POST,'fromgplus-enable')) ? intval($_POST['fromgplus-enable']) : 0);
set_pconfig(local_user(),'fromgplus','enable', $enable);
+
+ if (!$enable)
+ del_pconfig(local_user(),'fromgplus','lastdate');
+
info( t('Google+ Import Settings saved.') . EOL);
}
}
@@ -101,6 +116,10 @@ function fromgplus_post($a, $uid, $source, $body, $location) {
//$uid = 2;
+ // Don't know what it is. Maybe some trash from the mobile client
+ $trash = html_entity_decode("", ENT_QUOTES, 'UTF-8');
+ $body = str_replace($trash, "", $body);
+
$body = trim($body);
if (substr($body, 0, 3) == "[b]") {
@@ -223,45 +242,40 @@ function fromgplus_cleanupgoogleproxy($fullImage, $image) {
}
function fromgplus_cleantext($text) {
+
+ // Don't know what it is. But it is added to the text.
+ $trash = html_entity_decode("", 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", " "), array("", "", ""), $text);
+ $text = str_replace(array("\n", "\r", " ", $trash), array("", "", "", ""), $text);
return($text);
}
function fromgplus_handleattachments($item, $displaytext) {
$post = "";
$quote = "";
+ $type = "";
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[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]\n";
+ $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]";
+
+ $quote .= "[/class]";
break;
case "photo":
@@ -287,13 +301,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]";
+
+ $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";
- }
+ // $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";
@@ -316,12 +340,15 @@ 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);
$initiallastdate = get_pconfig($uid,'fromgplus','lastdate');
+ $first_time = ($initiallastdate == "");
+
$lastdate = 0;
if (!is_array($activities->items))
@@ -336,6 +363,9 @@ function fromgplus_fetch($a, $uid) {
if ($lastdate < strtotime($item->published))
$lastdate = strtotime($item->published);
+ if ($first_time)
+ continue;
+
if ($item->access->description == "Public")
// Loop prevention - ignore postings from HootSuite