Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/zend/Zend/Validate/File/IsCompressed.php
Go to the documentation of this file.
00001 <?php
00025 require_once 'Zend/Validate/File/MimeType.php';
00026 
00035 class Zend_Validate_File_IsCompressed extends Zend_Validate_File_MimeType
00036 {
00040     const FALSE_TYPE   = 'fileIsCompressedFalseType';
00041     const NOT_DETECTED = 'fileIsCompressedNotDetected';
00042     const NOT_READABLE = 'fileIsCompressedNotReadable';
00043 
00047     protected $_messageTemplates = array(
00048         self::FALSE_TYPE   => "File '%value%' is not compressed, '%type%' detected",
00049         self::NOT_DETECTED => "The mimetype of file '%value%' could not been detected",
00050         self::NOT_READABLE => "File '%value%' can not be read",
00051     );
00052 
00059     public function __construct($mimetype = array())
00060     {
00061         if ($mimetype instanceof Zend_Config) {
00062             $mimetype = $mimetype->toArray();
00063         }
00064 
00065         $temp    = array();
00066         // http://de.wikipedia.org/wiki/Liste_von_Dateiendungen
00067             $default = array(
00068             'application/arj',
00069             'application/gnutar',
00070             'application/lha',
00071             'application/lzx',
00072             'application/vnd.ms-cab-compressed',
00073             'application/x-ace-compressed',
00074             'application/x-arc',
00075             'application/x-archive',
00076             'application/x-arj',
00077             'application/x-bzip',
00078             'application/x-bzip2',
00079             'application/x-cab-compressed',
00080             'application/x-compress',
00081             'application/x-compressed',
00082             'application/x-cpio',
00083             'application/x-debian-package',
00084             'application/x-eet',
00085             'application/x-gzip',
00086             'application/x-java-pack200',
00087             'application/x-lha',
00088             'application/x-lharc',
00089             'application/x-lzh',
00090             'application/x-lzma',
00091             'application/x-lzx',
00092             'application/x-rar',
00093             'application/x-sit',
00094             'application/x-stuffit',
00095             'application/x-tar',
00096             'application/zip',
00097             'application/zoo',
00098             'multipart/x-gzip',
00099         );
00100 
00101         if (is_array($mimetype)) {
00102             $temp = $mimetype;
00103             if (array_key_exists('magicfile', $temp)) {
00104                 unset($temp['magicfile']);
00105             }
00106 
00107             if (array_key_exists('headerCheck', $temp)) {
00108                 unset($temp['headerCheck']);
00109             }
00110 
00111             if (empty($temp)) {
00112                 $mimetype += $default;
00113             }
00114         }
00115 
00116         if (empty($mimetype)) {
00117             $mimetype = $default;
00118         }
00119 
00120         parent::__construct($mimetype);
00121     }
00122 
00131     protected function _throw($file, $errorType)
00132     {
00133         $this->_value = $file['name'];
00134         switch($errorType) {
00135             case Zend_Validate_File_MimeType::FALSE_TYPE :
00136                 $errorType = self::FALSE_TYPE;
00137                 break;
00138             case Zend_Validate_File_MimeType::NOT_DETECTED :
00139                 $errorType = self::NOT_DETECTED;
00140                 break;
00141             case Zend_Validate_File_MimeType::NOT_READABLE :
00142                 $errorType = self::NOT_READABLE;
00143                 break;
00144         }
00145 
00146         $this->_error($errorType);
00147         return false;
00148     }
00149 }
 All Data Structures Namespaces Files Functions Variables Enumerations