X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FPhoto.php;h=f8f50824bd5dc40375b677c4fa4beacb212255a6;hb=dbd5b5bb6e329ceb216fc2c13540e9f482129ccd;hp=db3c4d429bb29680989524d419ae4f4d0b939e40;hpb=8997361609017e1bc73f8241971c118fb71c70f2;p=friendica.git diff --git a/src/Model/Photo.php b/src/Model/Photo.php index db3c4d429b..f8f50824bd 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -6,7 +6,6 @@ */ namespace Friendica\Model; -use Friendica\BaseObject; use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -15,7 +14,9 @@ use Friendica\Core\StorageManager; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Database\DBStructure; +use Friendica\DI; use Friendica\Model\Storage\IStorage; +use Friendica\Model\Storage\SystemResource; use Friendica\Object\Image; use Friendica\Util\DateTimeFormat; use Friendica\Util\Images; @@ -28,7 +29,7 @@ require_once "include/dba.php"; /** * Class to handle photo dabatase table */ -class Photo extends BaseObject +class Photo { /** * @brief Select rows from the photo table and returns them as array @@ -202,7 +203,7 @@ class Photo extends BaseObject */ private static function getFields() { - $allfields = DBStructure::definition(self::getApp()->getBasePath(), false); + $allfields = DBStructure::definition(DI::app()->getBasePath(), false); $fields = array_keys($allfields["photo"]["fields"]); array_splice($fields, array_search("data", $fields), 1); return $fields; @@ -223,7 +224,7 @@ class Photo extends BaseObject $values = array_fill(0, count($fields), ""); $photo = array_combine($fields, $values); - $photo["backend-class"] = Storage\SystemResource::class; + $photo["backend-class"] = SystemResource::NAME; $photo["backend-ref"] = $filename; $photo["type"] = $mimetype; $photo["cacheable"] = false; @@ -273,18 +274,17 @@ class Photo extends BaseObject $data = ""; $backend_ref = ""; - /** @var IStorage $backend_class */ if (DBA::isResult($existing_photo)) { $backend_ref = (string)$existing_photo["backend-ref"]; - $backend_class = (string)$existing_photo["backend-class"]; + $storage = DI::facStorage()->getByName($existing_photo["backend-class"] ?? ''); } else { - $backend_class = StorageManager::getBackend(); + $storage = DI::storage(); } - if ($backend_class === "") { + if ($storage === null) { $data = $Image->asString(); } else { - $backend_ref = $backend_class::put($Image->asString(), $backend_ref); + $backend_ref = $storage->put($Image->asString(), $backend_ref); } @@ -309,7 +309,7 @@ class Photo extends BaseObject "deny_cid" => $deny_cid, "deny_gid" => $deny_gid, "desc" => $desc, - "backend-class" => $backend_class, + "backend-class" => (string)$storage, "backend-ref" => $backend_ref ]; @@ -456,12 +456,12 @@ class Photo extends BaseObject $suffix = "?ts=" . time(); - $image_url = System::baseUrl() . "/photo/" . $resource_id . "-4." . $Image->getExt() . $suffix; - $thumb = System::baseUrl() . "/photo/" . $resource_id . "-5." . $Image->getExt() . $suffix; - $micro = System::baseUrl() . "/photo/" . $resource_id . "-6." . $Image->getExt() . $suffix; + $image_url = DI::baseUrl() . "/photo/" . $resource_id . "-4." . $Image->getExt() . $suffix; + $thumb = DI::baseUrl() . "/photo/" . $resource_id . "-5." . $Image->getExt() . $suffix; + $micro = DI::baseUrl() . "/photo/" . $resource_id . "-6." . $Image->getExt() . $suffix; // Remove the cached photo - $a = \get_app(); + $a = DI::app(); $basepath = $a->getBasePath(); if (is_dir($basepath . "/photo")) { @@ -487,9 +487,9 @@ class Photo extends BaseObject } if ($photo_failure) { - $image_url = System::baseUrl() . "/images/person-300.jpg"; - $thumb = System::baseUrl() . "/images/person-80.jpg"; - $micro = System::baseUrl() . "/images/person-48.jpg"; + $image_url = DI::baseUrl() . "/images/person-300.jpg"; + $thumb = DI::baseUrl() . "/images/person-80.jpg"; + $micro = DI::baseUrl() . "/images/person-48.jpg"; } return [$image_url, $thumb, $micro]; @@ -622,7 +622,7 @@ class Photo extends BaseObject } foreach ($images as $image) { - if (!stristr($image, System::baseUrl() . '/photo/')) { + if (!stristr($image, DI::baseUrl() . '/photo/')) { continue; } $image_uri = substr($image,strrpos($image,'/') + 1); @@ -679,8 +679,7 @@ class Photo extends BaseObject */ public static function getGUID($name) { - $a = \get_app(); - $base = $a->getBaseURL(); + $base = DI::baseUrl()->get(); $guid = str_replace([Strings::normaliseLink($base), '/photo/'], '', Strings::normaliseLink($name)); @@ -725,8 +724,7 @@ class Photo extends BaseObject */ public static function isLocalPage($name) { - $a = \get_app(); - $base = $a->getBaseURL(); + $base = DI::baseUrl()->get(); $guid = str_replace(Strings::normaliseLink($base), '', Strings::normaliseLink($name)); $guid = preg_replace("=/photos/.*/image/(.*)=ism", '$1', $guid);