1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-18 07:52:21 +01:00

Cleanup in TemporaryPhoto

This commit is contained in:
Thomas Tanghus 2014-03-24 21:24:45 +01:00
parent 8368b128cd
commit f7ea06fe79
4 changed files with 18 additions and 8 deletions

View File

@ -24,6 +24,8 @@ namespace OCA\Contacts\Utils;
/**
* This class is used for getting a temporary contact photo for cropping.
*
* Sub-classes must override __construct() and processImage()
*/
class TemporaryPhoto {

View File

@ -23,12 +23,12 @@
namespace OCA\Contacts\Utils\TemporaryPhoto;
use OCA\Contacts\Contact as ContactObject,
OCA\Contacts\Utils\TemporaryPhoto as AbstractTemporaryPhoto;
OCA\Contacts\Utils\TemporaryPhoto as BaseTemporaryPhoto;
/**
* This class loads the PHOTO or LOGO property from a contact.
*/
class Contact extends AbstractTemporaryPhoto {
class Contact extends BaseTemporaryPhoto {
/**
* The Contact object to load the image from

View File

@ -23,12 +23,13 @@
namespace OCA\Contacts\Utils\TemporaryPhoto;
use OCA\Contacts\Contact as ContactObject,
OCA\Contacts\Utils\TemporaryPhoto as AbstractTemporaryPhoto;
OCA\Contacts\Utils\TemporaryPhoto as BaseTemporaryPhoto,
OCP\AppFramework\Http;
/**
* This class loads an image from the virtual file system.
*/
class FileSystem extends AbstractTemporaryPhoto {
class FileSystem extends BaseTemporaryPhoto {
/**
* The virtual file system path to load the image from
@ -54,10 +55,17 @@ class FileSystem extends AbstractTemporaryPhoto {
* Load the image.
*/
protected function processImage() {
$localpath = \OC\Files\Filesystem::getLocalFile($this->path);
$localPath = \OC\Files\Filesystem::getLocalFile($this->path);
if (!file_exists($localPath)) {
throw new \Exception(
'The file does not exist: ' . $localPath,
Http::STATUS_NOT_FOUND
);
}
$this->image = new \OCP\Image();
$this->image->loadFromFile($localpath);
$this->image->loadFromFile($localPath);
}
}

View File

@ -23,7 +23,7 @@
namespace OCA\Contacts\Utils\TemporaryPhoto;
use OCA\Contacts\Contact as ContactObject,
OCA\Contacts\Utils\TemporaryPhoto as AbstractTemporaryPhoto,
OCA\Contacts\Utils\TemporaryPhoto as BaseTemporaryPhoto,
OCP\IRequest,
OCP\AppFramework\Http,
OCP\Image;
@ -31,7 +31,7 @@ use OCA\Contacts\Contact as ContactObject,
/**
* This class loads an image from the virtual file system.
*/
class Uploaded extends AbstractTemporaryPhoto {
class Uploaded extends BaseTemporaryPhoto {
/**
* The request to read the data from