mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-16 20:05:14 +02:00
Revert "Move Objects to Model"
This commit is contained in:
parent
e437c74d0e
commit
5747cfc79c
77 changed files with 593 additions and 636 deletions
|
@ -9,7 +9,7 @@ namespace Friendica\Core;
|
|||
use Friendica\Core\Pconfig;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Object\Contact;
|
||||
|
||||
require_once 'include/html2plain.php';
|
||||
require_once 'include/datetime.php';
|
||||
|
|
|
@ -9,9 +9,9 @@ use Friendica\Core\Config;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Object\Contact;
|
||||
use Friendica\Object\Profile;
|
||||
use Friendica\Protocol\PortableContact;
|
||||
use dba;
|
||||
use Exception;
|
||||
|
@ -23,7 +23,7 @@ require_once 'include/html2bbcode.php';
|
|||
/**
|
||||
* @brief This class handles GlobalContact related functions
|
||||
*/
|
||||
class GContact
|
||||
class GlobalContact
|
||||
{
|
||||
/**
|
||||
* @brief Search global contact table by nick or name
|
|
@ -1,174 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file src/Model/Photo.php
|
||||
* @brief This file contains the Photo class for database interface
|
||||
*/
|
||||
|
||||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Object\Image;
|
||||
use dba;
|
||||
|
||||
require_once "include/photos.php";
|
||||
/**
|
||||
* Class to handle photo dabatase table
|
||||
*/
|
||||
class Photo
|
||||
{
|
||||
/**
|
||||
* @param integer $uid uid
|
||||
* @param integer $cid cid
|
||||
* @param integer $rid rid
|
||||
* @param string $filename filename
|
||||
* @param string $album album name
|
||||
* @param integer $scale scale
|
||||
* @param integer $profile optional, default = 0
|
||||
* @param string $allow_cid optional, default = ''
|
||||
* @param string $allow_gid optional, default = ''
|
||||
* @param string $deny_cid optional, default = ''
|
||||
* @param string $deny_gid optional, default = ''
|
||||
* @param string $desc optional, default = ''
|
||||
* @return object
|
||||
*/
|
||||
public static function store(Image $Image, $uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '', $desc = '')
|
||||
{
|
||||
$r = dba::select('photo', array('guid'), array("`resource-id` = ? AND `guid` != ?", $rid, ''), array('limit' => 1));
|
||||
if (DBM::is_result($r)) {
|
||||
$guid = $r['guid'];
|
||||
} else {
|
||||
$guid = get_guid();
|
||||
}
|
||||
|
||||
$x = dba::select('photo', array('id'), array('resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale), array('limit' => 1));
|
||||
|
||||
$fields = array(
|
||||
'uid' => $uid,
|
||||
'contact-id' => $cid,
|
||||
'guid' => $guid,
|
||||
'resource-id' => $rid,
|
||||
'created' => datetime_convert(),
|
||||
'edited' => datetime_convert(),
|
||||
'filename' => basename($filename),
|
||||
'type' => $Image->getType(),
|
||||
'album' => $album,
|
||||
'height' => $Image->getHeight(),
|
||||
'width' => $Image->getWidth(),
|
||||
'datasize' => strlen($Image->asString()),
|
||||
'data' => $Image->asString(),
|
||||
'scale' => $scale,
|
||||
'profile' => $profile,
|
||||
'allow_cid' => $allow_cid,
|
||||
'allow_gid' => $allow_gid,
|
||||
'deny_cid' => $deny_cid,
|
||||
'deny_gid' => $deny_gid,
|
||||
'desc' => $desc
|
||||
);
|
||||
|
||||
if (DBM::is_result($x)) {
|
||||
$r = dba::update('photo', $fields, array('id' => $x['id']));
|
||||
} else {
|
||||
$r = dba::insert('photo', $fields);
|
||||
}
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $photo photo
|
||||
* @param integer $uid user id
|
||||
* @param integer $cid contact id
|
||||
* @param boolean $quit_on_error optional, default false
|
||||
* @return array
|
||||
*/
|
||||
public static function importProfilePhoto($photo, $uid, $cid, $quit_on_error = false)
|
||||
{
|
||||
$r = dba::select(
|
||||
'photo', array('resource-id'), array('uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'album' => 'Contact Photos'), array('limit' => 1)
|
||||
);
|
||||
|
||||
if (DBM::is_result($r) && strlen($r['resource-id'])) {
|
||||
$hash = $r['resource-id'];
|
||||
} else {
|
||||
$hash = photo_new_resource();
|
||||
}
|
||||
|
||||
$photo_failure = false;
|
||||
|
||||
$filename = basename($photo);
|
||||
$img_str = fetch_url($photo, true);
|
||||
|
||||
if ($quit_on_error && ($img_str == "")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$type = Image::guessType($photo, true);
|
||||
$Image = new Image($img_str, $type);
|
||||
if ($Image->isValid()) {
|
||||
$Image->scaleToSquare(175);
|
||||
|
||||
$r = self::store($Image, $uid, $cid, $hash, $filename, 'Contact Photos', 4);
|
||||
|
||||
if ($r === false) {
|
||||
$photo_failure = true;
|
||||
}
|
||||
|
||||
$Image->scaleDown(80);
|
||||
|
||||
$r = self::store($Image, $uid, $cid, $hash, $filename, 'Contact Photos', 5);
|
||||
|
||||
if ($r === false) {
|
||||
$photo_failure = true;
|
||||
}
|
||||
|
||||
$Image->scaleDown(48);
|
||||
|
||||
$r = self::store($Image, $uid, $cid, $hash, $filename, 'Contact Photos', 6);
|
||||
|
||||
if ($r === false) {
|
||||
$photo_failure = true;
|
||||
}
|
||||
|
||||
$suffix = '?ts=' . time();
|
||||
|
||||
$photo = System::baseUrl() . '/photo/' . $hash . '-4.' . $Image->getExt() . $suffix;
|
||||
$thumb = System::baseUrl() . '/photo/' . $hash . '-5.' . $Image->getExt() . $suffix;
|
||||
$micro = System::baseUrl() . '/photo/' . $hash . '-6.' . $Image->getExt() . $suffix;
|
||||
|
||||
// Remove the cached photo
|
||||
$a = get_app();
|
||||
$basepath = $a->get_basepath();
|
||||
|
||||
if (is_dir($basepath . "/photo")) {
|
||||
$filename = $basepath . '/photo/' . $hash . '-4.' . $Image->getExt();
|
||||
if (file_exists($filename)) {
|
||||
unlink($filename);
|
||||
}
|
||||
$filename = $basepath . '/photo/' . $hash . '-5.' . $Image->getExt();
|
||||
if (file_exists($filename)) {
|
||||
unlink($filename);
|
||||
}
|
||||
$filename = $basepath . '/photo/' . $hash . '-6.' . $Image->getExt();
|
||||
if (file_exists($filename)) {
|
||||
unlink($filename);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$photo_failure = true;
|
||||
}
|
||||
|
||||
if ($photo_failure && $quit_on_error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($photo_failure) {
|
||||
$photo = System::baseUrl() . '/images/person-175.jpg';
|
||||
$thumb = System::baseUrl() . '/images/person-80.jpg';
|
||||
$micro = System::baseUrl() . '/images/person-48.jpg';
|
||||
}
|
||||
|
||||
return array($photo, $thumb, $micro);
|
||||
}
|
||||
}
|
|
@ -11,9 +11,8 @@ use Friendica\Core\Config;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Object\Contact;
|
||||
use Friendica\Object\Photo;
|
||||
use dba;
|
||||
|
||||
require_once 'boot.php';
|
||||
|
@ -382,32 +381,32 @@ class User
|
|||
$filename = basename($photo);
|
||||
$img_str = fetch_url($photo, true);
|
||||
// guess mimetype from headers or filename
|
||||
$type = Image::guessType($photo, true);
|
||||
$type = Photo::guessImageType($photo, true);
|
||||
|
||||
|
||||
$Image = new Image($img_str, $type);
|
||||
if ($Image->isValid()) {
|
||||
$Image->scaleToSquare(175);
|
||||
$img = new Photo($img_str, $type);
|
||||
if ($img->isValid()) {
|
||||
$img->scaleImageSquare(175);
|
||||
|
||||
$hash = photo_new_resource();
|
||||
|
||||
$r = Photo::store($Image, $newuid, 0, $hash, $filename, t('Profile Photos'), 4);
|
||||
$r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 4);
|
||||
|
||||
if ($r === false) {
|
||||
$photo_failure = true;
|
||||
}
|
||||
|
||||
$Image->scaleDown(80);
|
||||
$img->scaleImage(80);
|
||||
|
||||
$r = Photo::store($Image, $newuid, 0, $hash, $filename, t('Profile Photos'), 5);
|
||||
$r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 5);
|
||||
|
||||
if ($r === false) {
|
||||
$photo_failure = true;
|
||||
}
|
||||
|
||||
$Image->scaleDown(48);
|
||||
$img->scaleImage(48);
|
||||
|
||||
$r = Photo::store($Image, $newuid, 0, $hash, $filename, t('Profile Photos'), 6);
|
||||
$r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 6);
|
||||
|
||||
if ($r === false) {
|
||||
$photo_failure = true;
|
||||
|
|
|
@ -14,7 +14,7 @@ use Friendica\Core\System;
|
|||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Object\Profile;
|
||||
use Friendica\Protocol\Email;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file src/Model/Contact.php
|
||||
* @file src/Object/Contact.php
|
||||
*/
|
||||
|
||||
namespace Friendica\Model;
|
||||
namespace Friendica\Object;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Object\Photo;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Protocol\DFRN;
|
||||
use Friendica\Protocol\OStatus;
|
||||
|
@ -921,7 +922,7 @@ class Contact extends BaseObject
|
|||
}
|
||||
|
||||
if (($r["avatar"] != $avatar) || $force) {
|
||||
$photos = Image::importProfilePhoto($avatar, $uid, $cid, true);
|
||||
$photos = Photo::importProfilePhoto($avatar, $uid, $cid, true);
|
||||
|
||||
if ($photos) {
|
||||
dba::update(
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* @file src/Object/Thread.php
|
||||
* @file src/Object/Conversation.php
|
||||
*/
|
||||
namespace Friendica\Object;
|
||||
|
||||
|
@ -15,9 +15,9 @@ require_once 'include/text.php';
|
|||
*
|
||||
* We should think about making this a SPL Iterator
|
||||
*/
|
||||
class Thread extends BaseObject
|
||||
class Conversation extends BaseObject
|
||||
{
|
||||
private $parents = array();
|
||||
private $threads = array();
|
||||
private $mode = null;
|
||||
private $writable = false;
|
||||
private $profile_owner = 0;
|
||||
|
@ -120,7 +120,7 @@ class Thread extends BaseObject
|
|||
* @return mixed The inserted item on success
|
||||
* false on failure
|
||||
*/
|
||||
public function addParent($item)
|
||||
public function addThread($item)
|
||||
{
|
||||
$item_id = $item->getId();
|
||||
|
||||
|
@ -129,7 +129,7 @@ class Thread extends BaseObject
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($this->getParent($item->getId())) {
|
||||
if ($this->getThread($item->getId())) {
|
||||
logger('[WARN] Conversation::addThread : Thread already exists ('. $item->getId() .').', LOGGER_DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
@ -147,10 +147,10 @@ class Thread extends BaseObject
|
|||
return false;
|
||||
}
|
||||
|
||||
$item->setThread($this);
|
||||
$this->parents[] = $item;
|
||||
$item->setConversation($this);
|
||||
$this->threads[] = $item;
|
||||
|
||||
return end($this->parents);
|
||||
return end($this->threads);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,7 +169,7 @@ class Thread extends BaseObject
|
|||
$result = array();
|
||||
$i = 0;
|
||||
|
||||
foreach ($this->parents as $item) {
|
||||
foreach ($this->threads as $item) {
|
||||
if ($item->getDataValue('network') === NETWORK_MAIL && local_user() != $item->getDataValue('uid')) {
|
||||
continue;
|
||||
}
|
||||
|
@ -194,9 +194,9 @@ class Thread extends BaseObject
|
|||
* @return mixed The found item on success
|
||||
* false on failure
|
||||
*/
|
||||
private function getParent($id)
|
||||
private function getThread($id)
|
||||
{
|
||||
foreach ($this->parents as $item) {
|
||||
foreach ($this->threads as $item) {
|
||||
if ($item->getId() == $id) {
|
||||
return $item;
|
||||
}
|
|
@ -1,24 +1,25 @@
|
|||
<?php
|
||||
/**
|
||||
* @file src/Object/Post.php
|
||||
* @file src/Object/Item.php
|
||||
*/
|
||||
namespace Friendica\Object;
|
||||
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Content\Feature;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Object\Contact;
|
||||
use dba;
|
||||
|
||||
require_once 'include/text.php';
|
||||
require_once 'boot.php';
|
||||
require_once 'include/conversation.php';
|
||||
require_once "include/conversation.php";
|
||||
|
||||
/**
|
||||
* An item
|
||||
*/
|
||||
class Post extends BaseObject
|
||||
class Item extends BaseObject
|
||||
{
|
||||
private $data = array();
|
||||
private $template = null;
|
||||
|
@ -31,7 +32,7 @@ class Post extends BaseObject
|
|||
private $writable = false;
|
||||
private $children = array();
|
||||
private $parent = null;
|
||||
private $thread = null;
|
||||
private $conversation = null;
|
||||
private $redirect_url = null;
|
||||
private $owner_url = '';
|
||||
private $owner_photo = '';
|
||||
|
@ -138,7 +139,7 @@ class Post extends BaseObject
|
|||
$osparkle = '';
|
||||
$total_children = $this->countDescendants();
|
||||
|
||||
$conv = $this->getThread();
|
||||
$conv = $this->getConversation();
|
||||
|
||||
$lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
|
||||
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
|
||||
|
@ -539,7 +540,7 @@ class Post extends BaseObject
|
|||
}
|
||||
|
||||
$this->parent = $item;
|
||||
$this->setThread($item->getThread());
|
||||
$this->setConversation($item->getConversation());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -550,7 +551,7 @@ class Post extends BaseObject
|
|||
protected function removeParent()
|
||||
{
|
||||
$this->parent = null;
|
||||
$this->thread = null;
|
||||
$this->conversation = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -593,15 +594,15 @@ class Post extends BaseObject
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setThread($conv)
|
||||
public function setConversation($conv)
|
||||
{
|
||||
$previous_mode = ($this->thread ? $this->thread->getMode() : '');
|
||||
$previous_mode = ($this->conversation ? $this->conversation->getMode() : '');
|
||||
|
||||
$this->thread = $conv;
|
||||
$this->conversation = $conv;
|
||||
|
||||
// Set it on our children too
|
||||
foreach ($this->getChildren() as $child) {
|
||||
$child->setThread($conv);
|
||||
$child->setConversation($conv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -610,9 +611,9 @@ class Post extends BaseObject
|
|||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getThread()
|
||||
public function getConversation()
|
||||
{
|
||||
return $this->thread;
|
||||
return $this->conversation;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -689,7 +690,7 @@ class Post extends BaseObject
|
|||
*/
|
||||
private function isWritable()
|
||||
{
|
||||
$conv = $this->getThread();
|
||||
$conv = $this->getConversation();
|
||||
|
||||
if ($conv) {
|
||||
// This will allow us to comment on wall-to-wall items owned by our friends
|
||||
|
@ -747,7 +748,7 @@ class Post extends BaseObject
|
|||
$a = self::getApp();
|
||||
|
||||
$comment_box = '';
|
||||
$conv = $this->getThread();
|
||||
$conv = $this->getConversation();
|
||||
$template = get_markup_template($this->getCommentBoxTemplate());
|
||||
$ww = '';
|
||||
if (($conv->getMode() === 'network') && $this->isWallToWall()) {
|
||||
|
@ -818,7 +819,7 @@ class Post extends BaseObject
|
|||
protected function checkWallToWall()
|
||||
{
|
||||
$a = self::getApp();
|
||||
$conv = $this->getThread();
|
||||
$conv = $this->getConversation();
|
||||
$this->wall_to_wall = false;
|
||||
|
||||
if ($this->isToplevel()) {
|
||||
|
@ -888,6 +889,14 @@ class Post extends BaseObject
|
|||
return $this->owner_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getOwnerPhoto()
|
||||
{
|
||||
return $this->owner_photo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* @file src/Object/Image.php
|
||||
* @brief This file contains the Image class for image processing
|
||||
* @file src/Object/Photo.php
|
||||
* @brief This file contains the Photo class for image processing
|
||||
*/
|
||||
namespace Friendica\Object;
|
||||
|
||||
|
@ -10,7 +10,7 @@ use Friendica\Core\Cache;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Photo;
|
||||
use dba;
|
||||
use Exception;
|
||||
use Imagick;
|
||||
use ImagickPixel;
|
||||
|
@ -18,9 +18,9 @@ use ImagickPixel;
|
|||
require_once "include/photos.php";
|
||||
|
||||
/**
|
||||
* Class to handle images
|
||||
* Class to handle Photos
|
||||
*/
|
||||
class Image
|
||||
class Photo
|
||||
{
|
||||
private $image;
|
||||
|
||||
|
@ -285,7 +285,7 @@ class Image
|
|||
* @param integer $max max dimension
|
||||
* @return mixed
|
||||
*/
|
||||
public function scaleDown($max)
|
||||
public function scaleImage($max)
|
||||
{
|
||||
if (!$this->isValid()) {
|
||||
return false;
|
||||
|
@ -350,7 +350,7 @@ class Image
|
|||
// FIXME - implement horizantal bias for scaling as in followin GD functions
|
||||
// to allow very tall images to be constrained only horizontally.
|
||||
|
||||
$this->image->scaleDown($dest_width, $dest_height);
|
||||
$this->image->scaleImage($dest_width, $dest_height);
|
||||
} while ($this->image->nextImage());
|
||||
|
||||
// These may not be necessary any more
|
||||
|
@ -524,7 +524,7 @@ class Image
|
|||
* @param integer $min minimum dimension
|
||||
* @return mixed
|
||||
*/
|
||||
public function scaleUp($min)
|
||||
public function scaleImageUp($min)
|
||||
{
|
||||
if (!$this->isValid()) {
|
||||
return false;
|
||||
|
@ -563,7 +563,7 @@ class Image
|
|||
}
|
||||
|
||||
if ($this->isImagick()) {
|
||||
return $this->scaleDown($dest_width, $dest_height);
|
||||
return $this->scaleImage($dest_width, $dest_height);
|
||||
}
|
||||
|
||||
$dest = imagecreatetruecolor($dest_width, $dest_height);
|
||||
|
@ -585,7 +585,7 @@ class Image
|
|||
* @param integer $dim dimension
|
||||
* @return mixed
|
||||
*/
|
||||
public function scaleToSquare($dim)
|
||||
public function scaleImageSquare($dim)
|
||||
{
|
||||
if (!$this->isValid()) {
|
||||
return false;
|
||||
|
@ -594,7 +594,7 @@ class Image
|
|||
if ($this->isImagick()) {
|
||||
$this->image->setFirstIterator();
|
||||
do {
|
||||
$this->image->scaleDown($dim, $dim);
|
||||
$this->image->scaleImage($dim, $dim);
|
||||
} while ($this->image->nextImage());
|
||||
return;
|
||||
}
|
||||
|
@ -622,7 +622,7 @@ class Image
|
|||
* @param integer $h height
|
||||
* @return mixed
|
||||
*/
|
||||
public function crop($max, $x, $y, $w, $h)
|
||||
public function cropImage($max, $x, $y, $w, $h)
|
||||
{
|
||||
if (!$this->isValid()) {
|
||||
return false;
|
||||
|
@ -639,7 +639,7 @@ class Image
|
|||
*/
|
||||
$this->image->setImagePage(0, 0, 0, 0);
|
||||
} while ($this->image->nextImage());
|
||||
return $this->scaleDown($max);
|
||||
return $this->scaleImage($max);
|
||||
}
|
||||
|
||||
$dest = imagecreatetruecolor($max, $max);
|
||||
|
@ -661,13 +661,13 @@ class Image
|
|||
* @param string $path file path
|
||||
* @return mixed
|
||||
*/
|
||||
public function saveToFilePath($path)
|
||||
public function saveImage($path)
|
||||
{
|
||||
if (!$this->isValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$string = $this->asString();
|
||||
$string = $this->imageString();
|
||||
|
||||
$a = get_app();
|
||||
|
||||
|
@ -676,23 +676,10 @@ class Image
|
|||
$a->save_timestamp($stamp1, "file");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Magic method allowing string casting of an Image object
|
||||
*
|
||||
* Ex: $data = $Image->asString();
|
||||
* can be replaced by
|
||||
* $data = (string) $Image;
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString() {
|
||||
return $this->asString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function asString()
|
||||
public function imageString()
|
||||
{
|
||||
if (!$this->isValid()) {
|
||||
return false;
|
||||
|
@ -733,6 +720,46 @@ class Image
|
|||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $uid uid
|
||||
* @param integer $cid cid
|
||||
* @param integer $rid rid
|
||||
* @param string $filename filename
|
||||
* @param string $album album name
|
||||
* @param integer $scale scale
|
||||
* @param integer $profile optional, default = 0
|
||||
* @param string $allow_cid optional, default = ''
|
||||
* @param string $allow_gid optional, default = ''
|
||||
* @param string $deny_cid optional, default = ''
|
||||
* @param string $deny_gid optional, default = ''
|
||||
* @param string $desc optional, default = ''
|
||||
* @return object
|
||||
*/
|
||||
public function store($uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '', $desc = '')
|
||||
{
|
||||
$r = dba::select('photo', array('guid'), array("`resource-id` = ? AND `guid` != ?", $rid, ''), array('limit' => 1));
|
||||
if (DBM::is_result($r)) {
|
||||
$guid = $r['guid'];
|
||||
} else {
|
||||
$guid = get_guid();
|
||||
}
|
||||
|
||||
$x = dba::select('photo', array('id'), array('resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale), array('limit' => 1));
|
||||
|
||||
$fields = array('uid' => $uid, 'contact-id' => $cid, 'guid' => $guid, 'resource-id' => $rid, 'created' => datetime_convert(), 'edited' => datetime_convert(),
|
||||
'filename' => basename($filename), 'type' => $this->getType(), 'album' => $album, 'height' => $this->getHeight(), 'width' => $this->getWidth(),
|
||||
'datasize' => strlen($this->imageString()), 'data' => $this->imageString(), 'scale' => $scale, 'profile' => $profile,
|
||||
'allow_cid' => $allow_cid, 'allow_gid' => $allow_gid, 'deny_cid' => $deny_cid, 'deny_gid' => $deny_gid, 'desc' => $desc);
|
||||
|
||||
if (DBM::is_result($x)) {
|
||||
$r = dba::update('photo', $fields, array('id' => $x['id']));
|
||||
} else {
|
||||
$r = dba::insert('photo', $fields);
|
||||
}
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Guess image mimetype from filename or from Content-Type header
|
||||
*
|
||||
|
@ -741,9 +768,9 @@ class Image
|
|||
*
|
||||
* @return object
|
||||
*/
|
||||
public static function guessType($filename, $fromcurl = false)
|
||||
public static function guessImageType($filename, $fromcurl = false)
|
||||
{
|
||||
logger('Image: guessType: '.$filename . ($fromcurl?' from curl headers':''), LOGGER_DEBUG);
|
||||
logger('Photo: guessImageType: '.$filename . ($fromcurl?' from curl headers':''), LOGGER_DEBUG);
|
||||
$type = null;
|
||||
if ($fromcurl) {
|
||||
$a = get_app();
|
||||
|
@ -778,10 +805,109 @@ class Image
|
|||
}
|
||||
}
|
||||
}
|
||||
logger('Image: guessType: type='.$type, LOGGER_DEBUG);
|
||||
logger('Photo: guessImageType: type='.$type, LOGGER_DEBUG);
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $photo photo
|
||||
* @param integer $uid user id
|
||||
* @param integer $cid contact id
|
||||
* @param boolean $quit_on_error optional, default false
|
||||
* @return array
|
||||
*/
|
||||
public static function importProfilePhoto($photo, $uid, $cid, $quit_on_error = false)
|
||||
{
|
||||
$r = dba::select(
|
||||
'photo',
|
||||
array('resource-id'),
|
||||
array('uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'album' => 'Contact Photos'),
|
||||
array('limit' => 1)
|
||||
);
|
||||
|
||||
if (DBM::is_result($r) && strlen($r['resource-id'])) {
|
||||
$hash = $r['resource-id'];
|
||||
} else {
|
||||
$hash = photo_new_resource();
|
||||
}
|
||||
|
||||
$photo_failure = false;
|
||||
|
||||
$filename = basename($photo);
|
||||
$img_str = fetch_url($photo, true);
|
||||
|
||||
if ($quit_on_error && ($img_str == "")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$type = self::guessImageType($photo, true);
|
||||
$img = new Photo($img_str, $type);
|
||||
if ($img->isValid()) {
|
||||
$img->scaleImageSquare(175);
|
||||
|
||||
$r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 4);
|
||||
|
||||
if ($r === false) {
|
||||
$photo_failure = true;
|
||||
}
|
||||
|
||||
$img->scaleImage(80);
|
||||
|
||||
$r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 5);
|
||||
|
||||
if ($r === false) {
|
||||
$photo_failure = true;
|
||||
}
|
||||
|
||||
$img->scaleImage(48);
|
||||
|
||||
$r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 6);
|
||||
|
||||
if ($r === false) {
|
||||
$photo_failure = true;
|
||||
}
|
||||
|
||||
$suffix = '?ts='.time();
|
||||
|
||||
$photo = System::baseUrl() . '/photo/' . $hash . '-4.' . $img->getExt() . $suffix;
|
||||
$thumb = System::baseUrl() . '/photo/' . $hash . '-5.' . $img->getExt() . $suffix;
|
||||
$micro = System::baseUrl() . '/photo/' . $hash . '-6.' . $img->getExt() . $suffix;
|
||||
|
||||
// Remove the cached photo
|
||||
$a = get_app();
|
||||
$basepath = $a->get_basepath();
|
||||
|
||||
if (is_dir($basepath."/photo")) {
|
||||
$filename = $basepath.'/photo/'.$hash.'-4.'.$img->getExt();
|
||||
if (file_exists($filename)) {
|
||||
unlink($filename);
|
||||
}
|
||||
$filename = $basepath.'/photo/'.$hash.'-5.'.$img->getExt();
|
||||
if (file_exists($filename)) {
|
||||
unlink($filename);
|
||||
}
|
||||
$filename = $basepath.'/photo/'.$hash.'-6.'.$img->getExt();
|
||||
if (file_exists($filename)) {
|
||||
unlink($filename);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$photo_failure = true;
|
||||
}
|
||||
|
||||
if ($photo_failure && $quit_on_error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($photo_failure) {
|
||||
$photo = System::baseUrl() . '/images/person-175.jpg';
|
||||
$thumb = System::baseUrl() . '/images/person-80.jpg';
|
||||
$micro = System::baseUrl() . '/images/person-48.jpg';
|
||||
}
|
||||
|
||||
return array($photo, $thumb, $micro);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url url
|
||||
* @return object
|
||||
|
@ -789,34 +915,34 @@ class Image
|
|||
public static function getInfoFromURL($url)
|
||||
{
|
||||
$data = array();
|
||||
|
||||
|
||||
$data = Cache::get($url);
|
||||
|
||||
|
||||
if (is_null($data) || !$data || !is_array($data)) {
|
||||
$img_str = fetch_url($url, true, $redirects, 4);
|
||||
$filesize = strlen($img_str);
|
||||
|
||||
|
||||
if (function_exists("getimagesizefromstring")) {
|
||||
$data = getimagesizefromstring($img_str);
|
||||
} else {
|
||||
$tempfile = tempnam(get_temppath(), "cache");
|
||||
|
||||
|
||||
$a = get_app();
|
||||
$stamp1 = microtime(true);
|
||||
file_put_contents($tempfile, $img_str);
|
||||
$a->save_timestamp($stamp1, "file");
|
||||
|
||||
|
||||
$data = getimagesize($tempfile);
|
||||
unlink($tempfile);
|
||||
}
|
||||
|
||||
|
||||
if ($data) {
|
||||
$data["size"] = $filesize;
|
||||
}
|
||||
|
||||
|
||||
Cache::set($url, $data);
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -826,18 +952,18 @@ class Image
|
|||
* @param integer $max max
|
||||
* @return array
|
||||
*/
|
||||
public static function getScalingDimensions($width, $height, $max)
|
||||
public static function scaleImageTo($width, $height, $max)
|
||||
{
|
||||
$dest_width = $dest_height = 0;
|
||||
|
||||
|
||||
if ((!$width) || (!$height)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if ($width > $max && $height > $max) {
|
||||
// very tall image (greater than 16:9)
|
||||
// constrain the width - let the height float.
|
||||
|
||||
|
||||
if ((($height * 9) / 16) > $width) {
|
||||
$dest_width = $max;
|
||||
$dest_height = intval(($height * $max) / $width);
|
||||
|
@ -857,7 +983,7 @@ class Image
|
|||
if ($height > $max) {
|
||||
// very tall image (greater than 16:9)
|
||||
// but width is OK - don't do anything
|
||||
|
||||
|
||||
if ((($height * 9) / 16) > $width) {
|
||||
$dest_width = $width;
|
||||
$dest_height = $height;
|
||||
|
@ -889,152 +1015,152 @@ class Image
|
|||
WHERE `user`.`uid` = %d AND `user`.`blocked` = 0 AND `contact`.`self` = 1 LIMIT 1",
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
|
||||
if (!DBM::is_result($r)) {
|
||||
logger("Can't detect user data for uid ".$uid, LOGGER_DEBUG);
|
||||
return(array());
|
||||
}
|
||||
|
||||
|
||||
$page_owner_nick = $r[0]['nickname'];
|
||||
|
||||
|
||||
/// @TODO
|
||||
/// $default_cid = $r[0]['id'];
|
||||
/// $community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
|
||||
|
||||
|
||||
if ((strlen($imagedata) == 0) && ($url == "")) {
|
||||
logger("No image data and no url provided", LOGGER_DEBUG);
|
||||
return(array());
|
||||
} elseif (strlen($imagedata) == 0) {
|
||||
logger("Uploading picture from ".$url, LOGGER_DEBUG);
|
||||
|
||||
|
||||
$stamp1 = microtime(true);
|
||||
$imagedata = @file_get_contents($url);
|
||||
$a->save_timestamp($stamp1, "file");
|
||||
}
|
||||
|
||||
|
||||
$maximagesize = Config::get('system', 'maximagesize');
|
||||
|
||||
|
||||
if (($maximagesize) && (strlen($imagedata) > $maximagesize)) {
|
||||
logger("Image exceeds size limit of ".$maximagesize, LOGGER_DEBUG);
|
||||
return(array());
|
||||
}
|
||||
|
||||
|
||||
$tempfile = tempnam(get_temppath(), "cache");
|
||||
|
||||
|
||||
$stamp1 = microtime(true);
|
||||
file_put_contents($tempfile, $imagedata);
|
||||
$a->save_timestamp($stamp1, "file");
|
||||
|
||||
|
||||
$data = getimagesize($tempfile);
|
||||
|
||||
|
||||
if (!isset($data["mime"])) {
|
||||
unlink($tempfile);
|
||||
logger("File is no picture", LOGGER_DEBUG);
|
||||
return(array());
|
||||
}
|
||||
|
||||
$Image = new Image($imagedata, $data["mime"]);
|
||||
|
||||
if (!$Image->isValid()) {
|
||||
|
||||
$ph = new Photo($imagedata, $data["mime"]);
|
||||
|
||||
if (!$ph->isValid()) {
|
||||
unlink($tempfile);
|
||||
logger("Picture is no valid picture", LOGGER_DEBUG);
|
||||
return(array());
|
||||
}
|
||||
|
||||
$Image->orient($tempfile);
|
||||
|
||||
$ph->orient($tempfile);
|
||||
unlink($tempfile);
|
||||
|
||||
|
||||
$max_length = Config::get('system', 'max_image_length');
|
||||
if (! $max_length) {
|
||||
$max_length = MAX_IMAGE_LENGTH;
|
||||
}
|
||||
|
||||
if ($max_length > 0) {
|
||||
$Image->scaleDown($max_length);
|
||||
$ph->scaleImage($max_length);
|
||||
}
|
||||
|
||||
$width = $Image->getWidth();
|
||||
$height = $Image->getHeight();
|
||||
|
||||
|
||||
$width = $ph->getWidth();
|
||||
$height = $ph->getHeight();
|
||||
|
||||
$hash = photo_new_resource();
|
||||
|
||||
|
||||
$smallest = 0;
|
||||
|
||||
|
||||
// Pictures are always public by now
|
||||
//$defperm = '<'.$default_cid.'>';
|
||||
$defperm = "";
|
||||
$visitor = 0;
|
||||
|
||||
$r = Photo::store($Image, $uid, $visitor, $hash, $tempfile, t('Wall Photos'), 0, 0, $defperm);
|
||||
|
||||
|
||||
$r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 0, 0, $defperm);
|
||||
|
||||
if (!$r) {
|
||||
logger("Picture couldn't be stored", LOGGER_DEBUG);
|
||||
return(array());
|
||||
}
|
||||
|
||||
|
||||
$image = array("page" => System::baseUrl().'/photos/'.$page_owner_nick.'/image/'.$hash,
|
||||
"full" => System::baseUrl()."/photo/{$hash}-0.".$Image->getExt());
|
||||
|
||||
"full" => System::baseUrl()."/photo/{$hash}-0.".$ph->getExt());
|
||||
|
||||
if ($width > 800 || $height > 800) {
|
||||
$image["large"] = System::baseUrl()."/photo/{$hash}-0.".$Image->getExt();
|
||||
$image["large"] = System::baseUrl()."/photo/{$hash}-0.".$ph->getExt();
|
||||
}
|
||||
|
||||
|
||||
if ($width > 640 || $height > 640) {
|
||||
$Image->scaleDown(640);
|
||||
$r = Photo::store($Image, $uid, $visitor, $hash, $tempfile, t('Wall Photos'), 1, 0, $defperm);
|
||||
$ph->scaleImage(640);
|
||||
$r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 1, 0, $defperm);
|
||||
if ($r) {
|
||||
$image["medium"] = System::baseUrl()."/photo/{$hash}-1.".$Image->getExt();
|
||||
$image["medium"] = System::baseUrl()."/photo/{$hash}-1.".$ph->getExt();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($width > 320 || $height > 320) {
|
||||
$Image->scaleDown(320);
|
||||
$r = Photo::store($Image, $uid, $visitor, $hash, $tempfile, t('Wall Photos'), 2, 0, $defperm);
|
||||
$ph->scaleImage(320);
|
||||
$r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 2, 0, $defperm);
|
||||
if ($r) {
|
||||
$image["small"] = System::baseUrl()."/photo/{$hash}-2.".$Image->getExt();
|
||||
$image["small"] = System::baseUrl()."/photo/{$hash}-2.".$ph->getExt();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($width > 160 && $height > 160) {
|
||||
$x = 0;
|
||||
$y = 0;
|
||||
|
||||
$min = $Image->getWidth();
|
||||
|
||||
$min = $ph->getWidth();
|
||||
if ($min > 160) {
|
||||
$x = ($min - 160) / 2;
|
||||
}
|
||||
|
||||
if ($Image->getHeight() < $min) {
|
||||
$min = $Image->getHeight();
|
||||
|
||||
if ($ph->getHeight() < $min) {
|
||||
$min = $ph->getHeight();
|
||||
if ($min > 160) {
|
||||
$y = ($min - 160) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$min = 160;
|
||||
$Image->crop(160, $x, $y, $min, $min);
|
||||
|
||||
$r = Photo::store($Image, $uid, $visitor, $hash, $tempfile, t('Wall Photos'), 3, 0, $defperm);
|
||||
$ph->cropImage(160, $x, $y, $min, $min);
|
||||
|
||||
$r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 3, 0, $defperm);
|
||||
if ($r) {
|
||||
$image["thumb"] = System::baseUrl()."/photo/{$hash}-3.".$Image->getExt();
|
||||
$image["thumb"] = System::baseUrl()."/photo/{$hash}-3.".$ph->getExt();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set the full image as preview image. This will be overwritten, if the picture is larger than 640.
|
||||
$image["preview"] = $image["full"];
|
||||
|
||||
|
||||
// Deactivated, since that would result in a cropped preview, if the picture wasn't larger than 320
|
||||
//if (isset($image["thumb"]))
|
||||
// $image["preview"] = $image["thumb"];
|
||||
|
||||
|
||||
// Unsure, if this should be activated or deactivated
|
||||
//if (isset($image["small"]))
|
||||
// $image["preview"] = $image["small"];
|
||||
|
||||
|
||||
if (isset($image["medium"])) {
|
||||
$image["preview"] = $image["medium"];
|
||||
}
|
||||
|
||||
|
||||
return($image);
|
||||
}
|
||||
}
|
|
@ -1,12 +1,14 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file src/Model/Profile.php
|
||||
* @file src/Object/Profile.php
|
||||
*/
|
||||
|
||||
namespace Friendica\Model;
|
||||
namespace Friendica\Object;
|
||||
|
||||
class Profile
|
||||
use Friendica\BaseObject;
|
||||
|
||||
class Profile extends BaseObject
|
||||
{
|
||||
/**
|
||||
* @brief Returns a formatted location string from the given profile array
|
|
@ -6,7 +6,7 @@
|
|||
namespace Friendica;
|
||||
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Object\Photo;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
use dba;
|
||||
|
@ -353,7 +353,7 @@ class ParseUrl
|
|||
}
|
||||
|
||||
$src = self::completeUrl($attr["src"], $url);
|
||||
$photodata = Image::getInfoFromURL($src);
|
||||
$photodata = Photo::getInfoFromURL($src);
|
||||
|
||||
if (($photodata) && ($photodata[0] > 150) && ($photodata[1] > 150)) {
|
||||
if ($photodata[0] > 300) {
|
||||
|
@ -374,7 +374,7 @@ class ParseUrl
|
|||
|
||||
unset($siteinfo["image"]);
|
||||
|
||||
$photodata = Image::getInfoFromURL($src);
|
||||
$photodata = Photo::getInfoFromURL($src);
|
||||
|
||||
if (($photodata) && ($photodata[0] > 10) && ($photodata[1] > 10)) {
|
||||
$siteinfo["images"][] = array("src" => $src,
|
||||
|
|
|
@ -13,10 +13,10 @@ use Friendica\Core\Config;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Model\GlobalContact;
|
||||
use Friendica\Object\Contact;
|
||||
use Friendica\Object\Photo;
|
||||
use Friendica\Object\Profile;
|
||||
use Friendica\Protocol\OStatus;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
|
@ -476,7 +476,7 @@ class DFRN
|
|||
$uid
|
||||
);
|
||||
$photos = array();
|
||||
$ext = Image::supportedTypes();
|
||||
$ext = Photo::supportedTypes();
|
||||
|
||||
foreach ($rp as $p) {
|
||||
$photos[$p['scale']] = System::baseUrl().'/photo/'.$p['resource-id'].'-'.$p['scale'].'.'.$ext[$p['type']];
|
||||
|
@ -1678,9 +1678,9 @@ class DFRN
|
|||
$poco["photo"] = $author["avatar"];
|
||||
$poco["hide"] = $hide;
|
||||
$poco["contact-type"] = $contact["contact-type"];
|
||||
$gcid = GContact::update($poco);
|
||||
$gcid = GlobalContact::update($poco);
|
||||
|
||||
GContact::link($gcid, $importer["uid"], $contact["id"]);
|
||||
GlobalContact::link($gcid, $importer["uid"], $contact["id"]);
|
||||
}
|
||||
|
||||
return($author);
|
||||
|
|
|
@ -16,10 +16,10 @@ use Friendica\Core\Config;
|
|||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Model\GlobalContact;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Object\Contact;
|
||||
use Friendica\Object\Profile;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
use dba;
|
||||
|
@ -2247,9 +2247,9 @@ class Diaspora
|
|||
"addr" => $author, "nick" => $nick, "keywords" => $keywords,
|
||||
"hide" => !$searchable, "nsfw" => $nsfw);
|
||||
|
||||
$gcid = GContact::update($gcontact);
|
||||
$gcid = GlobalContact::update($gcontact);
|
||||
|
||||
GContact::link($gcid, $importer["uid"], $contact["id"]);
|
||||
GlobalContact::link($gcid, $importer["uid"], $contact["id"]);
|
||||
|
||||
logger("Profile of contact ".$contact["id"]." stored for user ".$importer["uid"], LOGGER_DEBUG);
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@ use Friendica\Core\Cache;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\GlobalContact;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Object\Contact;
|
||||
use Friendica\Object\Photo;
|
||||
use Friendica\Util\Lock;
|
||||
use Friendica\Util\XML;
|
||||
use dba;
|
||||
|
@ -226,9 +226,9 @@ class OStatus
|
|||
$contact["generation"] = 2;
|
||||
$contact["hide"] = false; // OStatus contacts are never hidden
|
||||
$contact["photo"] = $author["author-avatar"];
|
||||
$gcid = GContact::update($contact);
|
||||
$gcid = GlobalContact::update($contact);
|
||||
|
||||
GContact::link($gcid, $contact["uid"], $contact["id"]);
|
||||
GlobalContact::link($gcid, $contact["uid"], $contact["id"]);
|
||||
}
|
||||
|
||||
return $author;
|
||||
|
@ -1323,7 +1323,7 @@ class OStatus
|
|||
|
||||
switch ($siteinfo["type"]) {
|
||||
case 'photo':
|
||||
$imgdata = Image::getInfoFromURL($siteinfo["image"]);
|
||||
$imgdata = Photo::getInfoFromURL($siteinfo["image"]);
|
||||
$attributes = array("rel" => "enclosure",
|
||||
"href" => $siteinfo["image"],
|
||||
"type" => $imgdata["mime"],
|
||||
|
@ -1343,7 +1343,7 @@ class OStatus
|
|||
}
|
||||
|
||||
if (!Config::get('system', 'ostatus_not_attach_preview') && ($siteinfo["type"] != "photo") && isset($siteinfo["image"])) {
|
||||
$imgdata = Image::getInfoFromURL($siteinfo["image"]);
|
||||
$imgdata = Photo::getInfoFromURL($siteinfo["image"]);
|
||||
$attributes = array("rel" => "enclosure",
|
||||
"href" => $siteinfo["image"],
|
||||
"type" => $imgdata["mime"],
|
||||
|
|
|
@ -12,9 +12,10 @@ namespace Friendica\Protocol;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Model\GlobalContact;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Object\Photo;
|
||||
use Friendica\Object\Profile;
|
||||
use dba;
|
||||
use DOMDocument;
|
||||
use DomXPath;
|
||||
|
@ -192,10 +193,10 @@ class PortableContact
|
|||
"generation" => $generation);
|
||||
|
||||
try {
|
||||
$gcontact = GContact::sanitize($gcontact);
|
||||
$gcid = GContact::update($gcontact);
|
||||
$gcontact = GlobalContact::sanitize($gcontact);
|
||||
$gcid = GlobalContact::update($gcontact);
|
||||
|
||||
GContact::link($gcid, $uid, $cid, $zcid);
|
||||
GlobalContact::link($gcid, $uid, $cid, $zcid);
|
||||
} catch (Exception $e) {
|
||||
logger($e->getMessage(), LOGGER_DEBUG);
|
||||
}
|
||||
|
@ -424,7 +425,7 @@ class PortableContact
|
|||
|
||||
$contact = array_merge($contact, $noscrape);
|
||||
|
||||
GContact::update($contact);
|
||||
GlobalContact::update($contact);
|
||||
|
||||
if (trim($noscrape["updated"]) != "") {
|
||||
q(
|
||||
|
@ -446,7 +447,7 @@ class PortableContact
|
|||
if (!$force && !self::updateNeeded($gcontacts[0]["created"], $gcontacts[0]["updated"], $gcontacts[0]["last_failure"], $gcontacts[0]["last_contact"])) {
|
||||
logger("Profile ".$profile." was last updated at ".$gcontacts[0]["updated"]." (cached)", LOGGER_DEBUG);
|
||||
|
||||
GContact::update($contact);
|
||||
GlobalContact::update($contact);
|
||||
return $gcontacts[0]["updated"];
|
||||
}
|
||||
|
||||
|
@ -467,8 +468,8 @@ class PortableContact
|
|||
$gcontact["server_url"] = $data["baseurl"];
|
||||
|
||||
try {
|
||||
$gcontact = GContact::sanitize($gcontact);
|
||||
GContact::update($gcontact);
|
||||
$gcontact = GlobalContact::sanitize($gcontact);
|
||||
GlobalContact::update($gcontact);
|
||||
|
||||
self::lastUpdated($data["url"], $force);
|
||||
} catch (Exception $e) {
|
||||
|
@ -494,7 +495,7 @@ class PortableContact
|
|||
|
||||
$contact["server_url"] = $data["baseurl"];
|
||||
|
||||
GContact::update($contact);
|
||||
GlobalContact::update($contact);
|
||||
|
||||
$feedret = z_fetch_url($data["poll"]);
|
||||
|
||||
|
@ -1600,8 +1601,8 @@ class PortableContact
|
|||
"generation" => $generation);
|
||||
|
||||
try {
|
||||
$gcontact = GContact::sanitize($gcontact);
|
||||
GContact::update($gcontact);
|
||||
$gcontact = GlobalContact::sanitize($gcontact);
|
||||
GlobalContact::update($gcontact);
|
||||
} catch (Exception $e) {
|
||||
logger($e->getMessage(), LOGGER_DEBUG);
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ use Friendica\App;
|
|||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\GlobalContact;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Object\Contact;
|
||||
use Friendica\Protocol\PortableContact;
|
||||
use dba;
|
||||
|
||||
|
@ -280,7 +280,7 @@ class CronJobs
|
|||
$r = q("SELECT `uid` FROM `user` WHERE `verified` AND NOT `blocked` AND NOT `account_removed` AND NOT `account_expired`");
|
||||
if (DBM::is_result($r)) {
|
||||
foreach ($r AS $user) {
|
||||
GContact::updateForUser($user["uid"]);
|
||||
GlobalContact::updateForUser($user["uid"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use Friendica\App;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Object\Contact;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Protocol\DFRN;
|
||||
use Friendica\Protocol\Email;
|
||||
|
|
|
@ -8,7 +8,7 @@ use Friendica\Core\Cache;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\GlobalContact;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\PortableContact;
|
||||
|
||||
|
@ -90,7 +90,7 @@ class DiscoverPoCo {
|
|||
}
|
||||
logger($result, LOGGER_DEBUG);
|
||||
} elseif ($mode == 3) {
|
||||
GContact::updateSuggestions();
|
||||
GlobalContact::updateSuggestions();
|
||||
} elseif (($mode == 2) && Config::get('system', 'poco_completion')) {
|
||||
self::discoverUsers();
|
||||
} elseif (($mode == 1) && ($search != "") && Config::get('system', 'poco_local_search')) {
|
||||
|
@ -102,7 +102,7 @@ class DiscoverPoCo {
|
|||
|
||||
// Query GNU Social servers for their users ("statistics" addon has to be enabled on the GS server)
|
||||
if (!Config::get('system', 'ostatus_disabled')) {
|
||||
GContact::discoverGsUsers();
|
||||
GlobalContact::discoverGsUsers();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ class DiscoverPoCo {
|
|||
|
||||
$data["server_url"] = $data["baseurl"];
|
||||
|
||||
GContact::update($data);
|
||||
GlobalContact::update($data);
|
||||
} else {
|
||||
logger("Profile ".$jj->url." is not responding or no Friendica contact - but network ".$data["network"], LOGGER_DEBUG);
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ class DiscoverPoCo {
|
|||
$contact = Probe::uri($user->site_address."/".$user->name);
|
||||
if ($contact["network"] != NETWORK_PHANTOM) {
|
||||
$contact["about"] = $user->description;
|
||||
GContact::update($contact);
|
||||
GlobalContact::update($contact);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Friendica\Worker;
|
|||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\GlobalContact;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\PortableContact;
|
||||
|
||||
|
@ -47,7 +47,7 @@ class GProbe {
|
|||
}
|
||||
|
||||
if (!in_array($arr["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) {
|
||||
GContact::update($arr);
|
||||
GlobalContact::update($arr);
|
||||
}
|
||||
|
||||
$r = q(
|
||||
|
|
|
@ -7,8 +7,8 @@ namespace Friendica\Worker;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Object\Contact;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Protocol\OStatus;
|
||||
use Friendica\Protocol\Salmon;
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Friendica\Worker;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Object\Contact;
|
||||
use Friendica\Protocol\Email;
|
||||
use Friendica\Protocol\PortableContact;
|
||||
use dba;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue