Files
image/Image.class.php

79 lines
1.6 KiB
PHP
Raw Normal View History

2013-05-24 13:27:47 +04:00
<?php
abstract class Image extends File
2013-05-24 13:27:47 +04:00
{
public $width;
public $height;
public $type;
public $size;
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();
protected static $max_width;
protected static $max_height;
protected static $sizes = array();
2013-05-24 13:27:47 +04:00
protected static $watermarks = array();
public static function getClassName()
{
return get_called_class();
}
2013-05-24 13:27:47 +04:00
/**
* @param $class string|StdClass
* @throws ErrorException
2013-05-24 13:27:47 +04:00
*/
public static function checkSubClass($class)
2013-05-24 13:27:47 +04:00
{
if (!self::getIsSubClass($class)) {
throw new ErrorException('Class "' . $class . '" mast be extend of "Image".');
2013-05-24 13:27:47 +04:00
}
}
/**
* @param $class string|StdClass
* @return bool
*/
public static function getIsSubClass($class)
{
return (get_parent_class($class) == __CLASS__);
}
public static function getSizes()
{
return static::$sizes;
2013-05-24 13:27:47 +04:00
}
public static function getWatermark($size)
{
return (isset(static::$watermarks[$size])) ? static::$watermarks[$size] : false;
}
public static function getMaxWidth()
{
return static::$max_width;
}
public static function getMaxHeight()
{
return static::$max_height;
}
/**
* @param $size
* @param $force_create
* @return ImageVariant
*/
public function getVariant($size, $force_create = false)
{
return parent::getImageVariant($size, $force_create);
}
2013-05-24 13:27:47 +04:00
}