Drupal investigation

Image.php 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Validator\Constraints;
  11. /**
  12. * @Annotation
  13. * @Target({"PROPERTY", "METHOD", "ANNOTATION"})
  14. *
  15. * @author Benjamin Dulau <benjamin.dulau@gmail.com>
  16. * @author Bernhard Schussek <bschussek@gmail.com>
  17. */
  18. class Image extends File
  19. {
  20. const SIZE_NOT_DETECTED_ERROR = '6d55c3f4-e58e-4fe3-91ee-74b492199956';
  21. const TOO_WIDE_ERROR = '7f87163d-878f-47f5-99ba-a8eb723a1ab2';
  22. const TOO_NARROW_ERROR = '9afbd561-4f90-4a27-be62-1780fc43604a';
  23. const TOO_HIGH_ERROR = '7efae81c-4877-47ba-aa65-d01ccb0d4645';
  24. const TOO_LOW_ERROR = 'aef0cb6a-c07f-4894-bc08-1781420d7b4c';
  25. const RATIO_TOO_BIG_ERROR = '70cafca6-168f-41c9-8c8c-4e47a52be643';
  26. const RATIO_TOO_SMALL_ERROR = '59b8c6ef-bcf2-4ceb-afff-4642ed92f12e';
  27. const SQUARE_NOT_ALLOWED_ERROR = '5d41425b-facb-47f7-a55a-de9fbe45cb46';
  28. const LANDSCAPE_NOT_ALLOWED_ERROR = '6f895685-7cf2-4d65-b3da-9029c5581d88';
  29. const PORTRAIT_NOT_ALLOWED_ERROR = '65608156-77da-4c79-a88c-02ef6d18c782';
  30. // Include the mapping from the base class
  31. protected static $errorNames = array(
  32. self::NOT_FOUND_ERROR => 'NOT_FOUND_ERROR',
  33. self::NOT_READABLE_ERROR => 'NOT_READABLE_ERROR',
  34. self::EMPTY_ERROR => 'EMPTY_ERROR',
  35. self::TOO_LARGE_ERROR => 'TOO_LARGE_ERROR',
  36. self::INVALID_MIME_TYPE_ERROR => 'INVALID_MIME_TYPE_ERROR',
  37. self::SIZE_NOT_DETECTED_ERROR => 'SIZE_NOT_DETECTED_ERROR',
  38. self::TOO_WIDE_ERROR => 'TOO_WIDE_ERROR',
  39. self::TOO_NARROW_ERROR => 'TOO_NARROW_ERROR',
  40. self::TOO_HIGH_ERROR => 'TOO_HIGH_ERROR',
  41. self::TOO_LOW_ERROR => 'TOO_LOW_ERROR',
  42. self::RATIO_TOO_BIG_ERROR => 'RATIO_TOO_BIG_ERROR',
  43. self::RATIO_TOO_SMALL_ERROR => 'RATIO_TOO_SMALL_ERROR',
  44. self::SQUARE_NOT_ALLOWED_ERROR => 'SQUARE_NOT_ALLOWED_ERROR',
  45. self::LANDSCAPE_NOT_ALLOWED_ERROR => 'LANDSCAPE_NOT_ALLOWED_ERROR',
  46. self::PORTRAIT_NOT_ALLOWED_ERROR => 'PORTRAIT_NOT_ALLOWED_ERROR',
  47. );
  48. public $mimeTypes = 'image/*';
  49. public $minWidth;
  50. public $maxWidth;
  51. public $maxHeight;
  52. public $minHeight;
  53. public $maxRatio;
  54. public $minRatio;
  55. public $allowSquare = true;
  56. public $allowLandscape = true;
  57. public $allowPortrait = true;
  58. // The constant for a wrong MIME type is taken from the parent class.
  59. public $mimeTypesMessage = 'This file is not a valid image.';
  60. public $sizeNotDetectedMessage = 'The size of the image could not be detected.';
  61. public $maxWidthMessage = 'The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px.';
  62. public $minWidthMessage = 'The image width is too small ({{ width }}px). Minimum width expected is {{ min_width }}px.';
  63. public $maxHeightMessage = 'The image height is too big ({{ height }}px). Allowed maximum height is {{ max_height }}px.';
  64. public $minHeightMessage = 'The image height is too small ({{ height }}px). Minimum height expected is {{ min_height }}px.';
  65. public $maxRatioMessage = 'The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}.';
  66. public $minRatioMessage = 'The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}.';
  67. public $allowSquareMessage = 'The image is square ({{ width }}x{{ height }}px). Square images are not allowed.';
  68. public $allowLandscapeMessage = 'The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed.';
  69. public $allowPortraitMessage = 'The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.';
  70. }