Merge pull request #458 from zeroadam/Photo-#3878

Photo to namespace
This commit is contained in:
Michael Vogel 2017-12-01 05:30:34 +01:00 committed by GitHub
commit cdfa834f05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 20 deletions

View file

@ -11,10 +11,11 @@ define('FROMGPLUS_DEFAULT_POLL_INTERVAL', 30); // given in minutes
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Object\Photo;
require_once('mod/share.php'); require_once 'mod/share.php';
require_once('mod/parse_url.php'); require_once 'mod/parse_url.php';
require_once('include/text.php'); require_once 'include/text.php';
function fromgplus_install() { function fromgplus_install() {
register_hook('connector_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings'); register_hook('connector_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings');
@ -263,12 +264,12 @@ function fromgplus_cleanupgoogleproxy($fullImage, $image) {
} }
if ($cleaned["full"] != "") if ($cleaned["full"] != "")
$infoFull = get_photo_info($cleaned["full"]); $infoFull = Photo::getInfoFromURL($cleaned["full"]);
else else
$infoFull = array("0" => 0, "1" => 0); $infoFull = array("0" => 0, "1" => 0);
if ($cleaned["preview"] != "") if ($cleaned["preview"] != "")
$infoPreview = get_photo_info($cleaned["preview"]); $infoPreview = Photo::getInfoFromURL($cleaned["preview"]);
else else
$infoFull = array("0" => 0, "1" => 0); $infoFull = array("0" => 0, "1" => 0);
@ -348,13 +349,14 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
case "photo": case "photo":
// Don't store shared pictures in your wall photos (to prevent a possible violating of licenses) // Don't store shared pictures in your wall photos (to prevent a possible violating of licenses)
if ($shared) if ($shared) {
$images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image); $images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
else { } else {
if ($attachment->fullImage->url != "") if ($attachment->fullImage->url != "") {
$images = store_photo($a, $uid, "", $attachment->fullImage->url); $images = Photo::storePhoto($a, $uid, "", $attachment->fullImage->url);
elseif ($attachment->image->url != "") } elseif ($attachment->image->url != "") {
$images = store_photo($a, $uid, "", $attachment->image->url); $images = Photo::storePhoto($a, $uid, "", $attachment->image->url);
}
} }
if ($images["preview"] != "") { if ($images["preview"] != "") {
@ -365,9 +367,10 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
$post .= "\n[img]".$images["full"]."[/img]\n"; $post .= "\n[img]".$images["full"]."[/img]\n";
$pagedata["images"][0]["src"] = $images["full"]; $pagedata["images"][0]["src"] = $images["full"];
if ($images["preview"] != "") if ($images["preview"] != "") {
$pagedata["images"][1]["src"] = $images["preview"]; $pagedata["images"][1]["src"] = $images["preview"];
} }
}
if (($attachment->displayName != "") && (fromgplus_cleantext($attachment->displayName) != fromgplus_cleantext($displaytext))) { if (($attachment->displayName != "") && (fromgplus_cleantext($attachment->displayName) != fromgplus_cleantext($displaytext))) {
$post .= fromgplus_html2bbcode($attachment->displayName)."\n"; $post .= fromgplus_html2bbcode($attachment->displayName)."\n";

View file

@ -5,7 +5,6 @@
* Version: 0.2 * Version: 0.2
* Author: Michael Vogel <http://pirati.ca/profile/heluecht> * Author: Michael Vogel <http://pirati.ca/profile/heluecht>
*/ */
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Core\Worker; use Friendica\Core\Worker;
@ -1046,8 +1045,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false) {
*/ */
} }
if (function_exists("update_contact_avatar")) Contact::updateAvatar($contact->image->url, $uid, $contact_id);
update_contact_avatar($contact->image->url, $uid, $contact_id);
return($contact_id); return($contact_id);
} }

View file

@ -49,6 +49,7 @@ require_once 'include/enotify.php';
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Model\GlobalContact; use Friendica\Model\GlobalContact;
use Friendica\Object\Photo;
class StatusNetOAuth extends TwitterOAuth { class StatusNetOAuth extends TwitterOAuth {
function get_maxlength() { function get_maxlength() {
@ -999,7 +1000,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user) {
require_once("Photo.php"); require_once("Photo.php");
$photos = import_profile_photo($contact->profile_image_url,$uid,$contact_id); $photos = Photo::importProfilePhoto($contact->profile_image_url,$uid,$contact_id);
q("UPDATE `contact` SET `photo` = '%s', q("UPDATE `contact` SET `photo` = '%s',
`thumb` = '%s', `thumb` = '%s',
@ -1026,7 +1027,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user) {
require_once("Photo.php"); require_once("Photo.php");
$photos = import_profile_photo($contact->profile_image_url, $uid, $r[0]['id']); $photos = Photo::importProfilePhoto($contact->profile_image_url, $uid, $r[0]['id']);
q("UPDATE `contact` SET `photo` = '%s', q("UPDATE `contact` SET `photo` = '%s',
`thumb` = '%s', `thumb` = '%s',

View file

@ -64,6 +64,7 @@ use Friendica\Core\Config;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Model\GlobalContact; use Friendica\Model\GlobalContact;
use Friendica\Object\Photo;
require_once 'include/enotify.php'; require_once 'include/enotify.php';
@ -950,7 +951,7 @@ function twitter_fix_avatar($avatar) {
$new_avatar = str_replace("_normal.", ".", $avatar); $new_avatar = str_replace("_normal.", ".", $avatar);
$info = get_photo_info($new_avatar); $info = Photo::getInfoFromURL($new_avatar);
if (!$info) if (!$info)
$new_avatar = $avatar; $new_avatar = $avatar;
@ -1027,7 +1028,7 @@ function twitter_fetch_contact($uid, $contact, $create_user) {
require_once("Photo.php"); require_once("Photo.php");
$photos = import_profile_photo($avatar, $uid, $contact_id, true); $photos = Photo::importProfilePhoto($avatar, $uid, $contact_id, true);
if ($photos) { if ($photos) {
q("UPDATE `contact` SET `photo` = '%s', q("UPDATE `contact` SET `photo` = '%s',
@ -1060,7 +1061,7 @@ function twitter_fetch_contact($uid, $contact, $create_user) {
require_once("Photo.php"); require_once("Photo.php");
$photos = import_profile_photo($avatar, $uid, $r[0]['id'], true); $photos = Photo::importProfilePhoto($avatar, $uid, $r[0]['id'], true);
if ($photos) { if ($photos) {
q("UPDATE `contact` SET `photo` = '%s', q("UPDATE `contact` SET `photo` = '%s',