2013-05-24 13:27:47 +04:00
|
|
|
<?php
|
|
|
|
|
2013-09-23 14:07:03 +04:00
|
|
|
abstract class Image extends File
|
2013-05-24 13:27:47 +04:00
|
|
|
{
|
|
|
|
public $width;
|
|
|
|
public $height;
|
|
|
|
public $type;
|
|
|
|
public $size;
|
2013-05-27 12:49:32 +04:00
|
|
|
|
2013-05-24 13:27:47 +04:00
|
|
|
public $original_filename;
|
2013-11-25 13:04:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var ImageVariant[]
|
|
|
|
*/
|
2013-05-24 13:27:47 +04:00
|
|
|
public $variants = array();
|
|
|
|
|
2013-08-19 12:11:40 +04:00
|
|
|
protected static $max_width;
|
|
|
|
|
|
|
|
protected static $max_height;
|
|
|
|
|
2013-06-10 22:06:52 +04:00
|
|
|
protected static $sizes = array();
|
2013-05-24 13:27:47 +04:00
|
|
|
|
2013-11-29 18:33:05 +04:00
|
|
|
public static function getClassName()
|
|
|
|
{
|
|
|
|
return get_called_class();
|
|
|
|
}
|
|
|
|
|
2013-05-24 13:27:47 +04:00
|
|
|
/**
|
2013-08-19 12:11:40 +04:00
|
|
|
* @param $class string|StdClass
|
2013-05-29 15:01:54 +04:00
|
|
|
* @throws ErrorException
|
2013-05-24 13:27:47 +04:00
|
|
|
*/
|
2013-05-29 15:01:54 +04:00
|
|
|
public static function checkSubClass($class)
|
2013-05-24 13:27:47 +04:00
|
|
|
{
|
2013-08-19 12:11:40 +04:00
|
|
|
if (!self::getIsSubClass($class)) {
|
2013-05-29 15:01:54 +04:00
|
|
|
throw new ErrorException('Class "' . $class . '" mast be extend of "Image".');
|
2013-05-24 13:27:47 +04:00
|
|
|
}
|
2013-05-29 15:01:54 +04:00
|
|
|
}
|
|
|
|
|
2013-08-19 12:11:40 +04:00
|
|
|
/**
|
|
|
|
* @param $class string|StdClass
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public static function getIsSubClass($class)
|
|
|
|
{
|
|
|
|
return (get_parent_class($class) == __CLASS__);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getSizes()
|
2013-05-29 15:01:54 +04:00
|
|
|
{
|
2013-06-10 22:06:52 +04:00
|
|
|
return static::$sizes;
|
2013-05-24 13:27:47 +04:00
|
|
|
}
|
2013-06-07 12:18:25 +04:00
|
|
|
|
2013-08-19 12:11:40 +04:00
|
|
|
public static function getMaxWidth()
|
|
|
|
{
|
|
|
|
return static::$max_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getMaxHeight()
|
|
|
|
{
|
|
|
|
return static::$max_height;
|
|
|
|
}
|
|
|
|
|
2013-10-04 17:53:23 +04:00
|
|
|
/**
|
|
|
|
* @param $size
|
|
|
|
* @param $force_create
|
|
|
|
* @return ImageVariant
|
|
|
|
*/
|
|
|
|
public function getVariant($size, $force_create = false)
|
2013-06-07 12:18:25 +04:00
|
|
|
{
|
2013-10-04 17:53:23 +04:00
|
|
|
return parent::getImageVariant($size, $force_create);
|
2013-06-07 12:18:25 +04:00
|
|
|
}
|
2013-05-24 13:27:47 +04:00
|
|
|
}
|