mirror of
https://github.com/colymba/GridFieldBulkEditingTools.git
synced 2024-10-22 11:05:57 +02:00
BulkUploadField Extends UploadField so handlers link properly through the GridField
This commit is contained in:
parent
825b989ad6
commit
29482dbd17
21
bulkUpload/code/BulkUploadField.php
Normal file
21
bulkUpload/code/BulkUploadField.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Custom UploadField used to override Link()
|
||||
* and redirect UploadField action properly through the GridField.
|
||||
*
|
||||
* @author colymba
|
||||
*/
|
||||
class BulkUploadField extends UploadField
|
||||
{
|
||||
protected $gridfield;
|
||||
|
||||
public function __construct($gridfield, $parent, $folderName = null) {
|
||||
$this->gridfield = $gridfield;
|
||||
parent::__construct($parent, $folderName);
|
||||
}
|
||||
|
||||
public function Link($action = null)
|
||||
{
|
||||
return Controller::join_links($this->gridfield->Link(), 'bulkupload/', $action);
|
||||
}
|
||||
}
|
@ -290,7 +290,7 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
||||
public function bulkUploadField($gridField)
|
||||
{
|
||||
$fileRelationName = $this->getFileRelationName($gridField);
|
||||
$uploadField = UploadField::create($fileRelationName, '')
|
||||
$uploadField = BulkUploadField::create($gridField, $fileRelationName, '')
|
||||
->setForm($gridField->getForm())
|
||||
|
||||
->setConfig('previewMaxWidth', 20)
|
||||
@ -417,7 +417,7 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
||||
public function getURLHandlers($gridField)
|
||||
{
|
||||
return array(
|
||||
'bulkupload' => 'handleBulkUpload',
|
||||
'bulkupload' => 'handleBulkUpload'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ class GridFieldBulkUpload_Request extends RequestHandler
|
||||
* @var array
|
||||
*/
|
||||
private static $allowed_actions = array(
|
||||
'upload', 'select', 'attach', 'fileexists',
|
||||
'upload', 'attach', 'fileexists', 'select'
|
||||
);
|
||||
|
||||
/**
|
||||
@ -42,7 +42,7 @@ class GridFieldBulkUpload_Request extends RequestHandler
|
||||
* @var array
|
||||
*/
|
||||
private static $url_handlers = array(
|
||||
'$Action!' => '$Action',
|
||||
'$Action!' => '$Action'
|
||||
);
|
||||
|
||||
/**
|
||||
@ -169,22 +169,6 @@ class GridFieldBulkUpload_Request extends RequestHandler
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass select request to UploadField.
|
||||
*
|
||||
* @link UploadField->select()
|
||||
*/
|
||||
public function select(SS_HTTPRequest $request)
|
||||
{
|
||||
/*
|
||||
$uploadField = $this->getUploadField();
|
||||
return $uploadField->handleSelect($request);
|
||||
*/
|
||||
$uploadField = $this->getUploadField();
|
||||
|
||||
return UploadField_SelectHandler::create($uploadField, $uploadField->getFolderName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass getRelationAutosetClass request to UploadField
|
||||
* Used by select dialog.
|
||||
@ -255,6 +239,20 @@ class GridFieldBulkUpload_Request extends RequestHandler
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass select request to UploadField.
|
||||
*
|
||||
* @link UploadField->select()
|
||||
*/
|
||||
public function select(SS_HTTPRequest $request)
|
||||
{
|
||||
|
||||
$uploadField = $this->getUploadField();
|
||||
$uploadField->setRequest($request);
|
||||
|
||||
return $uploadField->handleSelect($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass fileexists request to UploadField.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user