TYPO3 CMS  TYPO3_6-2
FileMaximumSizeValidator.php
Go to the documentation of this file.
1 <?php
3 
24 
30  const LOCALISATION_OBJECT_NAME = 'tx_form_system_validate_filemaximumsize';
31 
37  protected $maximum;
38 
44  public function __construct($arguments) {
45  $this->setMaximum($arguments['maximum']);
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 = $fileValue['size'];
59  if ($value > $this->maximum) {
60  return FALSE;
61  }
62  }
63  return TRUE;
64  }
65 
72  public function setMaximum($maximum) {
73  $this->maximum = (int)$maximum;
74  return $this;
75  }
76 
84  protected function substituteValues($message) {
85  $message = str_replace('%maximum', \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($this->maximum), $message);
86  return $message;
87  }
88 
89 }