TYPO3 CMS  TYPO3_6-2
FileAllowedTypesValidator.php
Go to the documentation of this file.
1 <?php
3 
24 
30  const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_fileallowedtypes';
31 
37  protected $allowedTypes;
38 
44  public function __construct($arguments) {
45  $this->setAllowedTypes($arguments['types']);
46  parent::__construct($arguments);
47  }
48 
55  public function isValid() {
56  if ($this->requestHandler->has($this->fieldName)) {
57  $fileValue = $this->requestHandler->getByMethod($this->fieldName);
58  $value = strtolower($fileValue['type']);
59  if (!in_array($value, $this->allowedTypes)) {
60  return FALSE;
61  }
62  }
63  return TRUE;
64  }
65 
72  public function setAllowedTypes($allowedTypes) {
73  $allowedTypes = strtolower($allowedTypes);
75  return $this;
76  }
77 
85  protected function substituteValues($message) {
86  $message = str_replace('%allowedTypes', implode(',', $this->allowedTypes), $message);
87  return $message;
88  }
89 
90 }
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)