You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.3 KiB

11 years ago
  1. <?php
  2. abstract class Image extends File
  3. {
  4. public $width;
  5. public $height;
  6. public $type;
  7. public $size;
  8. public $original_filename;
  9. /**
  10. * @var ImageVariant[]
  11. */
  12. public $variants = array();
  13. protected static $max_width;
  14. protected static $max_height;
  15. protected static $sizes = array();
  16. /**
  17. * @param $class string|StdClass
  18. * @throws ErrorException
  19. */
  20. public static function checkSubClass($class)
  21. {
  22. if (!self::getIsSubClass($class)) {
  23. throw new ErrorException('Class "' . $class . '" mast be extend of "Image".');
  24. }
  25. }
  26. /**
  27. * @param $class string|StdClass
  28. * @return bool
  29. */
  30. public static function getIsSubClass($class)
  31. {
  32. return (get_parent_class($class) == __CLASS__);
  33. }
  34. public static function getSizes()
  35. {
  36. return static::$sizes;
  37. }
  38. public static function getMaxWidth()
  39. {
  40. return static::$max_width;
  41. }
  42. public static function getMaxHeight()
  43. {
  44. return static::$max_height;
  45. }
  46. /**
  47. * @param $size
  48. * @param $force_create
  49. * @return ImageVariant
  50. */
  51. public function getVariant($size, $force_create = false)
  52. {
  53. return parent::getImageVariant($size, $force_create);
  54. }
  55. }