Skip to content

Commit

Permalink
FIX silverstripe#8 Add config option for sequential uploads
Browse files Browse the repository at this point in the history
setting Component option 'sequentialUploads' to true will upload files
one by one in the order they were selected
  • Loading branch information
colymba committed Jan 10, 2013
1 parent efe4e35 commit eb944b6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ The available configuration options are:
* 'fieldsClassBlacklist' : array of string referencing types (ClassName) of fields that wont be available for editing
* '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

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:
Expand Down
9 changes: 8 additions & 1 deletion code/GridFieldBulkImageUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class GridFieldBulkImageUpload implements GridField_HTMLProvider, GridField_URLH
'editableFields' => null,
'fieldsClassBlacklist' => array(),
'fieldsNameBlacklist' => array(),
'folderName' => 'bulkUpload'
'folderName' => 'bulkUpload',
'sequentialUploads' => false
);

/**
Expand Down Expand Up @@ -67,6 +68,12 @@ function setConfig ( $reference, $value )
{
$value = array_unique( array_merge($value, $this->forbiddenFieldsClasses) );
}

//sequentialUploads true/false
if ( $reference == 'sequentialUploads' && !is_bool($value) )
{
$value = false;
}

$this->config[$reference] = $value;
}
Expand Down
3 changes: 2 additions & 1 deletion code/GridFieldBulkImageUpload_Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ public function index()
$uploadField->removeExtraClass('ss-uploadfield');

$uploadField->setTemplate('AssetUploadField');
$uploadField->setConfig('downloadTemplateName','GridFieldBulkImageUpload_downloadtemplate');
$uploadField->setConfig('downloadTemplateName','GridFieldBulkImageUpload_downloadtemplate');
$uploadField->setConfig('sequentialUploads', $this->component->getConfig('sequentialUploads'));


$uploadField->setConfig('url', $this->Link('upload'));
Expand Down

0 comments on commit eb944b6

Please sign in to comment.