1
0
Fork 0

Merge pull request #4031 from MrPetovan/task/3878-move-objects-to-model

Move Objects to Model
This commit is contained in:
Michael Vogel 2017-12-08 05:02:21 +01:00 committed by GitHub
commit e437c74d0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
77 changed files with 636 additions and 593 deletions

View file

@ -10,8 +10,8 @@ use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\User;
use Friendica\Object\Contact;
require_once 'include/enotify.php';
require_once 'include/text.php';

View file

@ -5,8 +5,8 @@
use Friendica\App;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\GlobalContact;
use Friendica\Object\Contact;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
require_once 'include/contact_selectors.php';
require_once 'mod/contacts.php';
@ -41,12 +41,12 @@ function allfriends_content(App $a) {
$a->page['aside'] = "";
profile_load($a, "", 0, Contact::getDetailsByURL($c[0]["url"]));
$total = GlobalContact::countAllFriends(local_user(), $cid);
$total = GContact::countAllFriends(local_user(), $cid);
if(count($total))
$a->set_pager_total($total);
$r = GlobalContact::allFriends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
$r = GContact::allFriends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
if (! DBM::is_result($r)) {
$o .= t('No friends to display.');

View file

@ -11,7 +11,7 @@ use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Object\Contact;
use Friendica\Model\Contact;
require_once 'include/event.php';
require_once 'include/redir.php';

View file

@ -4,8 +4,8 @@
*/
use Friendica\App;
use Friendica\Database\DBM;
use Friendica\Model\GlobalContact;
use Friendica\Object\Contact;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
require_once 'include/contact_selectors.php';
require_once 'mod/contacts.php';
@ -85,9 +85,9 @@ function common_content(App $a) {
}
if ($cid) {
$t = GlobalContact::countCommonFriends($uid, $cid);
$t = GContact::countCommonFriends($uid, $cid);
} else {
$t = GlobalContact::countCommonFriendsZcid($uid, $zcid);
$t = GContact::countCommonFriendsZcid($uid, $zcid);
}
if (count($t)) {
@ -99,9 +99,9 @@ function common_content(App $a) {
if ($cid) {
$r = GlobalContact::commonFriends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
$r = GContact::commonFriends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
} else {
$r = GlobalContact::commonFriendsZcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
$r = GContact::commonFriendsZcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
}

View file

@ -6,9 +6,9 @@ use Friendica\App;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\GlobalContact;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Network\Probe;
use Friendica\Object\Contact;
require_once 'include/contact_selectors.php';
require_once 'mod/proxy.php';
@ -313,7 +313,7 @@ function _contact_update_profile($contact_id) {
Contact::updateAvatar($data['photo'], local_user(), $contact_id, true);
// Update the entry in the gcontact table
GlobalContact::updateFromProbe($data["url"]);
GContact::updateFromProbe($data["url"]);
}
function _contact_block($contact_id, $orig_record) {
@ -887,7 +887,7 @@ function contacts_tab($a, $contact_id, $active_tab) {
);
// Show this tab only if there is visible friend list
$x = GlobalContact::countAllFriends(local_user(), $contact_id);
$x = GContact::countAllFriends(local_user(), $contact_id);
if ($x)
$tabs[] = array('label'=>t('Contacts'),
'url' => "allfriends/".$contact_id,
@ -897,7 +897,7 @@ function contacts_tab($a, $contact_id, $active_tab) {
'accesskey' => 't');
// Show this tab only if there is visible common friend list
$common = GlobalContact::countCommonFriends(local_user(), $contact_id);
$common = GContact::countCommonFriends(local_user(), $contact_id);
if ($common)
$tabs[] = array('label'=>t('Common Friends'),
'url' => "common/loc/".local_user()."/".$contact_id,

View file

@ -5,7 +5,7 @@
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Object\Contact;
use Friendica\Model\Contact;
require_once 'include/contact_selectors.php';
require_once 'mod/contacts.php';

View file

@ -24,8 +24,8 @@ use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Network\Probe;
use Friendica\Object\Contact;
use Friendica\Protocol\Diaspora;
require_once 'include/enotify.php';

View file

@ -9,7 +9,7 @@
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Object\Contact;
use Friendica\Model\Contact;
use Friendica\Protocol\DFRN;
require_once 'include/items.php';

View file

@ -15,8 +15,8 @@ use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Network\Probe;
use Friendica\Object\Contact;
require_once 'include/enotify.php';
require_once 'include/group.php';

View file

@ -3,7 +3,7 @@
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Object\Contact;
use Friendica\Model\Contact;
function directory_init(App $a) {
$a->set_pager_itemspage(60);

View file

@ -6,9 +6,9 @@ use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Model\GlobalContact;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Network\Probe;
use Friendica\Object\Contact;
use Friendica\Protocol\PortableContact;
require_once 'include/contact_widgets.php';
@ -82,7 +82,7 @@ function dirfind_content(App $a, $prefix = "") {
// Add the contact to the global contacts if it isn't already in our system
if (($contact["cid"] == 0) && ($contact["zid"] == 0) && ($contact["gid"] == 0)) {
GlobalContact::update($user_data);
GContact::update($user_data);
}
} elseif ($local) {

View file

@ -4,7 +4,7 @@ use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Object\Contact;
use Friendica\Model\Contact;
use Friendica\Protocol\DFRN;
function display_init(App $a) {

View file

@ -7,7 +7,7 @@
use Friendica\App;
use Friendica\Core\System;
use Friendica\Object\Photo;
use Friendica\Object\Image;
/**
* @param App $a
@ -66,7 +66,7 @@ function fbrowser_content(App $a) {
function _map_files1($rr){
$a = get_app();
$types = Photo::supportedTypes();
$types = Image::supportedTypes();
$ext = $types[$rr['type']];
$filename_e = $rr['filename'];

View file

@ -3,8 +3,8 @@
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Model\Contact;
use Friendica\Network\Probe;
use Friendica\Object\Contact;
require_once 'include/follow.php';
require_once 'include/contact_selectors.php';

View file

@ -10,8 +10,8 @@
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Model\GlobalContact;
use Friendica\Object\Contact;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
function hovercard_init(App $a) {
// Just for testing purposes
@ -47,7 +47,7 @@ function hovercard_content() {
}
// if it's the url containing https it should be converted to http
$nurl = normalise_link(GlobalContact::cleanContactUrl($profileurl));
$nurl = normalise_link(GContact::cleanContactUrl($profileurl));
if($nurl) {
// Search for contact data
$contact = Contact::getDetailsByURL($nurl);

View file

@ -5,7 +5,7 @@
use Friendica\App;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Object\Photo;
use Friendica\Object\Image;
$install_wizard_pass = 1;
@ -503,7 +503,7 @@ function check_imagik(&$checks) {
if (class_exists('Imagick')) {
$imagick = true;
$supported = Photo::supportedTypes();
$supported = Image::supportedTypes();
if (array_key_exists('image/gif', $supported)) {
$gif = true;
}

View file

@ -22,9 +22,9 @@ use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\GlobalContact;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Network\Probe;
use Friendica\Object\Contact;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\Email;
use Friendica\Util\Emailer;
@ -743,7 +743,7 @@ function item_post(App $a) {
$datarray['postopts'] = $postopts;
$datarray['origin'] = $origin;
$datarray['moderated'] = $allow_moderated;
$datarray['gcontact-id'] = GlobalContact::getId(array("url" => $datarray['author-link'], "network" => $datarray['network'],
$datarray['gcontact-id'] = GContact::getId(array("url" => $datarray['author-link'], "network" => $datarray['network'],
"photo" => $datarray['author-avatar'], "name" => $datarray['author-name']));
$datarray['object'] = $object;
@ -1244,7 +1244,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
if (!DBM::is_result($r)) {
$probed = Probe::uri($name);
if ($result['network'] != NETWORK_PHANTOM) {
GlobalContact::update($probed);
GContact::update($probed);
$r = q("SELECT `url`, `name`, `nick`, `network`, `alias`, `notify` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
dbesc(normalise_link($probed["url"])));
}

View file

@ -6,7 +6,7 @@ use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Object\Contact;
use Friendica\Model\Contact;
require_once 'include/text.php';
require_once 'include/contact_widgets.php';

View file

@ -4,7 +4,7 @@ use Friendica\App;
use Friendica\Content\Smilies;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Object\Contact;
use Friendica\Model\Contact;
require_once 'include/acl_selectors.php';
require_once 'include/message.php';

View file

@ -9,7 +9,7 @@ use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Database\DBM;
use Friendica\Object\Contact;
use Friendica\Model\Contact;
require_once 'include/conversation.php';
require_once 'include/group.php';

View file

@ -4,7 +4,7 @@
*/
use Friendica\App;
use Friendica\Database\DBM;
use Friendica\Object\Contact;
use Friendica\Model\Contact;
require_once 'include/contact_selectors.php';

View file

@ -4,7 +4,7 @@
*/
use Friendica\App;
use Friendica\Database\DBM;
use Friendica\Object\Photo;
use Friendica\Object\Image;
require_once 'include/security.php';
@ -75,7 +75,7 @@ function photo_init(App $a) {
$uid = str_replace(array('.jpg', '.png', '.gif'), array('', '', ''), $person);
foreach (Photo::supportedTypes() AS $m => $e) {
foreach (Image::supportedTypes() AS $m => $e) {
$uid = str_replace('.'.$e, '', $uid);
}
@ -100,7 +100,7 @@ function photo_init(App $a) {
$resolution = 0;
$photo = str_replace(array('.jpg', '.png', '.gif'), array('', '', ''), $photo);
foreach (Photo::supportedTypes() AS $m => $e) {
foreach (Image::supportedTypes() AS $m => $e) {
$photo = str_replace('.'.$e, '', $photo);
}
@ -167,14 +167,14 @@ function photo_init(App $a) {
}
// Resize only if its not a GIF and it is supported by the library
if (($mimetype != "image/gif") && in_array($mimetype, Photo::supportedTypes())) {
$ph = new Photo($data, $mimetype);
if ($ph->isValid()) {
if (($mimetype != "image/gif") && in_array($mimetype, Image::supportedTypes())) {
$Image = new Image($data, $mimetype);
if ($Image->isValid()) {
if (isset($customres) && $customres > 0 && $customres < 500) {
$ph->scaleImageSquare($customres);
$Image->scaleToSquare($customres);
}
$data = $ph->imageString();
$mimetype = $ph->getType();
$data = $Image->asString();
$mimetype = $Image->getType();
}
}

View file

@ -8,9 +8,10 @@ use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Photo;
use Friendica\Network\Probe;
use Friendica\Object\Contact;
use Friendica\Object\Photo;
use Friendica\Object\Image;
require_once 'include/photos.php';
require_once 'include/items.php';
@ -136,7 +137,7 @@ function photos_post(App $a) {
logger('mod_photos: REQUEST ' . print_r($_REQUEST,true), LOGGER_DATA);
logger('mod_photos: FILES ' . print_r($_FILES,true), LOGGER_DATA);
$phototypes = Photo::supportedTypes();
$phototypes = Image::supportedTypes();
$can_post = false;
$visitor = 0;
@ -424,16 +425,16 @@ function photos_post(App $a) {
intval($page_owner_uid)
);
if (DBM::is_result($r)) {
$ph = new Photo($r[0]['data'], $r[0]['type']);
if ($ph->isValid()) {
$Image = new Image($r[0]['data'], $r[0]['type']);
if ($Image->isValid()) {
$rotate_deg = ( (intval($_POST['rotate']) == 1) ? 270 : 90 );
$ph->rotate($rotate_deg);
$Image->rotate($rotate_deg);
$width = $ph->getWidth();
$height = $ph->getHeight();
$width = $Image->getWidth();
$height = $Image->getHeight();
$x = q("UPDATE `photo` SET `data` = '%s', `height` = %d, `width` = %d WHERE `resource-id` = '%s' AND `uid` = %d AND `scale` = 0",
dbesc($ph->imageString()),
dbesc($Image->asString()),
intval($height),
intval($width),
dbesc($resource_id),
@ -441,12 +442,12 @@ function photos_post(App $a) {
);
if ($width > 640 || $height > 640) {
$ph->scaleImage(640);
$width = $ph->getWidth();
$height = $ph->getHeight();
$Image->scaleDown(640);
$width = $Image->getWidth();
$height = $Image->getHeight();
$x = q("UPDATE `photo` SET `data` = '%s', `height` = %d, `width` = %d WHERE `resource-id` = '%s' AND `uid` = %d AND `scale` = 1",
dbesc($ph->imageString()),
dbesc($Image->asString()),
intval($height),
intval($width),
dbesc($resource_id),
@ -455,12 +456,12 @@ function photos_post(App $a) {
}
if ($width > 320 || $height > 320) {
$ph->scaleImage(320);
$width = $ph->getWidth();
$height = $ph->getHeight();
$Image->scaleDown(320);
$width = $Image->getWidth();
$height = $Image->getHeight();
$x = q("UPDATE `photo` SET `data` = '%s', `height` = %d, `width` = %d WHERE `resource-id` = '%s' AND `uid` = %d AND `scale` = 2",
dbesc($ph->imageString()),
dbesc($Image->asString()),
intval($height),
intval($width),
dbesc($resource_id),
@ -811,7 +812,7 @@ function photos_post(App $a) {
$type = $_FILES['userfile']['type'];
}
if ($type == "") {
$type = Photo::guessImageType($filename);
$type = Image::guessType($filename);
}
logger('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG);
@ -838,9 +839,9 @@ function photos_post(App $a) {
$imagedata = @file_get_contents($src);
$ph = new Photo($imagedata, $type);
$Image = new Image($imagedata, $type);
if (! $ph->isValid()) {
if (! $Image->isValid()) {
logger('mod/photos.php: photos_post(): unable to process image' , LOGGER_DEBUG);
notice( t('Unable to process image.') . EOL );
@unlink($src);
@ -849,7 +850,7 @@ function photos_post(App $a) {
killme();
}
$exif = $ph->orient($src);
$exif = $Image->orient($src);
@unlink($src);
$max_length = Config::get('system', 'max_image_length');
@ -857,17 +858,17 @@ function photos_post(App $a) {
$max_length = MAX_IMAGE_LENGTH;
}
if ($max_length > 0) {
$ph->scaleImage($max_length);
$Image->scaleDown($max_length);
}
$width = $ph->getWidth();
$height = $ph->getHeight();
$width = $Image->getWidth();
$height = $Image->getHeight();
$smallest = 0;
$photo_hash = photo_new_resource();
$r = $ph->store($page_owner_uid, $visitor, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
$r = Photo::store($Image, $page_owner_uid, $visitor, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
if (! $r) {
logger('mod/photos.php: photos_post(): image store failed' , LOGGER_DEBUG);
@ -876,14 +877,14 @@ function photos_post(App $a) {
}
if ($width > 640 || $height > 640) {
$ph->scaleImage(640);
$ph->store($page_owner_uid, $visitor, $photo_hash, $filename, $album, 1, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
$Image->scaleDown(640);
Photo::store($Image, $page_owner_uid, $visitor, $photo_hash, $filename, $album, 1, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
$smallest = 1;
}
if ($width > 320 || $height > 320) {
$ph->scaleImage(320);
$ph->store($page_owner_uid, $visitor, $photo_hash, $filename, $album, 2, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
$Image->scaleDown(320);
Photo::store($Image, $page_owner_uid, $visitor, $photo_hash, $filename, $album, 2, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
$smallest = 2;
}
@ -932,7 +933,7 @@ function photos_post(App $a) {
$arr['origin'] = 1;
$arr['body'] = '[url=' . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo_hash . ']'
. '[img]' . System::baseUrl() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/img]'
. '[img]' . System::baseUrl() . "/photo/{$photo_hash}-{$smallest}.".$Image->getExt() . '[/img]'
. '[/url]';
$item_id = item_store($arr);
@ -980,7 +981,7 @@ function photos_content(App $a) {
return;
}
$phototypes = Photo::supportedTypes();
$phototypes = Image::supportedTypes();
$_SESSION['photo_return'] = $a->cmd;

View file

@ -9,7 +9,7 @@ use Friendica\Core\Cache;
use Friendica\Core\System;
use Friendica\Core\PConfig;
use Friendica\Database\DBM;
use Friendica\Object\Contact;
use Friendica\Model\Contact;
use Friendica\Util\XML;
require_once 'include/datetime.php';

View file

@ -7,7 +7,8 @@ use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Object\Photo;
use Friendica\Model\Photo;
use Friendica\Object\Image;
function profile_photo_init(App $a) {
@ -72,27 +73,27 @@ function profile_photo_post(App $a) {
$base_image = $r[0];
$im = new Photo($base_image['data'], $base_image['type']);
if ($im->isValid()) {
$im->cropImage(175,$srcX,$srcY,$srcW,$srcH);
$Image = new Image($base_image['data'], $base_image['type']);
if ($Image->isValid()) {
$Image->crop(175,$srcX,$srcY,$srcW,$srcH);
$r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 4, $is_default_profile);
$r = Photo::store($Image, local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 4, $is_default_profile);
if ($r === false) {
notice ( sprintf(t('Image size reduction [%s] failed.'),"175") . EOL );
}
$im->scaleImage(80);
$Image->scaleDown(80);
$r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 5, $is_default_profile);
$r = Photo::store($Image, local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 5, $is_default_profile);
if ($r === false) {
notice( sprintf(t('Image size reduction [%s] failed.'),"80") . EOL );
}
$im->scaleImage(48);
$Image->scaleDown(48);
$r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 6, $is_default_profile);
$r = Photo::store($Image, local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 6, $is_default_profile);
if ($r === false) {
notice( sprintf(t('Image size reduction [%s] failed.'),"48") . EOL );
@ -107,15 +108,15 @@ function profile_photo_post(App $a) {
);
$r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `self` AND `uid` = %d",
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()),
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()),
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-6.' . $im->getExt()),
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-4.' . $Image->getExt()),
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-5.' . $Image->getExt()),
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-6.' . $Image->getExt()),
intval(local_user())
);
} else {
$r = q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d",
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()),
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()),
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-4.' . $Image->getExt()),
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-5.' . $Image->getExt()),
intval($_REQUEST['profile']),
intval(local_user())
);
@ -151,7 +152,7 @@ function profile_photo_post(App $a) {
$filesize = intval($_FILES['userfile']['size']);
$filetype = $_FILES['userfile']['type'];
if ($filetype == "") {
$filetype = Photo::guessImageType($filename);
$filetype = Image::guessType($filename);
}
$maximagesize = Config::get('system', 'maximagesize');
@ -163,7 +164,7 @@ function profile_photo_post(App $a) {
}
$imagedata = @file_get_contents($src);
$ph = new Photo($imagedata, $filetype);
$ph = new Image($imagedata, $filetype);
if (! $ph->isValid()) {
notice(t('Unable to process image.') . EOL);
@ -239,7 +240,7 @@ function profile_photo_content(App $a) {
goaway(System::baseUrl() . '/profiles');
return; // NOTREACHED
}
$ph = new Photo($r[0]['data'], $r[0]['type']);
$ph = new Image($r[0]['data'], $r[0]['type']);
profile_photo_crop_ui_head($a, $ph);
// go ahead as we have jus uploaded a new photo to crop
}
@ -288,22 +289,22 @@ function profile_photo_content(App $a) {
if(! function_exists('profile_photo_crop_ui_head')) {
function profile_photo_crop_ui_head(App $a, $ph) {
function profile_photo_crop_ui_head(App $a, Image $Image) {
$max_length = Config::get('system','max_image_length');
if (! $max_length) {
$max_length = MAX_IMAGE_LENGTH;
}
if ($max_length > 0) {
$ph->scaleImage($max_length);
$Image->scaleDown($max_length);
}
$width = $ph->getWidth();
$height = $ph->getHeight();
$width = $Image->getWidth();
$height = $Image->getHeight();
if ($width < 175 || $height < 175) {
$ph->scaleImageUp(200);
$width = $ph->getWidth();
$height = $ph->getHeight();
$Image->scaleUp(200);
$width = $Image->getWidth();
$height = $Image->getHeight();
}
$hash = photo_new_resource();
@ -311,7 +312,7 @@ function profile_photo_crop_ui_head(App $a, $ph) {
$smallest = 0;
$r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 0 );
$r = Photo::store($Image, local_user(), 0 , $hash, $filename, t('Profile Photos'), 0 );
if ($r) {
info( t('Image uploaded successfully.') . EOL );
@ -320,8 +321,8 @@ function profile_photo_crop_ui_head(App $a, $ph) {
}
if ($width > 640 || $height > 640) {
$ph->scaleImage(640);
$r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 1 );
$Image->scaleDown(640);
$r = Photo::store($Image, local_user(), 0 , $hash, $filename, t('Profile Photos'), 1 );
if ($r === false) {
notice( sprintf(t('Image size reduction [%s] failed.'),"640") . EOL );
@ -332,7 +333,7 @@ function profile_photo_crop_ui_head(App $a, $ph) {
$a->config['imagecrop'] = $hash;
$a->config['imagecrop_resolution'] = $smallest;
$a->config['imagecrop_ext'] = $ph->getExt();
$a->config['imagecrop_ext'] = $Image->getExt();
$a->page['htmlhead'] .= replace_macros(get_markup_template("crophead.tpl"), array());
$a->page['end'] .= replace_macros(get_markup_template("cropend.tpl"), array());
return;

View file

@ -9,9 +9,9 @@ use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\GlobalContact;
use Friendica\Model\GContact;
use Friendica\Model\Profile;
use Friendica\Network\Probe;
use Friendica\Object\Profile;
function profiles_init(App $a) {
@ -509,7 +509,7 @@ function profiles_post(App $a) {
Worker::add(PRIORITY_LOW, 'ProfileUpdate', local_user());
// Update the global contact for the user
GlobalContact::updateForUser(local_user());
GContact::updateForUser(local_user());
}
}
}

View file

@ -8,7 +8,8 @@ use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Object\Photo;
use Friendica\Model\Photo;
use Friendica\Object\Image;
define('PROXY_DEFAULT_TIME', 86400); // 1 Day
@ -130,9 +131,9 @@ function proxy_init(App $a) {
// reduce quality - if it isn't a GIF
if ($mime != 'image/gif') {
$img = new Photo($img_str, $mime);
if ($img->isValid()) {
$img_str = $img->imageString();
$Image = new Image($img_str, $mime);
if ($Image->isValid()) {
$img_str = $Image->asString();
}
}
@ -174,10 +175,10 @@ function proxy_init(App $a) {
$mime = 'image/png';
$cachefile = ''; // Clear the cachefile so that the dummy isn't stored
$valid = false;
$img = new Photo($img_str, 'image/png');
if ($img->isValid()) {
$img->scaleImage(10);
$img_str = $img->imageString();
$Image = new Image($img_str, 'image/png');
if ($Image->isValid()) {
$Image->scaleDown(10);
$img_str = $Image->asString();
}
} elseif ($mime != 'image/jpeg' && !$direct_cache && $cachefile == '') {
$image = @imagecreatefromstring($img_str);
@ -192,9 +193,9 @@ function proxy_init(App $a) {
'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '', 'desc' => $mime);
dba::insert('photo', $fields);
} else {
$img = new Photo($img_str, $mime);
if ($img->isValid() && !$direct_cache && ($cachefile == '')) {
$img->store(0, 0, $urlhash, $_REQUEST['url'], '', 100);
$Image = new Image($img_str, $mime);
if ($Image->isValid() && !$direct_cache && ($cachefile == '')) {
Photo::store($Image, 0, 0, $urlhash, $_REQUEST['url'], '', 100);
}
}
}
@ -203,10 +204,10 @@ function proxy_init(App $a) {
// reduce quality - if it isn't a GIF
if ($mime != 'image/gif') {
$img = new Photo($img_str, $mime);
if ($img->isValid()) {
$img->scaleImage($size);
$img_str = $img->imageString();
$Image = new Image($img_str, $mime);
if ($Image->isValid()) {
$Image->scaleDown($size);
$img_str = $Image->asString();
}
}

View file

@ -2,10 +2,10 @@
use Friendica\App;
use Friendica\Core\System;
use Friendica\Model\GlobalContact;
use Friendica\Model\GContact;
function randprof_init(App $a) {
$x = GlobalContact::getRandomUrl();
$x = GContact::getRandomUrl();
if ($x) {
goaway(zrl($x));

View file

@ -9,7 +9,7 @@ use Friendica\Core\Worker;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Database\DBM;
use Friendica\Model\GlobalContact;
use Friendica\Model\GContact;
use Friendica\Model\User;
use Friendica\Protocol\Email;
@ -650,7 +650,7 @@ function settings_post(App $a) {
Worker::add(PRIORITY_LOW, 'ProfileUpdate', local_user());
// Update the global contact for the user
GlobalContact::updateForUser(local_user());
GContact::updateForUser(local_user());
//$_SESSION['theme'] = $theme;
if ($email_changed && $a->config['register_policy'] == REGISTER_VERIFY) {

View file

@ -5,8 +5,8 @@
use Friendica\App;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\GlobalContact;
use Friendica\Object\Contact;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
require_once 'include/contact_widgets.php';
@ -69,7 +69,7 @@ function suggest_content(App $a) {
$a->page['aside'] .= follow_widget();
$r = GlobalContact::suggestionQuery(local_user());
$r = GContact::suggestionQuery(local_user());
if (! DBM::is_result($r)) {
$o .= t('No suggestions available. If this is a new site, please try again in 24 hours.');

View file

@ -3,7 +3,7 @@
use Friendica\App;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Object\Contact;
use Friendica\Model\Contact;
require_once 'include/follow.php';
require_once 'include/contact_selectors.php';

View file

@ -5,7 +5,7 @@ use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Object\Contact;
use Friendica\Model\Contact;
require_once('include/items.php');
require_once('include/acl_selectors.php');

View file

@ -3,7 +3,7 @@
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Object\Contact;
use Friendica\Model\Contact;
require_once('include/contact_selectors.php');

View file

@ -13,7 +13,8 @@ use Friendica\App;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Object\Photo;
use Friendica\Model\Photo;
use Friendica\Object\Image;
function wall_upload_post(App $a, $desktopmode = true) {
@ -161,8 +162,8 @@ function wall_upload_post(App $a, $desktopmode = true) {
$filetype = "";
}
if ($filetype=="") {
$filetype=Photo::guessImageType($filename);
if ($filetype == "") {
$filetype = Image::guessType($filename);
}
// If there is a temp name, then do a manual check
@ -190,9 +191,9 @@ function wall_upload_post(App $a, $desktopmode = true) {
}
$imagedata = @file_get_contents($src);
$ph = new Photo($imagedata, $filetype);
$Image = new Image($imagedata, $filetype);
if (! $ph->isValid()) {
if (! $Image->isValid()) {
$msg = t('Unable to process image.');
if ($r_json) {
echo json_encode(array('error'=>$msg));
@ -203,7 +204,7 @@ function wall_upload_post(App $a, $desktopmode = true) {
killme();
}
$ph->orient($src);
$Image->orient($src);
@unlink($src);
$max_length = Config::get('system', 'max_image_length');
@ -211,12 +212,12 @@ function wall_upload_post(App $a, $desktopmode = true) {
$max_length = MAX_IMAGE_LENGTH;
}
if ($max_length > 0) {
$ph->scaleImage($max_length);
$Image->scaleDown($max_length);
logger("File upload: Scaling picture to new size " . $max_length, LOGGER_DEBUG);
}
$width = $ph->getWidth();
$height = $ph->getHeight();
$width = $Image->getWidth();
$height = $Image->getHeight();
$hash = photo_new_resource();
@ -229,7 +230,7 @@ function wall_upload_post(App $a, $desktopmode = true) {
$defperm = '<' . $default_cid . '>';
$r = $ph->store($page_owner_uid, $visitor, $hash, $filename, $album, 0, 0, $defperm);
$r = Photo::store($Image, $page_owner_uid, $visitor, $hash, $filename, $album, 0, 0, $defperm);
if (! $r) {
$msg = t('Image upload failed.');
@ -242,16 +243,16 @@ function wall_upload_post(App $a, $desktopmode = true) {
}
if ($width > 640 || $height > 640) {
$ph->scaleImage(640);
$r = $ph->store($page_owner_uid, $visitor, $hash, $filename, $album, 1, 0, $defperm);
$Image->scaleDown(640);
$r = Photo::store($Image, $page_owner_uid, $visitor, $hash, $filename, $album, 1, 0, $defperm);
if ($r) {
$smallest = 1;
}
}
if ($width > 320 || $height > 320) {
$ph->scaleImage(320);
$r = $ph->store($page_owner_uid, $visitor, $hash, $filename, $album, 2, 0, $defperm);
$Image->scaleDown(320);
$r = Photo::store($Image, $page_owner_uid, $visitor, $hash, $filename, $album, 2, 0, $defperm);
if ($r && ($smallest == 0)) {
$smallest = 2;
}
@ -280,8 +281,8 @@ function wall_upload_post(App $a, $desktopmode = true) {
$picture["height"] = $r[0]["height"];
$picture["type"] = $r[0]["type"];
$picture["albumpage"] = System::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $hash;
$picture["picture"] = System::baseUrl() . "/photo/{$hash}-0." . $ph->getExt();
$picture["preview"] = System::baseUrl() . "/photo/{$hash}-{$smallest}." . $ph->getExt();
$picture["picture"] = System::baseUrl() . "/photo/{$hash}-0." . $Image->getExt();
$picture["preview"] = System::baseUrl() . "/photo/{$hash}-{$smallest}." . $Image->getExt();
if ($r_json) {
echo json_encode(array('picture'=>$picture));
@ -299,9 +300,9 @@ function wall_upload_post(App $a, $desktopmode = true) {
/* mod Waitman Gobble NO WARRANTY */
// if we get the signal then return the image url info in BBCODE
if ($_REQUEST['hush']!='yeah') {
echo "\n\n" . '[url=' . System::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . System::baseUrl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]\n\n";
echo "\n\n" . '[url=' . System::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . System::baseUrl() . "/photo/{$hash}-{$smallest}.".$Image->getExt()."[/img][/url]\n\n";
} else {
$m = '[url='.System::baseUrl().'/photos/'.$page_owner_nick.'/image/'.$hash.'][img]'.System::baseUrl()."/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]";
$m = '[url='.System::baseUrl().'/photos/'.$page_owner_nick.'/image/'.$hash.'][img]'.System::baseUrl()."/photo/{$hash}-{$smallest}.".$Image->getExt()."[/img][/url]";
return($m);
}
/* mod Waitman Gobble NO WARRANTY */