mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-19 21:23:41 +00:00
fromgplus: Using the new function to upload pictures to the wall
This commit is contained in:
parent
fb14c7094c
commit
67cf047ef7
2 changed files with 47 additions and 34 deletions
|
@ -12,6 +12,7 @@
|
||||||
- Use embedded pictures for the attachment information (large attachment)
|
- Use embedded pictures for the attachment information (large attachment)
|
||||||
- Sound links must be handled
|
- Sound links must be handled
|
||||||
- https://alpha.app.net/sr_rolando/post/32365203 - double pictures
|
- https://alpha.app.net/sr_rolando/post/32365203 - double pictures
|
||||||
|
- https://alpha.app.net/opendev/post/34396399 - location data
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define('APPNET_DEFAULT_POLL_INTERVAL', 5); // given in minutes
|
define('APPNET_DEFAULT_POLL_INTERVAL', 5); // given in minutes
|
||||||
|
|
|
@ -195,14 +195,15 @@ function fromgplus_parse_query($var)
|
||||||
}
|
}
|
||||||
|
|
||||||
function fromgplus_cleanupgoogleproxy($fullImage, $image) {
|
function fromgplus_cleanupgoogleproxy($fullImage, $image) {
|
||||||
|
//$preview = "/w".$fullImage->width."-h".$fullImage->height."/";
|
||||||
|
//$preview2 = "/w".$fullImage->width."-h".$fullImage->height."-p/";
|
||||||
|
//$fullImage = str_replace(array($preview, $preview2), array("/", "/"), $fullImage->url);
|
||||||
|
$fullImage = $fullImage->url;
|
||||||
|
|
||||||
$preview = "/w".$fullImage->width."-h".$fullImage->height."/";
|
//$preview = "/w".$image->width."-h".$image->height."/";
|
||||||
$preview2 = "/w".$fullImage->width."-h".$fullImage->height."-p/";
|
//$preview2 = "/w".$image->width."-h".$image->height."-p/";
|
||||||
$fullImage = str_replace(array($preview, $preview2), array("/", "/"), $fullImage->url);
|
//$image = str_replace(array($preview, $preview2), array("/", "/"), $image->url);
|
||||||
|
$image = $image->url;
|
||||||
$preview = "/w".$image->width."-h".$image->height."/";
|
|
||||||
$preview2 = "/w".$image->width."-h".$image->height."-p/";
|
|
||||||
$image = str_replace(array($preview, $preview2), array("/", "/"), $image->url);
|
|
||||||
|
|
||||||
$cleaned = array();
|
$cleaned = array();
|
||||||
|
|
||||||
|
@ -227,7 +228,23 @@ function fromgplus_cleanupgoogleproxy($fullImage, $image) {
|
||||||
$cleaned["preview"] = "";
|
$cleaned["preview"] = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cleaned["full"] == $cleaned["preview"])
|
if ($cleaned["full"] != "")
|
||||||
|
$infoFull = get_photo_info($cleaned["full"]);
|
||||||
|
else
|
||||||
|
$infoFull = array("0" => 0, "1" => 0);
|
||||||
|
|
||||||
|
if ($cleaned["preview"] != "")
|
||||||
|
$infoPreview = get_photo_info($cleaned["preview"]);
|
||||||
|
else
|
||||||
|
$infoFull = array("0" => 0, "1" => 0);
|
||||||
|
|
||||||
|
if (($infoPreview[0] >= $infoFull[0]) AND ($infoPreview[1] >= $infoFull[1])) {
|
||||||
|
$temp = $cleaned["full"];
|
||||||
|
$cleaned["full"] = $cleaned["preview"];
|
||||||
|
$cleaned["preview"] = $temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($cleaned["full"] == $cleaned["preview"]) OR (($infoPreview[0] == $infoFull[0]) AND ($infoPreview[1] == $infoFull[1])))
|
||||||
$cleaned["preview"] = "";
|
$cleaned["preview"] = "";
|
||||||
|
|
||||||
if ($cleaned["full"] == "")
|
if ($cleaned["full"] == "")
|
||||||
|
@ -236,7 +253,10 @@ function fromgplus_cleanupgoogleproxy($fullImage, $image) {
|
||||||
|
|
||||||
if ($cleaned["full"] == "")
|
if ($cleaned["full"] == "")
|
||||||
if (@exif_imagetype($image) != 0)
|
if (@exif_imagetype($image) != 0)
|
||||||
$cleaned["full"] = $fullImage;
|
$cleaned["full"] = $image;
|
||||||
|
|
||||||
|
// Could be changed in the future to a link to the album
|
||||||
|
$cleaned["page"] = $cleaned["full"];
|
||||||
|
|
||||||
return($cleaned);
|
return($cleaned);
|
||||||
}
|
}
|
||||||
|
@ -253,7 +273,9 @@ function fromgplus_cleantext($text) {
|
||||||
return($text);
|
return($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fromgplus_handleattachments($item, $displaytext) {
|
function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
|
||||||
|
require_once("include/Photo.php");
|
||||||
|
|
||||||
$post = "";
|
$post = "";
|
||||||
$quote = "";
|
$quote = "";
|
||||||
$type = "";
|
$type = "";
|
||||||
|
@ -279,9 +301,18 @@ function fromgplus_handleattachments($item, $displaytext) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "photo":
|
case "photo":
|
||||||
|
// Don't store shared pictures in your wall photos (to prevent a possible violating of licenses)
|
||||||
|
if ($shared)
|
||||||
$images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
|
$images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
|
||||||
|
else {
|
||||||
|
if ($attachment->fullImage->url != "")
|
||||||
|
$images = store_photo($a, $uid, "", $attachment->fullImage->url);
|
||||||
|
elseif ($attachment->image->url != "")
|
||||||
|
$images = store_photo($a, $uid, "", $attachment->image->url);
|
||||||
|
}
|
||||||
|
|
||||||
if ($images["preview"] != "")
|
if ($images["preview"] != "")
|
||||||
$post .= "\n[url=".$images["full"]."][img]".$images["preview"]."[/img][/url]\n";
|
$post .= "\n[url=".$images["page"]."][img]".$images["preview"]."[/img][/url]\n";
|
||||||
elseif ($images["full"] != "")
|
elseif ($images["full"] != "")
|
||||||
$post .= "\n[img]".$images["full"]."[/img]\n";
|
$post .= "\n[img]".$images["full"]."[/img]\n";
|
||||||
|
|
||||||
|
@ -381,7 +412,7 @@ function fromgplus_fetch($a, $uid) {
|
||||||
$post = fromgplus_html2bbcode($item->object->content);
|
$post = fromgplus_html2bbcode($item->object->content);
|
||||||
|
|
||||||
if (is_array($item->object->attachments))
|
if (is_array($item->object->attachments))
|
||||||
$post .= fromgplus_handleattachments($item, $item->object->content);
|
$post .= fromgplus_handleattachments($a, $uid, $item, $item->object->content, false);
|
||||||
|
|
||||||
// geocode, placeName
|
// geocode, placeName
|
||||||
if (isset($item->address))
|
if (isset($item->address))
|
||||||
|
@ -406,7 +437,7 @@ function fromgplus_fetch($a, $uid) {
|
||||||
$post .= fromgplus_html2bbcode($item->object->content);
|
$post .= fromgplus_html2bbcode($item->object->content);
|
||||||
|
|
||||||
if (is_array($item->object->attachments))
|
if (is_array($item->object->attachments))
|
||||||
$post .= "\n".trim(fromgplus_handleattachments($item, $item->object->content));
|
$post .= "\n".trim(fromgplus_handleattachments($a, $uid, $item, $item->object->content, true));
|
||||||
|
|
||||||
$post .= "[/share]";
|
$post .= "[/share]";
|
||||||
} else {
|
} else {
|
||||||
|
@ -415,7 +446,7 @@ function fromgplus_fetch($a, $uid) {
|
||||||
$post .= fromgplus_html2bbcode($item->object->content);
|
$post .= fromgplus_html2bbcode($item->object->content);
|
||||||
|
|
||||||
if (is_array($item->object->attachments))
|
if (is_array($item->object->attachments))
|
||||||
$post .= "\n".trim(fromgplus_handleattachments($item, $item->object->content));
|
$post .= "\n".trim(fromgplus_handleattachments($a, $uid, $item, $item->object->content, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($item->address))
|
if (isset($item->address))
|
||||||
|
@ -431,22 +462,3 @@ function fromgplus_fetch($a, $uid) {
|
||||||
if ($lastdate != 0)
|
if ($lastdate != 0)
|
||||||
set_pconfig($uid,'fromgplus','lastdate', $lastdate);
|
set_pconfig($uid,'fromgplus','lastdate', $lastdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// Test
|
|
||||||
require_once("boot.php");
|
|
||||||
|
|
||||||
if(@is_null($a)) {
|
|
||||||
$a = new App;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(@is_null($db)) {
|
|
||||||
@include(".htconfig.php");
|
|
||||||
require_once("include/dba.php");
|
|
||||||
$db = new dba($db_host, $db_user, $db_pass, $db_data);
|
|
||||||
unset($db_host, $db_user, $db_pass, $db_data);
|
|
||||||
};
|
|
||||||
|
|
||||||
$test = array();
|
|
||||||
fromgplus_cron($a, $test);
|
|
||||||
*/
|
|
||||||
|
|
Loading…
Reference in a new issue