mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Upload_Validator fixing file size spelling
This commit is contained in:
parent
0178fa5a18
commit
7867c51388
@ -391,7 +391,7 @@ class Upload_Validator {
|
|||||||
* @return int Filesize in bytes
|
* @return int Filesize in bytes
|
||||||
*/
|
*/
|
||||||
public function getAllowedMaxFileSize($ext = null) {
|
public function getAllowedMaxFileSize($ext = null) {
|
||||||
|
|
||||||
// Check if there is any defined instance max file sizes
|
// Check if there is any defined instance max file sizes
|
||||||
if (empty($this->allowedMaxFileSize)) {
|
if (empty($this->allowedMaxFileSize)) {
|
||||||
// Set default max file sizes if there isn't
|
// Set default max file sizes if there isn't
|
||||||
@ -405,18 +405,18 @@ class Upload_Validator {
|
|||||||
$this->setAllowedMaxFileSize(min($maxUpload, $maxPost));
|
$this->setAllowedMaxFileSize(min($maxUpload, $maxPost));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ext = strtolower($ext);
|
$ext = strtolower($ext);
|
||||||
if ($ext) {
|
if ($ext) {
|
||||||
if (isset($this->allowedMaxFileSize[$ext])) {
|
if (isset($this->allowedMaxFileSize[$ext])) {
|
||||||
return $this->allowedMaxFileSize[$ext];
|
return $this->allowedMaxFileSize[$ext];
|
||||||
}
|
}
|
||||||
|
|
||||||
$category = File::get_app_category($ext);
|
$category = File::get_app_category($ext);
|
||||||
if ($category && isset($this->allowedMaxFileSize['[' . $category . ']'])) {
|
if ($category && isset($this->allowedMaxFileSize['[' . $category . ']'])) {
|
||||||
return $this->allowedMaxFileSize['[' . $category . ']'];
|
return $this->allowedMaxFileSize['[' . $category . ']'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return (isset($this->allowedMaxFileSize['*'])) ? $this->allowedMaxFileSize['*'] : false;
|
return (isset($this->allowedMaxFileSize['*'])) ? $this->allowedMaxFileSize['*'] : false;
|
||||||
@ -441,17 +441,17 @@ class Upload_Validator {
|
|||||||
$rules = array_change_key_case($rules, CASE_LOWER);
|
$rules = array_change_key_case($rules, CASE_LOWER);
|
||||||
$finalRules = array();
|
$finalRules = array();
|
||||||
$tmpSize = 0;
|
$tmpSize = 0;
|
||||||
|
|
||||||
foreach ($rules as $rule => $value) {
|
foreach ($rules as $rule => $value) {
|
||||||
if (is_numeric($value)) {
|
if (is_numeric($value)) {
|
||||||
$tmpSize = $value;
|
$tmpSize = $value;
|
||||||
} else {
|
} else {
|
||||||
$tmpSize = File::ini2bytes($value);
|
$tmpSize = File::ini2bytes($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
$finalRules[$rule] = (int)$tmpSize;
|
$finalRules[$rule] = (int)$tmpSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->allowedMaxFileSize = $finalRules;
|
$this->allowedMaxFileSize = $finalRules;
|
||||||
} elseif(is_string($rules)) {
|
} elseif(is_string($rules)) {
|
||||||
$this->allowedMaxFileSize['*'] = File::ini2bytes($rules);
|
$this->allowedMaxFileSize['*'] = File::ini2bytes($rules);
|
||||||
@ -540,8 +540,8 @@ class Upload_Validator {
|
|||||||
$arg = File::format_size($this->getAllowedMaxFileSize($ext));
|
$arg = File::format_size($this->getAllowedMaxFileSize($ext));
|
||||||
$this->errors[] = _t(
|
$this->errors[] = _t(
|
||||||
'File.TOOLARGE',
|
'File.TOOLARGE',
|
||||||
'Filesize is too large, maximum {size} allowed',
|
'File size is too large, maximum {size} allowed',
|
||||||
'Argument 1: Filesize (e.g. 1MB)',
|
'Argument 1: File size (e.g. 1MB)',
|
||||||
array('size' => $arg)
|
array('size' => $arg)
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user