PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/concreteOLD/libraries/3rdparty/Zend/Validate/File/NotExists.php

https://bitbucket.org/selfeky/xclusivescardwebsite
PHP | 84 lines | 31 code | 8 blank | 45 comment | 6 complexity | 4ed69bba742db9611949e5665a191d92 MD5 | raw file
  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-2011 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id: NotExists.php 23775 2011-03-01 17:25:24Z ralph $
  20. */
  21. /**
  22. * @see Zend_Validate_File_Exists
  23. */
  24. require_once 'Zend/Validate/File/Exists.php';
  25. /**
  26. * Validator which checks if the destination file does not exist
  27. *
  28. * @category Zend
  29. * @package Zend_Validate
  30. * @copyright Copyright (c) 2005-2011 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_NotExists extends Zend_Validate_File_Exists
  34. {
  35. /**
  36. * @const string Error constants
  37. */
  38. const DOES_EXIST = 'fileNotExistsDoesExist';
  39. /**
  40. * @var array Error message templates
  41. */
  42. protected $_messageTemplates = array(
  43. self::DOES_EXIST => "File '%value%' exists",
  44. );
  45. /**
  46. * Defined by Zend_Validate_Interface
  47. *
  48. * Returns true if and only if the file does not exist in the set destinations
  49. *
  50. * @param string $value Real file to check for
  51. * @param array $file File data from Zend_File_Transfer
  52. * @return boolean
  53. */
  54. public function isValid($value, $file = null)
  55. {
  56. $directories = $this->getDirectory(true);
  57. if (($file !== null) and (!empty($file['destination']))) {
  58. $directories[] = $file['destination'];
  59. } else if (!isset($file['name'])) {
  60. $file['name'] = $value;
  61. }
  62. foreach ($directories as $directory) {
  63. if (empty($directory)) {
  64. continue;
  65. }
  66. $check = true;
  67. if (file_exists($directory . DIRECTORY_SEPARATOR . $file['name'])) {
  68. return $this->_throw($file, self::DOES_EXIST);
  69. }
  70. }
  71. if (!isset($check)) {
  72. return $this->_throw($file, self::DOES_EXIST);
  73. }
  74. return true;
  75. }
  76. }