IsCompressed.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Validate
  17. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id$
  20. */
  21. /**
  22. * @see Zend_Validate_File_MimeType
  23. */
  24. require_once 'Zend/Validate/File/MimeType.php';
  25. /**
  26. * Validator which checks if the file already exists in the directory
  27. *
  28. * @category Zend
  29. * @package Zend_Validate
  30. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. */
  33. class Zend_Validate_File_IsCompressed extends Zend_Validate_File_MimeType
  34. {
  35. /**
  36. * @const string Error constants
  37. */
  38. const FALSE_TYPE = 'fileIsCompressedFalseType';
  39. const NOT_DETECTED = 'fileIsCompressedNotDetected';
  40. const NOT_READABLE = 'fileIsCompressedNotReadable';
  41. /**
  42. * @var array Error message templates
  43. */
  44. protected $_messageTemplates = array(
  45. self::FALSE_TYPE => "The file '%value%' is not compressed, '%type%' detected",
  46. self::NOT_DETECTED => "The mimetype of file '%value%' has not been detected",
  47. self::NOT_READABLE => "The file '%value%' can not be read"
  48. );
  49. /**
  50. * Sets validator options
  51. *
  52. * @param string|array|Zend_Config $compression
  53. * @return void
  54. */
  55. public function __construct($mimetype = array())
  56. {
  57. if ($mimetype instanceof Zend_Config) {
  58. $mimetype = $mimetype->toArray();
  59. } else if (empty($mimetype)) {
  60. $mimetype = array(
  61. 'application/x-tar',
  62. 'application/x-cpio',
  63. 'application/x-debian-package',
  64. 'application/x-archive',
  65. 'application/x-arc',
  66. 'application/x-arj',
  67. 'application/x-lharc',
  68. 'application/x-lha',
  69. 'application/x-rar',
  70. 'application/zip',
  71. 'application/zoo',
  72. 'application/x-eet',
  73. 'application/x-java-pack200',
  74. 'application/x-compress',
  75. 'application/x-gzip',
  76. 'application/x-bzip2'
  77. );
  78. }
  79. $this->setMimeType($mimetype);
  80. }
  81. }