00001 <?php 00025 require_once 'Zend/Validate/File/Exists.php'; 00026 00035 class Zend_Validate_File_NotExists extends Zend_Validate_File_Exists 00036 { 00040 const DOES_EXIST = 'fileNotExistsDoesExist'; 00041 00045 protected $_messageTemplates = array( 00046 self::DOES_EXIST => "The file '%value%' does exist" 00047 ); 00048 00058 public function isValid($value, $file = null) 00059 { 00060 $directories = $this->getDirectory(true); 00061 if (($file !== null) and (!empty($file['destination']))) { 00062 $directories[] = $file['destination']; 00063 } else if (!isset($file['name'])) { 00064 $file['name'] = $value; 00065 } 00066 00067 foreach ($directories as $directory) { 00068 if (empty($directory)) { 00069 continue; 00070 } 00071 00072 $check = true; 00073 if (file_exists($directory . DIRECTORY_SEPARATOR . $file['name'])) { 00074 return $this->_throw($file, self::DOES_EXIST); 00075 } 00076 } 00077 00078 if (!isset($check)) { 00079 return $this->_throw($file, self::DOES_EXIST); 00080 } 00081 00082 return true; 00083 } 00084 }