mirror of
https://github.com/colymba/GridFieldBulkEditingTools.git
synced 2024-10-22 11:05:57 +02:00
API: added forbidden filed classes
Some fields classes break the component. These have been added to a forbidden list and cannot be removed from the blacklist.
This commit is contained in:
parent
c916d6ac12
commit
b8a0a1e14f
@ -20,10 +20,16 @@ class GridFieldBulkImageUpload implements GridField_HTMLProvider, GridField_URLH
|
|||||||
protected $config = array(
|
protected $config = array(
|
||||||
'imageFieldName' => null,
|
'imageFieldName' => null,
|
||||||
'editableFields' => null,
|
'editableFields' => null,
|
||||||
'fieldsClassBlacklist' => array( 'GridField', 'UploadField' ),
|
'fieldsClassBlacklist' => array(),
|
||||||
'fieldsNameBlacklist' => array(),
|
'fieldsNameBlacklist' => array(),
|
||||||
'folderName' => 'bulkUpload'
|
'folderName' => 'bulkUpload'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds any class that should not be used as they break the component
|
||||||
|
* These cannot be removed from the blacklist
|
||||||
|
*/
|
||||||
|
protected $forbiddenFieldsClasses = array( 'GridField', 'UploadField' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -34,6 +40,9 @@ class GridFieldBulkImageUpload implements GridField_HTMLProvider, GridField_URLH
|
|||||||
{
|
{
|
||||||
if ( $imageField != null ) $this->setConfig ( 'imageFieldName', $imageField );
|
if ( $imageField != null ) $this->setConfig ( 'imageFieldName', $imageField );
|
||||||
if ( $editableFields != null ) $this->setConfig ( 'editableFields', $editableFields );
|
if ( $editableFields != null ) $this->setConfig ( 'editableFields', $editableFields );
|
||||||
|
|
||||||
|
//init classes blacklist with forbidden classes
|
||||||
|
$this->config['fieldsClassBlacklist'] = $this->forbiddenFieldsClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,6 +59,13 @@ class GridFieldBulkImageUpload implements GridField_HTMLProvider, GridField_URLH
|
|||||||
{
|
{
|
||||||
$value = array($value);
|
$value = array($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//makes sure $forbiddenFieldsClasses are in no matter what
|
||||||
|
if ( $reference == 'fieldsClassBlacklist' )
|
||||||
|
{
|
||||||
|
$value = array_unique( array_merge($value, $this->forbiddenFieldsClasses) );
|
||||||
|
}
|
||||||
|
|
||||||
$this->config[$reference] = $value;
|
$this->config[$reference] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,7 +127,7 @@ class GridFieldBulkImageUpload implements GridField_HTMLProvider, GridField_URLH
|
|||||||
*/
|
*/
|
||||||
function removeClassFromBlacklist ( $className )
|
function removeClassFromBlacklist ( $className )
|
||||||
{
|
{
|
||||||
if (key_exists($className, $this->config['fieldsNameBlacklist'])) {
|
if (key_exists($className, $this->config['fieldsNameBlacklist']) && !in_array($className, $this->forbiddenFieldsClasses)) {
|
||||||
return delete( $this->config['fieldsNameBlacklist'][$className] );
|
return delete( $this->config['fieldsNameBlacklist'][$className] );
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user