From cb1eb1369b8bf3a9d1eaa71cabb8bae98899926e Mon Sep 17 00:00:00 2001 From: Alexander Demidov Date: Fri, 29 Nov 2013 18:33:05 +0400 Subject: [PATCH] =?UTF-8?q?Image::getClassName=20=D0=B8=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0=20=D0=BD=D0=B0=20=D1=81?= =?UTF-8?q?=D1=83=D1=89=D0=B5=D1=81=D1=82=D0=B2=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=D0=B7=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=BF=D0=BE=20=D0=BF=D0=B0=D1=80=D0=B0?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D1=80=D1=83=20error.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Image.class.php | 5 +++++ Upload.class.php | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Image.class.php b/Image.class.php index 3ac4d6d..fce7b72 100644 --- a/Image.class.php +++ b/Image.class.php @@ -20,6 +20,11 @@ abstract class Image extends File protected static $sizes = array(); + public static function getClassName() + { + return get_called_class(); + } + /** * @param $class string|StdClass * @throws ErrorException diff --git a/Upload.class.php b/Upload.class.php index 7c67716..eb7d05b 100644 --- a/Upload.class.php +++ b/Upload.class.php @@ -19,11 +19,11 @@ abstract class Upload /** * @param $class string|Image - * @param $file array (ex. ['tmp_name' => '...', 'name' => '...', 'type' => '...']) + * @param $file array (ex. ['tmp_name' => '...', 'name' => '...', 'error' => '...']) * @param $force_create_variants bool * @return Image * @throws ErrorException - * TODO: Рефакторинг: убрать параметр $force_create_variants + * TODO: Рефакторинг: убрать параметр $force_create_variants? */ public static function image($class, $file, $force_create_variants = true) { @@ -37,6 +37,9 @@ abstract class Upload throw new ErrorException('Class "' . $class . '" not exists.'); } Image::checkSubClass($class); + if (isset($file['error']) && $file['error'] != 0) { + return false; + } $image = is_object($class) ? $class : new $class; $image->original_filename = $file['name']; $greagwar_image = self::getGreagwarImage($file['tmp_name']); @@ -47,7 +50,6 @@ abstract class Upload self::imageVariant($image, $size); } } - // В случае, если был передан объект, возвращение результата не имеет значения return $image; }