Photo to src

Move Photo to Friendica\Object namespace and replace require_once statments with use statements.
This commit is contained in:
Adam Magness 2017-11-29 07:52:27 -05:00
parent 7b5a0fdbe0
commit 54827e7fed
27 changed files with 68 additions and 60 deletions

View file

@ -23,6 +23,7 @@ use Friendica\Network\HTTPException\NotImplementedException;
use Friendica\Network\HTTPException\UnauthorizedException;
use Friendica\Network\HTTPException\TooManyRequestsException;
use Friendica\Object\Contact;
use Friendica\Object\Photo;
use Friendica\Protocol\Diaspora;
use Friendica\Util\XML;
@ -32,7 +33,6 @@ require_once 'include/conversation.php';
require_once 'include/oauth.php';
require_once 'include/html2plain.php';
require_once 'mod/share.php';
require_once 'include/Photo.php';
require_once 'mod/item.php';
require_once 'include/security.php';
require_once 'include/contact_selectors.php';

View file

@ -8,13 +8,13 @@ use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Network\Probe;
use Friendica\Object\Photo;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\OStatus;
use Friendica\Protocol\PortableContact;
require_once 'include/group.php';
require_once 'include/salmon.php';
require_once 'include/Photo.php';
function update_contact($id) {
/*

View file

@ -1,9 +1,7 @@
<?php
/**
* @file include/items.php
*/
use Friendica\App;
use Friendica\ParseUrl;
use Friendica\Core\Config;
@ -13,6 +11,7 @@ use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\GlobalContact;
use Friendica\Object\Contact;
use Friendica\Object\Photo;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\OStatus;
use Friendica\Util\Lock;
@ -21,7 +20,6 @@ require_once 'include/bbcode.php';
require_once 'include/oembed.php';
require_once 'include/salmon.php';
require_once 'include/crypto.php';
require_once 'include/Photo.php';
require_once 'include/tags.php';
require_once 'include/files.php';
require_once 'include/text.php';

View file

@ -1,13 +1,12 @@
<?php
/**
* @file include/network.php
*/
use Friendica\App;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Network\Probe;
use Friendica\Object\Photo;
use Friendica\Util\XML;
/**
@ -687,7 +686,6 @@ function scale_external_images($srctext, $include_link = true, $scale_replace =
$matches = null;
$c = preg_match_all('/\[img.*?\](.*?)\[\/img\]/ism', $s, $matches, PREG_SET_ORDER);
if ($c) {
require_once 'include/Photo.php';
foreach ($matches as $mtch) {
logger('scale_external_image: ' . $mtch[1]);

View file

@ -1,17 +1,15 @@
<?php
/**
* @file include/plaintext.php
*/
use Friendica\App;
use Friendica\ParseUrl;
use Friendica\Core\PConfig;
use Friendica\Object\Photo;
require_once("include/Photo.php");
require_once("include/bbcode.php");
require_once("include/html2plain.php");
require_once("include/network.php");
require_once "include/bbcode.php";
require_once "include/html2plain.php";
require_once "include/network.php";
/**
* @brief Fetches attachment data that were generated the old way

View file

@ -1,12 +1,14 @@
<?php
/**
* @file include/uimport.php
*/
use Friendica\App;
use Friendica\Core\System;
use Friendica\Core\PConfig;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Object\Photo;
require_once("include/Photo.php");
define("IMPORT_DEBUG", False);
function last_insert_id() {

View file

@ -1,8 +1,11 @@
<?php
/**
* @file include/user.php
*/
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Object\Photo;
require_once 'include/network.php';
require_once 'include/plugin.php';
@ -283,7 +286,6 @@ function create_user($arr) {
// unless there is no avatar-plugin loaded
if(strlen($photo)) {
require_once('include/Photo.php');
$photo_failure = false;
$filename = basename($photo);

View file

@ -1,5 +1,7 @@
<?php
/**
* @file mod/contacts.php
*/
use Friendica\App;
use Friendica\Core\System;
use Friendica\Core\Worker;
@ -7,10 +9,10 @@ use Friendica\Database\DBM;
use Friendica\Model\GlobalContact;
use Friendica\Network\Probe;
use Friendica\Object\Contact;
use Friendica\Object\Photo;
require_once 'include/contact_selectors.php';
require_once 'mod/proxy.php';
require_once 'include/Photo.php';
function contacts_init(App $a) {
if (! local_user()) {

View file

@ -4,6 +4,7 @@ use Friendica\App;
use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Object\Contact;
use Friendica\Object\Photo;
require_once 'include/contact_selectors.php';
require_once 'mod/contacts.php';
@ -86,7 +87,6 @@ function crepair_post(App $a) {
if($photo) {
logger('mod-crepair: updating photo from ' . $photo);
require_once("include/Photo.php");
update_contact_avatar($photo,local_user(),$contact['id']);
}

View file

@ -25,6 +25,7 @@ use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Network\Probe;
use Friendica\Object\Photo;
use Friendica\Protocol\Diaspora;
require_once 'include/enotify.php';
@ -325,8 +326,6 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
*
*/
require_once 'include/Photo.php';
update_contact_avatar($contact['photo'],$uid,$contact_id);
logger('dfrn_confirm: confirm - imported photos');
@ -676,8 +675,6 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$photo = System::baseUrl() . '/images/person-175.jpg';
}
require_once 'include/Photo.php';
update_contact_avatar($photo,$local_uid,$dfrn_record);
logger('dfrn_confirm: request - photos imported');

View file

@ -7,8 +7,7 @@
use Friendica\App;
use Friendica\Core\System;
require_once('include/Photo.php');
use Friendica\Object\Photo;
/**
* @param App $a

View file

@ -1,10 +1,11 @@
<?php
/**
* @file mod/install.php
*/
use Friendica\App;
use Friendica\Core\System;
use Friendica\Database\DBM;
require_once "include/Photo.php";
use Friendica\Object\Photo;
$install_wizard_pass = 1;

View file

@ -1,10 +1,12 @@
<?php
/**
* @file mod/photo.php
*/
use Friendica\App;
use Friendica\Database\DBM;
use Friendica\Object\Photo;
require_once('include/security.php');
require_once('include/Photo.php');
require_once 'include/security.php';
function photo_init(App $a) {
global $_SERVER;

View file

@ -1,5 +1,7 @@
<?php
/**
* @file mod/photos.php
*/
use Friendica\App;
use Friendica\Core\System;
use Friendica\Core\Config;
@ -7,8 +9,8 @@ use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Network\Probe;
use Friendica\Object\Contact;
use Friendica\Object\Photo;
require_once 'include/Photo.php';
require_once 'include/photos.php';
require_once 'include/items.php';
require_once 'include/acl_selectors.php';

View file

@ -1,12 +1,13 @@
<?php
/**
* @file mod/profile_photo.php
*/
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
require_once("include/Photo.php");
use Friendica\Object\Photo;
function profile_photo_init(App $a) {

View file

@ -1,10 +1,14 @@
<?php
// Based upon "Privacy Image Cache" by Tobias Hößl <https://github.com/CatoTH/>
/**
* @file mod/proxy.php
* @brief Based upon "Privacy Image Cache" by Tobias Hößl <https://github.com/CatoTH/>
*/
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Object\Photo;
define('PROXY_DEFAULT_TIME', 86400); // 1 Day
@ -15,7 +19,6 @@ define('PROXY_SIZE_MEDIUM', 'medium');
define('PROXY_SIZE_LARGE', 'large');
require_once 'include/security.php';
require_once 'include/Photo.php';
function proxy_init(App $a) {
// Pictures are stored in one of the following ways:

View file

@ -13,8 +13,7 @@ use Friendica\App;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Database\DBM;
require_once 'include/Photo.php';
use Friendica\Object\Photo;
function wall_upload_post(App $a, $desktopmode = true) {

View file

@ -10,6 +10,7 @@ use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Network\Probe;
use Friendica\Object\Photo;
use Friendica\Object\Profile;
use Friendica\Protocol\PortableContact;
use dba;
@ -18,7 +19,6 @@ use Exception;
require_once 'include/datetime.php';
require_once 'include/network.php';
require_once 'include/html2bbcode.php';
require_once 'include/Photo.php';
/**
* @brief This class handles GlobalContact related functions

View file

@ -13,6 +13,7 @@ use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Network\Probe;
use Friendica\Object\Photo;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\OStatus;
@ -643,8 +644,6 @@ class Contact extends BaseObject
}
}
require_once 'include/Photo.php';
update_contact_avatar($data["photo"], $uid, $contact_id);
$contact = dba::select('contact', array('url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date'), array('id' => $contact_id), array('limit' => 1));

View file

@ -1,8 +1,9 @@
<?php
/**
* @file include/Photo.php
* @file src/Object/Photo.php
* @brief This file contains the Photo class for image processing
*/
namespace Friendica\Object;
use Friendica\App;
use Friendica\Core\Cache;
@ -10,7 +11,7 @@ use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Database\DBM;
require_once("include/photos.php");
require_once "include/photos.php";
class Photo {
@ -50,7 +51,8 @@ class Photo {
return $t;
}
public function __construct($data, $type=null) {
public function __construct($data, $type=null)
{
$this->imagick = class_exists('Imagick');
$this->types = static::supportedTypes();
if (!array_key_exists($type, $this->types)){
@ -80,7 +82,8 @@ class Photo {
}
}
public function is_imagick() {
public function is_imagick()
{
return $this->imagick;
}

View file

@ -6,6 +6,7 @@
namespace Friendica;
use Friendica\Core\Config;
use Friendica\Object\Photo;
use Friendica\Util\XML;
use dba;
@ -13,7 +14,6 @@ use DomXPath;
use DOMDocument;
require_once "include/network.php";
require_once "include/Photo.php";
require_once "include/oembed.php";
/**

View file

@ -19,6 +19,7 @@ use Friendica\Database\DBM;
use Friendica\Model\GlobalContact;
use Friendica\Network\Probe;
use Friendica\Object\Contact;
use Friendica\Object\Photo;
use Friendica\Object\Profile;
use Friendica\Util\XML;
@ -27,7 +28,6 @@ use SimpleXMLElement;
require_once 'include/items.php';
require_once 'include/bb2diaspora.php';
require_once 'include/Photo.php';
require_once 'include/group.php';
require_once 'include/datetime.php';
require_once 'include/queue_fn.php';

View file

@ -12,6 +12,7 @@ use Friendica\Database\DBM;
use Friendica\Model\GlobalContact;
use Friendica\Network\Probe;
use Friendica\Object\Contact;
use Friendica\Object\Photo;
use Friendica\Util\Lock;
use Friendica\Util\XML;
use dba;
@ -24,7 +25,6 @@ require_once 'include/bbcode.php';
require_once 'include/items.php';
require_once 'mod/share.php';
require_once 'include/enotify.php';
require_once 'include/Photo.php';
require_once 'include/follow.php';
require_once 'include/api.php';
require_once 'mod/proxy.php';

View file

@ -14,6 +14,7 @@ use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\GlobalContact;
use Friendica\Network\Probe;
use Friendica\Object\Photo;
use Friendica\Object\Profile;
use dba;
use DOMDocument;
@ -23,7 +24,6 @@ use Exception;
require_once 'include/datetime.php';
require_once 'include/network.php';
require_once 'include/html2bbcode.php';
require_once 'include/Photo.php';
class PortableContact
{

View file

@ -6,6 +6,7 @@ use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Object\Photo;
/**
*
@ -146,8 +147,8 @@ function update_1013() {
AFTER `object` , ADD `target` TEXT NOT NULL AFTER `target-type`");
}
function update_1014() {
require_once('include/Photo.php');
function update_1014()
{
q("ALTER TABLE `contact` ADD `micro` TEXT NOT NULL AFTER `thumb` ");
$r = q("SELECT * FROM `photo` WHERE `scale` = 4");
if (DBM::is_result($r)) {

View file

@ -12,6 +12,7 @@ use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Object\Photo;
$frio = "view/theme/frio";
@ -79,9 +80,8 @@ function frio_uninstall() {
* @param App $a Unused but required by hook definition
* @param array $body_info The item and its html output
*/
function frio_item_photo_links(App $a, &$body_info) {
require_once('include/Photo.php');
function frio_item_photo_links(App $a, &$body_info)
{
$phototypes = Photo::supportedTypes();
$occurence = 1;
$p = bb_find_open_close($body_info['html'], "<a", ">");

View file

@ -11,6 +11,7 @@
use Friendica\App;
use Friendica\Core\System;
use Friendica\Object\Photo;
function frost_init(App $a) {
$a->videowidth = 400;
@ -45,8 +46,8 @@ function frost_uninstall() {
logger("uninstalled theme frost");
}
function frost_item_photo_links(App $a, &$body_info) {
require_once('include/Photo.php');
function frost_item_photo_links(App $a, &$body_info)
{
$phototypes = Photo::supportedTypes();
$occurence = 1;