Browse Source

Photo to src

Move Photo to Friendica\Object namespace and replace require_once statments with use statements.
pull/3982/head
Adam Magness 4 years ago
parent
commit
54827e7fed
  1. 2
      include/api.php
  2. 2
      include/follow.php
  3. 4
      include/items.php
  4. 4
      include/network.php
  5. 10
      include/plaintext.php
  6. 6
      include/uimport.php
  7. 6
      include/user.php
  8. 6
      mod/contacts.php
  9. 2
      mod/crepair.php
  10. 5
      mod/dfrn_confirm.php
  11. 3
      mod/fbrowser.php
  12. 7
      mod/install.php
  13. 8
      mod/photo.php
  14. 6
      mod/photos.php
  15. 7
      mod/profile_photo.php
  16. 7
      mod/proxy.php
  17. 3
      mod/wall_upload.php
  18. 2
      src/Model/GlobalContact.php
  19. 3
      src/Object/Contact.php
  20. 11
      src/Object/Photo.php
  21. 2
      src/ParseUrl.php
  22. 2
      src/Protocol/Diaspora.php
  23. 2
      src/Protocol/OStatus.php
  24. 2
      src/Protocol/PortableContact.php
  25. 5
      update.php
  26. 6
      view/theme/frio/theme.php
  27. 5
      view/theme/frost/theme.php

2
include/api.php

@ -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';

2
include/follow.php

@ -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) {
/*

4
include/items.php

@ -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';

4
include/network.php

@ -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]);

10
include/plaintext.php

@ -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

6
include/uimport.php

@ -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() {

6
include/user.php

@ -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);

6
mod/contacts.php

@ -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()) {

2
mod/crepair.php

@ -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']);
}

5
mod/dfrn_confirm.php

@ -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');

3
mod/fbrowser.php

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

7
mod/install.php

@ -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;

8
mod/photo.php

@ -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;

6
mod/photos.php

@ -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';

7
mod/profile_photo.php

@ -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) {

7
mod/proxy.php

@ -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:

3
mod/wall_upload.php

@ -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) {

2
src/Model/GlobalContact.php

@ -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

3
src/Object/Contact.php

@ -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));

11
include/Photo.php → src/Object/Photo.php

@ -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;
}

2
src/ParseUrl.php

@ -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";
/**

2
src/Protocol/Diaspora.php

@ -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';

2
src/Protocol/OStatus.php

@ -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';

2
src/Protocol/PortableContact.php

@ -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
{

5
update.php

@ -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)) {

6
view/theme/frio/theme.php

@ -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", ">");

5
view/theme/frost/theme.php

@ -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;

Loading…
Cancel
Save