00001 <?php
00025 require_once 'Zend/Validate/File/Extension.php';
00026
00035 class Zend_Validate_File_ExcludeExtension extends Zend_Validate_File_Extension
00036 {
00040 const FALSE_EXTENSION = 'fileExcludeExtensionFalse';
00041 const NOT_FOUND = 'fileExcludeExtensionNotFound';
00042
00046 protected $_messageTemplates = array(
00047 self::FALSE_EXTENSION => "The file '%value%' has a false extension",
00048 self::NOT_FOUND => "The file '%value%' was not found"
00049 );
00050
00061 public function isValid($value, $file = null)
00062 {
00063
00064 require_once 'Zend/Loader.php';
00065 if (!Zend_Loader::isReadable($value)) {
00066 return $this->_throw($file, self::NOT_FOUND);
00067 }
00068
00069 if ($file !== null) {
00070 $info['extension'] = substr($file['name'], strrpos($file['name'], '.') + 1);
00071 } else {
00072 $info = pathinfo($value);
00073 }
00074
00075 $extensions = $this->getExtension();
00076
00077 if ($this->_case and (!in_array($info['extension'], $extensions))) {
00078 return true;
00079 } else if (!$this->_case) {
00080 $found = false;
00081 foreach ($extensions as $extension) {
00082 if (strtolower($extension) == strtolower($info['extension'])) {
00083 $found = true;
00084 }
00085 }
00086
00087 if (!$found) {
00088 return true;
00089 }
00090 }
00091
00092 return $this->_throw($file, self::FALSE_EXTENSION);
00093 }
00094 }