mirror of
https://github.com/colymba/GridFieldBulkEditingTools.git
synced 2024-10-22 09:05:57 +00:00
add max upload file size config
Bulk upload maximum file size can now be set through setConfig('maxFileSize', Xbytes )
This commit is contained in:
parent
2bfd2a8309
commit
60a5e48979
@ -45,7 +45,8 @@ The available configuration options are:
|
||||
* 'fieldsNameBlacklist' : array of string referencing the names of fields that wont be available for editing
|
||||
* 'folderName' : name of the folder where the images should be uploaded
|
||||
* 'sequentialUploads' : boolean, if true files will be uploaded one by one
|
||||
|
||||
* 'maxFileSize' : integer, maximum upload file size in bytes
|
||||
|
||||
Each option can be set through the component's method setConfig( $reference, $value )
|
||||
In addition, some configuration option can be set more specifically via individual methods:
|
||||
* addFieldNameToBlacklist( $fieldName )
|
||||
|
@ -23,6 +23,7 @@ class GridFieldBulkImageUpload implements GridField_HTMLProvider, GridField_URLH
|
||||
'fieldsClassBlacklist' => array(),
|
||||
'fieldsNameBlacklist' => array(),
|
||||
'folderName' => 'bulkUpload',
|
||||
'maxFileSize' => null,
|
||||
'sequentialUploads' => false
|
||||
);
|
||||
|
||||
@ -68,6 +69,13 @@ class GridFieldBulkImageUpload implements GridField_HTMLProvider, GridField_URLH
|
||||
{
|
||||
$value = array_unique( array_merge($value, $this->forbiddenFieldsClasses) );
|
||||
}
|
||||
|
||||
//makes sure maxFileSize is INT
|
||||
if ( $reference == 'maxFileSize' && !is_int($value) )
|
||||
{
|
||||
user_warning("maxFileSize should be an Integer. Setting it to Auto.", E_USER_ERROR);
|
||||
$value = null;
|
||||
}
|
||||
|
||||
//sequentialUploads true/false
|
||||
if ( $reference == 'sequentialUploads' && !is_bool($value) )
|
||||
|
@ -219,6 +219,11 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
|
||||
$uploadField->setConfig('downloadTemplateName','GridFieldBulkImageUpload_downloadtemplate');
|
||||
$uploadField->setConfig('sequentialUploads', $this->component->getConfig('sequentialUploads'));
|
||||
|
||||
$maxFileSize = $this->component->getConfig('maxFileSize');
|
||||
if ( $maxFileSize !== null )
|
||||
{
|
||||
$uploadField->getValidator()->setAllowedMaxFileSize( $maxFileSize );
|
||||
}
|
||||
|
||||
$uploadField->setConfig('url', $this->Link('upload'));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user